1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 06:22:22 +00:00

Fix date import of old documents

This commit is contained in:
Yohann D'ANELLO 2020-05-06 14:28:51 +02:00
parent 49ae0f18f5
commit c51bdd0d1a

View File

@ -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 = {