From c51bdd0d1aea7938d68112bb800aa54b907b1c44 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 6 May 2020 14:28:51 +0200 Subject: [PATCH] Fix date import of old documents --- apps/member/management/commands/import_olddb.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/member/management/commands/import_olddb.py b/apps/member/management/commands/import_olddb.py index da9280a..1759f14 100644 --- a/apps/member/management/commands/import_olddb.py +++ b/apps/member/management/commands/import_olddb.py @@ -7,10 +7,10 @@ from tournament.models import Team, Tournament class Command(BaseCommand): def add_arguments(self, parser): - parser.add_argument('--tournaments', '-t', action="store_true", help="Import tournaments") - parser.add_argument('--teams', '-T', action="store_true", help="Import teams") - parser.add_argument('--users', '-u', action="store_true", help="Import users") - parser.add_argument('--documents', '-d', action="store_true", help="Import all documents") + parser.add_argument('--tournaments', '-t', action="store", help="Import tournaments") + parser.add_argument('--teams', '-T', action="store", help="Import teams") + parser.add_argument('--users', '-u', action="store", help="Import users") + parser.add_argument('--documents', '-d', action="store", help="Import all documents") def handle(self, *args, **options): if "tournaments" in options: @@ -202,6 +202,9 @@ class Command(BaseCommand): args = [arg if arg and arg != "NULL" else None for arg in args] if Document.objects.filter(file=args[0]).exists(): + doc = Document.objects.get(file=args[0]) + doc.uploaded_at = args[5].replace(" ", "T") + doc.save() continue obj_dict = { @@ -236,6 +239,9 @@ class Command(BaseCommand): args = [arg if arg and arg != "NULL" else None for arg in args] if Document.objects.filter(file=args[0]).exists(): + doc = Document.objects.get(file=args[0]) + doc.uploaded_at = args[4].replace(" ", "T") + doc.save() continue obj_dict = { @@ -263,6 +269,9 @@ class Command(BaseCommand): args = [arg if arg and arg != "NULL" else None for arg in args] if Document.objects.filter(file=args[0]).exists(): + doc = Document.objects.get(file=args[0]) + doc.uploaded_at = args[5].replace(" ", "T") + doc.save() continue obj_dict = {