mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 03:02:14 +01:00 
			
		
		
		
	Comment code, fix minor issues
This commit is contained in:
		@@ -7,6 +7,9 @@ from member.models import TFJMUser
 | 
			
		||||
 | 
			
		||||
class Command(BaseCommand):
 | 
			
		||||
    def handle(self, *args, **options):
 | 
			
		||||
        """
 | 
			
		||||
        Little script that generate a superuser.
 | 
			
		||||
        """
 | 
			
		||||
        email = input("Email: ")
 | 
			
		||||
        password = "1"
 | 
			
		||||
        confirm_password = "2"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
from django.core.management import BaseCommand, CommandError
 | 
			
		||||
from django.db import transaction
 | 
			
		||||
from member.models import TFJMUser, Document, Solution, Synthesis, Authorization, MotivationLetter
 | 
			
		||||
@@ -5,6 +7,11 @@ from tournament.models import Team, Tournament
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Command(BaseCommand):
 | 
			
		||||
    """
 | 
			
		||||
    Import the old database.
 | 
			
		||||
    Tables must be found into the import_olddb folder, as CSV files.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def add_arguments(self, parser):
 | 
			
		||||
        parser.add_argument('--tournaments', '-t', action="store", help="Import tournaments")
 | 
			
		||||
        parser.add_argument('--teams', '-T', action="store", help="Import teams")
 | 
			
		||||
@@ -26,6 +33,9 @@ class Command(BaseCommand):
 | 
			
		||||
 | 
			
		||||
    @transaction.atomic
 | 
			
		||||
    def import_tournaments(self):
 | 
			
		||||
        """
 | 
			
		||||
        Import tournaments into the new database.
 | 
			
		||||
        """
 | 
			
		||||
        print("Importing tournaments...")
 | 
			
		||||
        with open("import_olddb/tournaments.csv") as f:
 | 
			
		||||
            first_line = True
 | 
			
		||||
@@ -75,6 +85,9 @@ class Command(BaseCommand):
 | 
			
		||||
 | 
			
		||||
    @transaction.atomic
 | 
			
		||||
    def import_teams(self):
 | 
			
		||||
        """
 | 
			
		||||
        Import teams into new database.
 | 
			
		||||
        """
 | 
			
		||||
        self.stdout.write("Importing teams...")
 | 
			
		||||
        with open("import_olddb/teams.csv") as f:
 | 
			
		||||
            first_line = True
 | 
			
		||||
@@ -120,6 +133,10 @@ class Command(BaseCommand):
 | 
			
		||||
 | 
			
		||||
    @transaction.atomic
 | 
			
		||||
    def import_users(self):
 | 
			
		||||
        """
 | 
			
		||||
        Import users into the new database.
 | 
			
		||||
        :return:
 | 
			
		||||
        """
 | 
			
		||||
        self.stdout.write("Importing users...")
 | 
			
		||||
        with open("import_olddb/users.csv") as f:
 | 
			
		||||
            first_line = True
 | 
			
		||||
@@ -159,7 +176,7 @@ class Command(BaseCommand):
 | 
			
		||||
                    "team": Team.objects.get(pk=args[19]) if args[19] else None,
 | 
			
		||||
                    "year": args[20],
 | 
			
		||||
                    "date_joined": args[23],
 | 
			
		||||
                    "is_active": args[18] == "ADMIN",  # TODO Replace it with "True"
 | 
			
		||||
                    "is_active": args[18] == "ADMIN" or os.getenv("TFJM_STAGE", "dev") == "prod",
 | 
			
		||||
                    "is_staff": args[18] == "ADMIN",
 | 
			
		||||
                    "is_superuser": args[18] == "ADMIN",
 | 
			
		||||
                }
 | 
			
		||||
@@ -168,6 +185,7 @@ class Command(BaseCommand):
 | 
			
		||||
        self.stdout.write(self.style.SUCCESS("Users imported"))
 | 
			
		||||
 | 
			
		||||
        self.stdout.write("Importing organizers...")
 | 
			
		||||
        # We also import the information about the organizers of a tournament.
 | 
			
		||||
        with open("import_olddb/organizers.csv") as f:
 | 
			
		||||
            first_line = True
 | 
			
		||||
            for line in f:
 | 
			
		||||
@@ -188,6 +206,9 @@ class Command(BaseCommand):
 | 
			
		||||
 | 
			
		||||
    @transaction.atomic
 | 
			
		||||
    def import_documents(self):
 | 
			
		||||
        """
 | 
			
		||||
        Import the documents (authorizations, motivation letters, solutions, syntheses) from the old database.
 | 
			
		||||
        """
 | 
			
		||||
        self.stdout.write("Importing documents...")
 | 
			
		||||
        with open("import_olddb/documents.csv") as f:
 | 
			
		||||
            first_line = True
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user