From 9fd58afab9ea2969cb1008e038561cc0ac6c6c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=A1=D0=BE?= =?UTF-8?q?=D1=81=D0=BE=D0=B2=7E?= Date: Thu, 7 Dec 2023 21:28:32 +0300 Subject: [PATCH] add registration --- .../adaptive_hockey_federation/settings.py | 21 ++++-- .../adaptive_hockey_federation/urls.py | 1 + adaptive_hockey_federation/core/apps.py | 6 ++ .../migrations/__init__.py} | 0 .../templatetags/__init__.py} | 0 .../core/templatetags/user_filters.py | 8 +++ adaptive_hockey_federation/core/views.py | 9 +++ adaptive_hockey_federation/main/urls.py | 1 + adaptive_hockey_federation/main/views.py | 5 +- .../templates/base.html | 8 +-- .../templates/core/403.html | 5 ++ .../templates/core/403csrf.html | 4 ++ .../templates/core/404.html | 7 ++ .../templates/includes/forms_errors.html | 14 ++++ .../templates/includes/header.html | 39 +++++++---- .../templates/main/main.html | 7 ++ .../registration/includes/close_divs.html | 4 ++ .../registration/includes/fields_form.html | 17 +++++ .../registration/includes/open_divs.html | 4 ++ .../registration/password_change_done.html | 12 ++++ .../registration/password_change_form.html | 29 ++++++++ .../registration/password_reset_complete.html | 23 +++++++ .../registration/password_reset_confirm.html | 36 ++++++++++ .../registration/password_reset_done.html | 12 ++++ .../registration/password_reset_form.html | 29 ++++++++ .../templates/users/includes/close_divs.html | 4 ++ .../templates/users/includes/fields_form.html | 15 +++++ .../users/includes/hello_auth_user.html | 12 ++++ .../templates/users/includes/open_divs.html | 4 ++ .../templates/users/logged_out.html | 21 ++++++ .../templates/users/login.html | 41 ++++++++++++ .../templates/users/profile_site.html | 13 ++++ .../templates/users/signup.html | 23 +++++++ adaptive_hockey_federation/users/forms.py | 8 +++ adaptive_hockey_federation/users/urls.py | 67 ++++++++++++++++--- adaptive_hockey_federation/users/views.py | 21 +++++- 36 files changed, 495 insertions(+), 35 deletions(-) create mode 100644 adaptive_hockey_federation/core/apps.py rename adaptive_hockey_federation/{templates/users/loggin.html => core/migrations/__init__.py} (100%) rename adaptive_hockey_federation/{templates/users/password_reset.html => core/templatetags/__init__.py} (100%) create mode 100644 adaptive_hockey_federation/core/templatetags/user_filters.py create mode 100644 adaptive_hockey_federation/core/views.py create mode 100644 adaptive_hockey_federation/templates/core/403.html create mode 100644 adaptive_hockey_federation/templates/core/403csrf.html create mode 100644 adaptive_hockey_federation/templates/core/404.html create mode 100644 adaptive_hockey_federation/templates/includes/forms_errors.html create mode 100644 adaptive_hockey_federation/templates/main/main.html create mode 100644 adaptive_hockey_federation/templates/registration/includes/close_divs.html create mode 100644 adaptive_hockey_federation/templates/registration/includes/fields_form.html create mode 100644 adaptive_hockey_federation/templates/registration/includes/open_divs.html create mode 100644 adaptive_hockey_federation/templates/registration/password_change_done.html create mode 100644 adaptive_hockey_federation/templates/registration/password_change_form.html create mode 100644 adaptive_hockey_federation/templates/registration/password_reset_complete.html create mode 100644 adaptive_hockey_federation/templates/registration/password_reset_confirm.html create mode 100644 adaptive_hockey_federation/templates/registration/password_reset_done.html create mode 100644 adaptive_hockey_federation/templates/registration/password_reset_form.html create mode 100644 adaptive_hockey_federation/templates/users/includes/close_divs.html create mode 100644 adaptive_hockey_federation/templates/users/includes/fields_form.html create mode 100644 adaptive_hockey_federation/templates/users/includes/hello_auth_user.html create mode 100644 adaptive_hockey_federation/templates/users/includes/open_divs.html create mode 100644 adaptive_hockey_federation/templates/users/login.html create mode 100644 adaptive_hockey_federation/templates/users/profile_site.html create mode 100644 adaptive_hockey_federation/templates/users/signup.html create mode 100644 adaptive_hockey_federation/users/forms.py 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 @@
-