Small code style improvements

This commit is contained in:
Andrew Smirnov 2021-02-11 20:15:46 +03:00
parent c3f9e6626b
commit ac99a23a3b
No known key found for this signature in database
GPG Key ID: 0EFE318E5BB2A82A
3 changed files with 16 additions and 20 deletions

View File

@ -32,7 +32,4 @@ urlpatterns = [
path('accounts/', include('django.contrib.auth.urls'))
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@ -7,7 +7,7 @@ from main.models import UserProfile
# Дополнительные функции
def set_and_get_name(UP: UserProfile):
def set_and_get_name(user_profile: UserProfile):
"""
Функция устанавливает поле :class:`username` текущим именем в Zendesk
@ -19,10 +19,10 @@ def set_and_get_name(UP: UserProfile):
:return: Имя пользователя
:rtype: :class:`str`
"""
return UP.user.username
return user_profile.user.username
def set_and_get_email(UP: UserProfile): # TODO: Переделать с получением данных через API
def set_and_get_email(user_profile: UserProfile): # TODO: Переделать с получением данных через API
"""
Функция устанавливает поле :class:`user.email` текущей почтой в Zendesk
@ -31,10 +31,10 @@ def set_and_get_email(UP: UserProfile): # TODO: Переделать с пол
:return: Почта пользователя
:rtype: :class:`str`
"""
return UP.user.email
return user_profile.user.email
def set_and_get_role(UP: UserProfile): # TODO: Переделать с получением данных через API
def set_and_get_role(user_profile: UserProfile): # TODO: Переделать с получением данных через API
"""
Функция устанавливает поле :class:`role` текущей ролью в Zendesk
@ -43,10 +43,10 @@ def set_and_get_role(UP: UserProfile): # TODO: Переделать с полу
:return: Роль пользователя
:rtype: :class:`str`
"""
return UP.role
return user_profile.role
def load_and_get_image(UP: UserProfile): # TODO: Переделать с получением изображения через API
def load_and_get_image(user_profile: UserProfile): # TODO: Переделать с получением изображения через API
"""
Функция загружает и устанавливает изображение в поле :class:`image`
@ -55,7 +55,7 @@ def load_and_get_image(UP: UserProfile): # TODO: Переделать с пол
:return: Название изображения
:rtype: :class:`str`
"""
return UP.image.name
return user_profile.image.name
def check_user_exist(email: str) -> bool:

View File

@ -1,7 +1,6 @@
from django.shortcuts import render
from django.urls import reverse_lazy
from main.extra_func import set_and_get_name, set_and_get_email, load_and_get_image, set_and_get_role, check_user_exist, \
check_user_auth
from main.models import UserProfile
@ -44,9 +43,9 @@ class CustomRegistrationView(RegistrationView):
else:
self.is_allowed = False
def get_success_url(self, request):
def get_success_url(self, user=None):
"""
Вовзращет url-адресс страницы, куда нужно перейти после успешной/неуспешной регистрации
Возвращает url-адрес страницы, куда нужно перейти после успешной/неуспешной регистрации
Используется самой django-registration
"""
if self.is_allowed:
@ -54,6 +53,7 @@ class CustomRegistrationView(RegistrationView):
else:
return reverse_lazy('django_registration_disallowed')
@login_required()
def profile_page(request):
"""
@ -81,4 +81,3 @@ def profile_page(request):
def main_page(request):
return render(request, 'pages/index.html')