From 2a2a47e2a7f21c400904f2075ab5d6180d715269 Mon Sep 17 00:00:00 2001 From: SDE Date: Tue, 11 Jul 2023 12:40:33 +0300 Subject: [PATCH] 0.0.12 profile routines --- AuthApp/admin.py | 1 + AuthApp/js_views.py | 2 +- AuthApp/migrations/0003_userprofile_avatar.py | 18 ++++++++++++++++++ .../0004_alter_userprofile_account_type.py | 18 ++++++++++++++++++ AuthApp/models.py | 8 +++++--- AuthApp/urls.py | 3 ++- AuthApp/views.py | 11 +++++++++-- TWB/urls.py | 2 +- sets/admin.py | 2 +- templates/blocks/b_header.html | 4 ++-- templates/blocks/b_user_profile.html | 15 ++++++++------- templates/pages/profile/p_login.html | 16 ++++++++++++++++ .../pages/{ => profile}/p_registration.html | 0 .../pages/{ => profile}/p_user_profile.html | 0 14 files changed, 82 insertions(+), 18 deletions(-) create mode 100644 AuthApp/migrations/0003_userprofile_avatar.py create mode 100644 AuthApp/migrations/0004_alter_userprofile_account_type.py create mode 100644 templates/pages/profile/p_login.html rename templates/pages/{ => profile}/p_registration.html (100%) rename templates/pages/{ => profile}/p_user_profile.html (100%) diff --git a/AuthApp/admin.py b/AuthApp/admin.py index b4c6131..7589aae 100644 --- a/AuthApp/admin.py +++ b/AuthApp/admin.py @@ -39,6 +39,7 @@ class Admin_ProfileInline(admin.StackedInline): (None, { 'classes': ['wide'], 'fields': ( + ('account_type',), ('enable',), ('phone',), ('country', 'city'), diff --git a/AuthApp/js_views.py b/AuthApp/js_views.py index 63041b2..3bc19ef 100644 --- a/AuthApp/js_views.py +++ b/AuthApp/js_views.py @@ -33,7 +33,7 @@ def registration_ajax(request): res_Dict = {} - JsonResponse(res_Dict) + return JsonResponse(res_Dict) except Exception as e: diff --git a/AuthApp/migrations/0003_userprofile_avatar.py b/AuthApp/migrations/0003_userprofile_avatar.py new file mode 100644 index 0000000..a22e755 --- /dev/null +++ b/AuthApp/migrations/0003_userprofile_avatar.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.2 on 2023-07-11 12:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('AuthApp', '0002_alter_userprofile_city'), + ] + + operations = [ + migrations.AddField( + model_name='userprofile', + name='avatar', + field=models.ImageField(blank=True, null=True, upload_to='uploads/', verbose_name='Аватар'), + ), + ] diff --git a/AuthApp/migrations/0004_alter_userprofile_account_type.py b/AuthApp/migrations/0004_alter_userprofile_account_type.py new file mode 100644 index 0000000..a28558e --- /dev/null +++ b/AuthApp/migrations/0004_alter_userprofile_account_type.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.2 on 2023-07-11 12:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('AuthApp', '0003_userprofile_avatar'), + ] + + operations = [ + migrations.AlterField( + model_name='userprofile', + name='account_type', + field=models.CharField(choices=[('mover', 'Перевозчик'), ('sender', 'Отправитель')], default='sender', max_length=250, verbose_name='Тип учетной записи'), + ), + ] diff --git a/AuthApp/models.py b/AuthApp/models.py index b2e2278..67b4e1e 100644 --- a/AuthApp/models.py +++ b/AuthApp/models.py @@ -18,19 +18,21 @@ User.add_to_class("__str__", user_name_str) account_type_choices = ( - (_('Перевозчик'), 'mover'), - (_('Отправитель'), 'sender') + ('mover', _('Перевозчик')), + ('sender', _('Отправитель')) ) class UserProfile(BaseModel): account_type = models.CharField( - max_length=250, verbose_name=_('Тип учетной записи'), choices=account_type_choices, default='base_account') + max_length=250, verbose_name=_('Тип учетной записи'), choices=account_type_choices, default='sender') user = models.OneToOneField(User, verbose_name=_('Пользователь'), related_name=u'user_profile', null=True, blank=True, on_delete=models.CASCADE) + avatar = models.ImageField(upload_to='uploads/', verbose_name=_('Аватар'), null=True, blank=True) + authMailCode = models.CharField(max_length=32, null=True, blank=True) phone = models.CharField(max_length=100, verbose_name=_('Телефон'), null=True, blank=True) diff --git a/AuthApp/urls.py b/AuthApp/urls.py index fd11a63..04b6056 100644 --- a/AuthApp/urls.py +++ b/AuthApp/urls.py @@ -8,7 +8,8 @@ from django.contrib.auth import views urlpatterns = [ path('registration/', registration_View, name='registration_page'), - path('profile/', user_profile_View, name='user_profile'), + path('', user_profile_View, name='user_profile'), + path('login/', login_View, name='login_profile'), # ajax ---------------- # url(r'^login$', user_login_View_ajax, name='user_login_View_ajax'), diff --git a/AuthApp/views.py b/AuthApp/views.py index 597095f..a965b91 100644 --- a/AuthApp/views.py +++ b/AuthApp/views.py @@ -11,25 +11,32 @@ from django.contrib.auth.decorators import login_required from BaseModels.mailSender import techSendMail from django.utils.translation import gettext as _ from datetime import datetime +from django.contrib.auth.decorators import login_required def registration_View(request): Dict = {} - t = loader.get_template('pages/p_registration.html') + t = loader.get_template('pages/profile/p_registration.html') return HttpResponse(t.render(Dict, request)) +login_required(login_url='/login/') def user_profile_View(request): Dict = {} - t = loader.get_template('pages/p_user_profile.html') + t = loader.get_template('pages/profile/p_user_profile.html') return HttpResponse(t.render(Dict, request)) +def login_View(request): + Dict = {} + + t = loader.get_template('pages/profile/p_login.html') + return HttpResponse(t.render(Dict, request)) diff --git a/TWB/urls.py b/TWB/urls.py index 8dd021f..1730d1c 100644 --- a/TWB/urls.py +++ b/TWB/urls.py @@ -17,7 +17,7 @@ urlpatterns += i18n_patterns( path('admin/', admin.site.urls), path('', include('GeneralApp.urls')), - path('', include('AuthApp.urls')), + path('profile/', include('AuthApp.urls')), path('user_account/', include('AuthApp.js_urls')), ) diff --git a/sets/admin.py b/sets/admin.py index 0a935c6..f0521c5 100644 --- a/sets/admin.py +++ b/sets/admin.py @@ -56,7 +56,7 @@ class Admin_BaseModelViewPage(Admin_BaseIconModel): 'seo_text' ) }) - fieldsets[0][1]['fields'].append('url') + # fieldsets[0][1]['fields'].append('url') fieldsets.append(seo_block) return fieldsets diff --git a/templates/blocks/b_header.html b/templates/blocks/b_header.html index 662f3e9..0c2c07a 100644 --- a/templates/blocks/b_header.html +++ b/templates/blocks/b_header.html @@ -25,7 +25,7 @@
Служба поддержки
- Регистрация - Войти + Регистрация + Войти \ No newline at end of file diff --git a/templates/blocks/b_user_profile.html b/templates/blocks/b_user_profile.html index 6725593..f67bfd4 100644 --- a/templates/blocks/b_user_profile.html +++ b/templates/blocks/b_user_profile.html @@ -32,14 +32,15 @@ Мой профиль
-

Добро пожаловать: Иван (ivanship)

-
+

Добро пожаловать: {{ user.first_name }} {{ user.last_name }} ({{ user.username }})

+
-
Статус:
-
+
Статус: {{ user.user_profile.get_account_type_display }}
+{#
#} +{#
#}
Если хотите отправить посылку - зарегистрируйтесь, как отправитель
diff --git a/templates/pages/profile/p_login.html b/templates/pages/profile/p_login.html new file mode 100644 index 0000000..b2a0542 --- /dev/null +++ b/templates/pages/profile/p_login.html @@ -0,0 +1,16 @@ + + + + + Title + {% include 'inter/meta.html' %} + + +
+ {% include 'blocks/b_header.html' %} + {% include 'blocks/b_login.html' %} + {% include 'blocks/b_footer.html' %} + +
+ + \ No newline at end of file diff --git a/templates/pages/p_registration.html b/templates/pages/profile/p_registration.html similarity index 100% rename from templates/pages/p_registration.html rename to templates/pages/profile/p_registration.html diff --git a/templates/pages/p_user_profile.html b/templates/pages/profile/p_user_profile.html similarity index 100% rename from templates/pages/p_user_profile.html rename to templates/pages/profile/p_user_profile.html