repair BASE_DIR

This commit is contained in:
thomas girod 2024-07-26 18:19:17 +02:00
parent 424639ea80
commit 63b6b262c6
5 changed files with 3 additions and 17 deletions

View File

@ -21,8 +21,6 @@
# #
# #
import os
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from core.models import SithFile from core.models import SithFile
@ -37,9 +35,6 @@ class Command(BaseCommand):
) )
def handle(self, *args, **options): def handle(self, *args, **options):
root_path = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
)
files = SithFile.objects.filter(id__in=options["ids"]).all() files = SithFile.objects.filter(id__in=options["ids"]).all()
for f in files: for f in files:
f._check_fs() f._check_fs()

View File

@ -21,7 +21,6 @@
# #
# #
import os
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
@ -37,9 +36,6 @@ class Command(BaseCommand):
) )
def handle(self, *args, **options): def handle(self, *args, **options):
root_path = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
)
files = SithFile.objects.filter(id__in=options["ids"]).all() files = SithFile.objects.filter(id__in=options["ids"]).all()
for f in files: for f in files:
f._repair_fs() f._repair_fs()

View File

@ -13,8 +13,6 @@
# #
# #
from pathlib import Path
from django.conf import settings from django.conf import settings
from django.core.management import call_command from django.core.management import call_command
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
@ -26,11 +24,11 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
if not settings.DEBUG: if not settings.DEBUG:
raise Exception("Never call this command in prod. Never.") raise Exception("Never call this command in prod. Never.")
data_dir = Path(settings.BASE_DIR) / "data" data_dir = settings.BASE_DIR / "data"
settings.EMAIL_BACKEND = "django.core.mail.backends.dummy.EmailBackend" settings.EMAIL_BACKEND = "django.core.mail.backends.dummy.EmailBackend"
if not data_dir.is_dir(): if not data_dir.is_dir():
data_dir.mkdir() data_dir.mkdir()
db_path = Path(settings.BASE_DIR) / "db.sqlite3" db_path = settings.BASE_DIR / "db.sqlite3"
if db_path.exists(): if db_path.exists():
call_command("flush", "--noinput") call_command("flush", "--noinput")
self.stdout.write("Existing database reset") self.stdout.write("Existing database reset")

View File

@ -14,7 +14,6 @@
# #
# This file contains all the views that concern the page model # This file contains all the views that concern the page model
import os
from wsgiref.util import FileWrapper from wsgiref.util import FileWrapper
from ajax_select import make_ajax_field from ajax_select import make_ajax_field

View File

@ -34,8 +34,6 @@ https://docs.djangoproject.com/en/1.8/ref/settings/
""" """
import binascii import binascii
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os import os
import sys import sys
from pathlib import Path from pathlib import Path
@ -46,7 +44,7 @@ from sentry_sdk.integrations.django import DjangoIntegration
from .honeypot import custom_honeypot_error from .honeypot import custom_honeypot_error
BASE_DIR = Path(__file__).parent.parent BASE_DIR = Path(__file__).parent.parent.resolve()
os.environ["HTTPS"] = "off" os.environ["HTTPS"] = "off"