Small code style improvements
This commit is contained in:
parent
c3f9e6626b
commit
ac99a23a3b
@ -32,7 +32,4 @@ urlpatterns = [
|
|||||||
path('accounts/', include('django.contrib.auth.urls'))
|
path('accounts/', include('django.contrib.auth.urls'))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
@ -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
|
Функция устанавливает поле :class:`username` текущим именем в Zendesk
|
||||||
|
|
||||||
@ -19,10 +19,10 @@ def set_and_get_name(UP: UserProfile):
|
|||||||
:return: Имя пользователя
|
:return: Имя пользователя
|
||||||
:rtype: :class:`str`
|
: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
|
Функция устанавливает поле :class:`user.email` текущей почтой в Zendesk
|
||||||
|
|
||||||
@ -31,10 +31,10 @@ def set_and_get_email(UP: UserProfile): # TODO: Переделать с пол
|
|||||||
:return: Почта пользователя
|
:return: Почта пользователя
|
||||||
:rtype: :class:`str`
|
: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
|
Функция устанавливает поле :class:`role` текущей ролью в Zendesk
|
||||||
|
|
||||||
@ -43,10 +43,10 @@ def set_and_get_role(UP: UserProfile): # TODO: Переделать с полу
|
|||||||
:return: Роль пользователя
|
:return: Роль пользователя
|
||||||
:rtype: :class:`str`
|
: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`
|
Функция загружает и устанавливает изображение в поле :class:`image`
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ def load_and_get_image(UP: UserProfile): # TODO: Переделать с пол
|
|||||||
:return: Название изображения
|
:return: Название изображения
|
||||||
:rtype: :class:`str`
|
:rtype: :class:`str`
|
||||||
"""
|
"""
|
||||||
return UP.image.name
|
return user_profile.image.name
|
||||||
|
|
||||||
|
|
||||||
def check_user_exist(email: str) -> bool:
|
def check_user_exist(email: str) -> bool:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.urls import reverse_lazy
|
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, \
|
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
|
check_user_auth
|
||||||
from main.models import UserProfile
|
from main.models import UserProfile
|
||||||
@ -44,9 +43,9 @@ class CustomRegistrationView(RegistrationView):
|
|||||||
else:
|
else:
|
||||||
self.is_allowed = False
|
self.is_allowed = False
|
||||||
|
|
||||||
def get_success_url(self, request):
|
def get_success_url(self, user=None):
|
||||||
"""
|
"""
|
||||||
Вовзращет url-адресс страницы, куда нужно перейти после успешной/неуспешной регистрации
|
Возвращает url-адрес страницы, куда нужно перейти после успешной/неуспешной регистрации
|
||||||
Используется самой django-registration
|
Используется самой django-registration
|
||||||
"""
|
"""
|
||||||
if self.is_allowed:
|
if self.is_allowed:
|
||||||
@ -54,6 +53,7 @@ class CustomRegistrationView(RegistrationView):
|
|||||||
else:
|
else:
|
||||||
return reverse_lazy('django_registration_disallowed')
|
return reverse_lazy('django_registration_disallowed')
|
||||||
|
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def profile_page(request):
|
def profile_page(request):
|
||||||
"""
|
"""
|
||||||
@ -81,4 +81,3 @@ def profile_page(request):
|
|||||||
|
|
||||||
def main_page(request):
|
def main_page(request):
|
||||||
return render(request, 'pages/index.html')
|
return render(request, 'pages/index.html')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user