diff --git a/adaptive_hockey_federation/adaptive_hockey_federation/settings.py b/adaptive_hockey_federation/adaptive_hockey_federation/settings.py index 4f0e2000..9d919580 100644 --- a/adaptive_hockey_federation/adaptive_hockey_federation/settings.py +++ b/adaptive_hockey_federation/adaptive_hockey_federation/settings.py @@ -1,9 +1,11 @@ import os -from pathlib import Path -BASE_DIR = Path(__file__).resolve().parent.parent +from django.core.management.utils import get_random_secret_key + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +SECRET_KEY = get_random_secret_key() -SECRET_KEY = 'django-insecure-))v)^p&_y!_-dsc7p)v%b@yi+#)k^34mp^ai8jc^9v)jpu2xn1' DEBUG = True ALLOWED_HOSTS: list = ['*'] @@ -18,6 +20,7 @@ 'django.contrib.staticfiles', 'main.apps.MainConfig', 'users.apps.UsersConfig', + 'core.apps.CoreConfig', ] MIDDLEWARE = [ @@ -54,7 +57,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } @@ -82,11 +85,19 @@ USE_TZ = True STATIC_URL = '/static/' + STATIC_ROOT = os.path.join(BASE_DIR, 'static') -# STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] + +LOGIN_REDIRECT_URL = 'main:main' + +EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend' + +EMAIL_FILE_PATH = os.path.join(BASE_DIR, 'sent_emails') MEDIA_URL = '/media/' + MEDIA_ROOT = os.path.join(BASE_DIR, 'media') DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + AUTH_USER_MODEL = 'users.User' diff --git a/adaptive_hockey_federation/adaptive_hockey_federation/urls.py b/adaptive_hockey_federation/adaptive_hockey_federation/urls.py index 2051bcc6..044819e3 100644 --- a/adaptive_hockey_federation/adaptive_hockey_federation/urls.py +++ b/adaptive_hockey_federation/adaptive_hockey_federation/urls.py @@ -5,4 +5,5 @@ path('admin/', admin.site.urls), path('', include('main.urls', namespace='main')), path('auth/', include('users.urls', namespace='users')), + path('auth/', include('django.contrib.auth.urls')), ] diff --git a/adaptive_hockey_federation/core/apps.py b/adaptive_hockey_federation/core/apps.py new file mode 100644 index 00000000..8115ae60 --- /dev/null +++ b/adaptive_hockey_federation/core/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class CoreConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'core' diff --git a/adaptive_hockey_federation/templates/users/loggin.html b/adaptive_hockey_federation/core/migrations/__init__.py similarity index 100% rename from adaptive_hockey_federation/templates/users/loggin.html rename to adaptive_hockey_federation/core/migrations/__init__.py diff --git a/adaptive_hockey_federation/templates/users/password_reset.html b/adaptive_hockey_federation/core/templatetags/__init__.py similarity index 100% rename from adaptive_hockey_federation/templates/users/password_reset.html rename to adaptive_hockey_federation/core/templatetags/__init__.py diff --git a/adaptive_hockey_federation/core/templatetags/user_filters.py b/adaptive_hockey_federation/core/templatetags/user_filters.py new file mode 100644 index 00000000..18a84286 --- /dev/null +++ b/adaptive_hockey_federation/core/templatetags/user_filters.py @@ -0,0 +1,8 @@ +from django import template + +register = template.Library() + + +@register.filter +def addclass(field, css): + return field.as_widget(attrs={'class': css}) diff --git a/adaptive_hockey_federation/core/views.py b/adaptive_hockey_federation/core/views.py new file mode 100644 index 00000000..3872e577 --- /dev/null +++ b/adaptive_hockey_federation/core/views.py @@ -0,0 +1,9 @@ +from django.shortcuts import render + + +def page_not_found(request, exception): + return render(request, 'core/404.html', {'path': request.path}, status=404) + + +def csrf_failure(request, reason=''): + return render(request, 'core/403csrf.html') diff --git a/adaptive_hockey_federation/main/urls.py b/adaptive_hockey_federation/main/urls.py index 2b42c518..46a13d93 100644 --- a/adaptive_hockey_federation/main/urls.py +++ b/adaptive_hockey_federation/main/urls.py @@ -6,6 +6,7 @@ urlpatterns = [ + path('', views.main, name='main'), path('users/', views.users, name='users'), path('teams//', views.teams_id, name='teams_id'), path('teams/', views.teams, name='teams'), diff --git a/adaptive_hockey_federation/main/views.py b/adaptive_hockey_federation/main/views.py index 492bd566..d5a23eed 100644 --- a/adaptive_hockey_federation/main/views.py +++ b/adaptive_hockey_federation/main/views.py @@ -1,6 +1,5 @@ from django.shortcuts import render - # пример рендера таблиц, удалить после реализации вьюх CONTEXT_EXAMPLE = { 'table_head': { @@ -15,6 +14,10 @@ } +def main(request): + return render(request, 'main/main.html') + + def users(request): return render(request, 'main/users.html') diff --git a/adaptive_hockey_federation/templates/base.html b/adaptive_hockey_federation/templates/base.html index 15790f06..87b16ec0 100644 --- a/adaptive_hockey_federation/templates/base.html +++ b/adaptive_hockey_federation/templates/base.html @@ -43,14 +43,14 @@
-