Sith/core/management/commands/setup.py

46 lines
1.4 KiB
Python
Raw Permalink Normal View History

2023-04-06 11:08:42 +00:00
# -*- coding:utf-8 -*-
#
# Copyright 2023 © AE UTBM
# ae@utbm.fr / ae.info@utbm.fr
2023-04-06 11:08:42 +00:00
# All contributors are listed in the CONTRIBUTORS file.
#
# This file is part of the website of the UTBM Student Association (AE UTBM),
# https://ae.utbm.fr.
#
2023-04-06 11:08:42 +00:00
# You can find the whole source code 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"
#
2023-04-06 11:08:42 +00:00
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
# OR WITHIN THE LOCAL FILE "LICENSE.old"
#
2015-12-04 15:13:20 +00:00
import os
2024-06-24 11:07:36 +00:00
2015-12-03 17:00:08 +00:00
from django.core.management import call_command
2024-06-24 11:07:36 +00:00
from django.core.management.base import BaseCommand
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-02 09:00:23 +00:00
call_command("populate")