Added highlight for login/register buttons a.k.a. finished the task
This commit is contained in:
parent
2e6db096d6
commit
7604c88777
26
main/migrations/0017_auto_20210408_1943.py
Normal file
26
main/migrations/0017_auto_20210408_1943.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Generated by Django 3.1.7 on 2021-04-08 16:43
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('main', '0016_merge_20210330_0043'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='unassignedticket',
|
||||
name='assignee',
|
||||
field=models.ForeignKey(help_text='Пользователь, с которого снят тикет', on_delete=django.db.models.deletion.CASCADE, related_name='tickets', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='unassignedticket',
|
||||
name='status',
|
||||
field=models.IntegerField(choices=[(0, 'Снят с пользователя, перенесён в буферную группу'), (1, 'Авторство восстановлено'), (2, 'Пока нас не было, тикет испарился из буферной группы. Дополнительные действия не требуются'), (3, 'Тикет уже был закрыт. Дополнительные действия не требуются'), (4, 'Тикет решён. Записан на пользователя с почтой SOLVED_TICKETS_EMAIL')], default=0, help_text='Статус тикета'),
|
||||
),
|
||||
]
|
@ -35,8 +35,18 @@
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="btn-group" role="group" aria-label="Basic example" style="margin-right: 9px">
|
||||
<a class="btn btn-secondary" href="/accounts/login">Войти</a>
|
||||
<a class="btn btn-secondary" href="/accounts/register">Зарегистрироваться</a>
|
||||
<a {% if login_lit %}
|
||||
class="btn btn-primary"
|
||||
{% else %}
|
||||
class="btn btn-secondary"
|
||||
{% endif %}
|
||||
href="/accounts/login">Войти</a>
|
||||
<a {% if registration_lit %}
|
||||
class="btn btn-primary"
|
||||
{% else %}
|
||||
class="btn btn-secondary"
|
||||
{% endif %}
|
||||
href="/accounts/register">Зарегистрироваться</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</nav>
|
||||
|
@ -35,6 +35,19 @@ from main.serializers import ProfileSerializer
|
||||
from .models import UserProfile
|
||||
|
||||
|
||||
def setup_context(profile_lit: bool = False, control_lit: bool = False, work_lit: bool = False,
|
||||
registration_lit: bool = False, login_lit: bool = False):
|
||||
print(profile_lit, control_lit, work_lit, registration_lit, login_lit)
|
||||
context = {
|
||||
'profile_lit': profile_lit,
|
||||
'control_lit': control_lit,
|
||||
'work_lit': work_lit,
|
||||
'registration_lit': registration_lit,
|
||||
'login_lit': login_lit,
|
||||
}
|
||||
return context
|
||||
|
||||
|
||||
class CustomRegistrationView(RegistrationView):
|
||||
"""
|
||||
Отображение и логика работы страницы регистрации пользователя.
|
||||
@ -48,6 +61,7 @@ class CustomRegistrationView(RegistrationView):
|
||||
:param is_allowed: Определение зарегистрирован ли пользователь с введенным email на Zendesk и принадлежит ли он к организации SYSTEM
|
||||
:type is_allowed: :class:`bool`
|
||||
"""
|
||||
extra_context = setup_context(registration_lit=True)
|
||||
form_class = CustomRegistrationForm
|
||||
template_name = 'django_registration/registration_form.html'
|
||||
success_url = reverse_lazy('django_registration_complete')
|
||||
@ -121,15 +135,6 @@ class CustomRegistrationView(RegistrationView):
|
||||
return reverse_lazy('django_registration_disallowed')
|
||||
|
||||
|
||||
def setup_context(profile_lit: bool = False, control_lit: bool = False, work_lit: bool = False):
|
||||
context = {
|
||||
'profile_lit': profile_lit,
|
||||
'control_lit': control_lit,
|
||||
'work_lit': work_lit,
|
||||
}
|
||||
return context
|
||||
|
||||
|
||||
@login_required()
|
||||
def profile_page(request: WSGIRequest) -> HttpResponse:
|
||||
"""
|
||||
@ -313,6 +318,7 @@ class CustomLoginView(LoginView):
|
||||
"""
|
||||
Отображение страницы авторизации пользователя
|
||||
"""
|
||||
extra_context = setup_context(login_lit=True)
|
||||
form_class = CustomAuthenticationForm
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user