Fix urls, update menu, codestyle improvements, add views in documentation

This commit is contained in:
Andrew Smirnov
2021-02-11 20:58:07 +03:00
parent ef36e8de40
commit 8c9b5a9cfa
5 changed files with 36 additions and 34 deletions

View File

@@ -4,24 +4,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<nav class="navbar navbar-light" style="background-color: #00FF00;">
<a class="navbar-brand" href="#">
<a class="navbar-brand" href="{% url 'index' %}">
<img src="{% static 'main/img/logo.png' %}" width="30" height="30" class="d-inline-block align-top" alt="" loading="lazy">
Access Controller
</a>
{% if request.user.is_authenticated %}
<div class="btn-group" role="group" aria-label="Basic example">
<a class="btn btn-secondary" href="/accounts/logout">Выйти</a>
<a class="btn btn-secondary" href="">Профиль</a>
</div>
<div class="btn-group" role="group" aria-label="Basic example">
<a class="btn btn-secondary" href="{% url 'profile' %}">Профиль</a>
<a class="btn btn-secondary" href="{% url 'logout' %}">Выйти</a>
</div>
{% else %}
<div class="btn-group" role="group" aria-label="Basic example">
<a class="btn btn-secondary" href="/accounts/login">Войти</a>
<a class="btn btn-secondary" href="/accounts/register">Зарегистрироваться</a>
</div>
<div class="btn-group" role="group" aria-label="Basic example">
<a class="btn btn-secondary" href="/accounts/login">Войти</a>
<a class="btn btn-secondary" href="/accounts/register">Зарегистрироваться</a>
</div>
{% endif %}
</nav>
</header>

View File

@@ -31,7 +31,6 @@ class CustomRegistrationView(RegistrationView):
password=form.data['password1']
)
profile = UserProfile(
image='None.png',
user=user,
role=0,
)
@@ -65,15 +64,13 @@ def profile_page(request):
:return: объект ответа сервера с HTML-кодом внутри
"""
if request.user.is_authenticated:
# UP = UserProfile.objects.get(user=request.user)
UP = UserProfile.objects.get(user=request.user)
# else: # TODO: Убрать после появления регистрации и авторизации, добавить login_required()
# UP = UserProfile.objects.get(user=1)
user_profile = request.user.userprofile
context = {
'name': set_and_get_name(UP),
'email': set_and_get_email(UP),
'role': set_and_get_role(UP),
'image_name': load_and_get_image(UP),
'name': set_and_get_name(user_profile),
'email': set_and_get_email(user_profile),
'role': set_and_get_role(user_profile),
'image_name': load_and_get_image(user_profile),
'pagename': 'Страница профиля'
}
return render(request, 'pages/profile.html', context)