Skip to content

Commit

Permalink
fix: django.conf.urls -> django.urls
Browse files Browse the repository at this point in the history
  • Loading branch information
camillemndn committed Jul 5, 2024
1 parent 76f9131 commit 2def663
Show file tree
Hide file tree
Showing 47 changed files with 739 additions and 484 deletions.
6 changes: 3 additions & 3 deletions back/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions back/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'radiogaga.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "radiogaga.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand All @@ -17,5 +17,5 @@ def main():
execute_from_command_line(sys.argv)


if __name__ == '__main__':
if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion back/radiogaga/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'radiogaga.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "radiogaga.settings")

application = get_asgi_application()
92 changes: 46 additions & 46 deletions back/radiogaga/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,78 +14,78 @@

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR_DEFAULT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.getenv('BASE_DIR', default=BASE_DIR_DEFAULT)
BASE_DIR = os.getenv("BASE_DIR", default=BASE_DIR_DEFAULT)

MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'o&rk#lnupad)ixm4q0xo!*foq%bae9))$+9_a+0hrgk8)sx15x'
SECRET_KEY = "o&rk#lnupad)ixm4q0xo!*foq%bae9))$+9_a+0hrgk8)sx15x"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ["*"]


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'drf_yasg',
'restapi',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"corsheaders",
"drf_yasg",
"restapi",
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = 'radiogaga.urls'
ROOT_URLCONF = "radiogaga.urls"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = 'radiogaga.wsgi.application'
WSGI_APPLICATION = "radiogaga.wsgi.application"


# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DB_DIR = os.path.join(BASE_DIR, 'db')
DB_DIR = os.path.join(BASE_DIR, "db")
if not os.path.exists(DB_DIR):
os.makedirs(DB_DIR)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(DB_DIR, 'db.sqlite3'),
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(DB_DIR, "db.sqlite3"),
}
}

Expand All @@ -95,26 +95,26 @@

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"

TIME_ZONE = 'Europe/Paris'
TIME_ZONE = "Europe/Paris"

USE_I18N = True

Expand All @@ -128,12 +128,12 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
STATIC_URL = "/static/"
STATIC_ROOT = "static"

REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 100
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
"PAGE_SIZE": 100,
}

# allow async context
Expand Down
32 changes: 18 additions & 14 deletions back/radiogaga/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf.urls import url

from django.urls import re_path as url
from django.contrib import admin
from django.urls import path, include
from django.views.generic import RedirectView
Expand All @@ -22,23 +23,26 @@
from rest_framework import permissions

schema_view = get_schema_view(
openapi.Info(
title="RadioGaGa",
default_version='v1',
description="RPI Clock Radio",
license=openapi.License(name="MIT License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
openapi.Info(
title="RadioGaGa",
default_version="v1",
description="RPI Clock Radio",
license=openapi.License(name="MIT License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
)


urlpatterns = [
# url(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
# url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
path('admin/', admin.site.urls),
url(r'^api-auth/', include('rest_framework.urls')),
url(r'^$', RedirectView.as_view(url='redoc/', permanent=True)), # Redirect / to the docs
url(r'^api/', include(('restapi.urls', 'api'), namespace='api')),
url(
r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"
),
path("admin/", admin.site.urls),
url(r"^api-auth/", include("rest_framework.urls")),
# Redirect / to the docs
url(r"^$", RedirectView.as_view(url="redoc/", permanent=True)),
url(r"^api/", include(("restapi.urls", "api"), namespace="api")),
]
2 changes: 1 addition & 1 deletion back/radiogaga/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'radiogaga.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "radiogaga.settings")

application = get_wsgi_application()
2 changes: 1 addition & 1 deletion back/restapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
default_app_config = 'restapi.apps.RestapiConfig'
default_app_config = "restapi.apps.RestapiConfig"
10 changes: 8 additions & 2 deletions back/restapi/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@


class RestapiConfig(AppConfig):
name = 'restapi'
name = "restapi"

def __init__(self, app_name, app_module):
super().__init__(app_name, app_module)

def ready(self):
argv = sys.argv
print(argv)
list_banned_argument = ["makemigrations", "migrate", "collectstatic", "dumpdata", "loaddata"]
list_banned_argument = [
"makemigrations",
"migrate",
"collectstatic",
"dumpdata",
"loaddata",
]
if not any(x in list_banned_argument for x in argv):
# start the scheduler
scheduler_manager = SchedulerManager()
Expand Down
Loading

0 comments on commit 2def663

Please sign in to comment.