Minor improvements in the command 'generate_sha1'

remotes/origin/logger
David Barragán Merino 2015-09-28 10:59:32 +02:00
parent 24cea7cc83
commit f4b11b26fb
1 changed files with 9 additions and 2 deletions

View File

@ -3,10 +3,17 @@ from django.db import transaction
from taiga.projects.attachments.models import Attachment
import logging
logger = logging.getLogger(__name__)
class Command(BaseCommand):
@transaction.atomic
def handle(self, *args, **options):
for attachment in Attachment.objects.all():
total = rest = Attachment.objects.all().count()
for attachment in Attachment.objects.all().order_by("id"):
attachment.save()
rest -= 1
logger.debug("[{} / {} remaining] - Generate sha1 for attach {}".format(rest, total, attachment.id))