2017-04-24 17:51:12 +02:00
|
|
|
#
|
2023-04-04 18:39:45 +02:00
|
|
|
# Copyright 2023 © AE UTBM
|
|
|
|
# ae@utbm.fr / ae.info@utbm.fr
|
2017-04-24 17:51:12 +02:00
|
|
|
#
|
2023-04-04 18:39:45 +02:00
|
|
|
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
|
|
|
# https://ae.utbm.fr.
|
2017-04-24 17:51:12 +02:00
|
|
|
#
|
2024-09-23 01:37:25 +02:00
|
|
|
# You can find the source code of the website at https://github.com/ae-utbm/sith
|
2017-04-24 17:51:12 +02:00
|
|
|
#
|
2023-04-04 18:39:45 +02:00
|
|
|
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
2024-09-23 10:25:27 +02:00
|
|
|
# SEE : https://raw.githubusercontent.com/ae-utbm/sith/master/LICENSE
|
2023-04-04 18:39:45 +02:00
|
|
|
# OR WITHIN THE LOCAL FILE "LICENSE"
|
2017-04-24 17:51:12 +02:00
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2024-07-24 00:16:31 +02:00
|
|
|
from django.conf import settings
|
2015-12-03 18:00:08 +01:00
|
|
|
from django.core.management import call_command
|
2024-06-24 13:07:36 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
2016-01-28 16:53:37 +01:00
|
|
|
|
|
|
|
|
2015-12-03 18:00:08 +01:00
|
|
|
class Command(BaseCommand):
|
2024-07-24 00:16:31 +02:00
|
|
|
help = "Set up the development environment."
|
2015-12-03 18:00:08 +01:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2024-07-24 00:16:31 +02:00
|
|
|
if not settings.DEBUG:
|
|
|
|
raise Exception("Never call this command in prod. Never.")
|
2024-07-26 18:19:17 +02:00
|
|
|
data_dir = settings.BASE_DIR / "data"
|
2024-07-24 00:16:31 +02:00
|
|
|
settings.EMAIL_BACKEND = "django.core.mail.backends.dummy.EmailBackend"
|
|
|
|
if not data_dir.is_dir():
|
|
|
|
data_dir.mkdir()
|
2024-07-26 18:19:17 +02:00
|
|
|
db_path = settings.BASE_DIR / "db.sqlite3"
|
2024-07-24 00:16:31 +02:00
|
|
|
if db_path.exists():
|
|
|
|
call_command("flush", "--noinput")
|
|
|
|
self.stdout.write("Existing database reset")
|
2018-10-04 21:29:19 +02:00
|
|
|
call_command("migrate")
|
2024-07-24 00:16:31 +02:00
|
|
|
self.stdout.write("Add the base fixtures.")
|
2023-05-02 11:00:23 +02:00
|
|
|
call_command("populate")
|
2024-07-24 00:16:31 +02:00
|
|
|
self.stdout.write("Generate additional random fixtures")
|
|
|
|
call_command("populate_more")
|
|
|
|
self.stdout.write("Build the xapian index")
|
|
|
|
call_command("rebuild_index", "--noinput")
|
|
|
|
|
|
|
|
settings.EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
|
|
|
self.stdout.write("Setup complete!")
|