2017-04-24 15:51:12 +00:00
|
|
|
# -*- coding:utf-8 -*
|
|
|
|
#
|
2023-04-04 17:17:44 +00:00
|
|
|
# Copyright 2023 © AE UTBM
|
|
|
|
# ae@utbm.fr / ae.info@utbm.fr
|
2017-04-24 15:51:12 +00:00
|
|
|
#
|
2023-04-04 17:17:44 +00:00
|
|
|
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
|
|
|
# https://ae.utbm.fr.
|
2017-04-24 15:51:12 +00:00
|
|
|
#
|
2023-04-04 17:17:44 +00:00
|
|
|
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
2017-04-24 15:51:12 +00:00
|
|
|
#
|
2023-04-04 17:17:44 +00:00
|
|
|
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
|
|
|
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
|
|
|
# OR WITHIN THE LOCAL FILE "LICENSE"
|
2017-04-24 15:51:12 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2015-12-04 15:13:20 +00:00
|
|
|
import os
|
2017-06-12 07:42:03 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
2015-12-03 17:00:08 +00:00
|
|
|
from django.core.management import call_command
|
2016-01-28 15:53:37 +00:00
|
|
|
|
|
|
|
|
2015-12-03 17:00:08 +00:00
|
|
|
class Command(BaseCommand):
|
|
|
|
help = "Set up a new instance of the Sith AE"
|
|
|
|
|
2015-12-04 15:13:20 +00:00
|
|
|
def add_arguments(self, parser):
|
2018-10-04 19:29:19 +00:00
|
|
|
parser.add_argument("--prod", action="store_true")
|
2015-12-04 15:13:20 +00:00
|
|
|
|
2015-12-03 17:00:08 +00:00
|
|
|
def handle(self, *args, **options):
|
2018-10-04 19:29:19 +00:00
|
|
|
root_path = os.path.dirname(
|
|
|
|
os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
|
|
|
)
|
2015-12-03 17:00:08 +00:00
|
|
|
try:
|
2018-10-04 19:29:19 +00:00
|
|
|
os.mkdir(os.path.join(root_path) + "/data")
|
2017-01-07 09:36:54 +00:00
|
|
|
print("Data dir created")
|
2016-01-28 15:53:37 +00:00
|
|
|
except Exception as e:
|
2017-01-07 09:36:54 +00:00
|
|
|
repr(e)
|
|
|
|
try:
|
2018-10-04 19:29:19 +00:00
|
|
|
os.remove(os.path.join(root_path, "db.sqlite3"))
|
2017-01-07 09:36:54 +00:00
|
|
|
print("db.sqlite3 deleted")
|
|
|
|
except Exception as e:
|
|
|
|
repr(e)
|
2018-10-04 19:29:19 +00:00
|
|
|
call_command("migrate")
|
|
|
|
if options["prod"]:
|
|
|
|
call_command("populate", "--prod")
|
2016-03-22 08:01:24 +00:00
|
|
|
else:
|
2018-10-04 19:29:19 +00:00
|
|
|
call_command("populate")
|