Sith/core/management/commands/setup.py

41 lines
1.2 KiB
Python
Raw Permalink Normal View History

# -*- coding:utf-8 -*
#
# Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr
#
# This file is part of the website of the UTBM Student Association (AE UTBM),
# https://ae.utbm.fr.
#
# You can find the source code of the website at https://github.com/ae-utbm/sith3
#
# 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"
#
#
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"
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")
print("Data dir created")
2016-01-28 15:53:37 +00:00
except Exception as e:
repr(e)
try:
2018-10-04 19:29:19 +00:00
os.remove(os.path.join(root_path, "db.sqlite3"))
print("db.sqlite3 deleted")
except Exception as e:
repr(e)
2018-10-04 19:29:19 +00:00
call_command("migrate")
2023-05-10 09:56:33 +00:00
call_command("populate")