Merge branch 'hotfix/role_view' into 'develop'

Hotfix/role view

See merge request 2020-2021/online/s101/group-02/access_controller!43
This commit is contained in:
Кравченко Артем 2021-03-29 21:58:39 +00:00
commit 4dd48a5e4b
6 changed files with 51 additions and 15 deletions

View File

@ -150,6 +150,8 @@ def update_role(user_profile: UserProfile, role: str) -> UserProfile:
zendesk = ZendeskAdmin()
user = zendesk.get_user(user_profile.user.email)
user.custom_role_id = role
user_profile.custom_role_id = role
user_profile.save()
zendesk.admin.users.update(user)

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.6 on 2021-03-29 21:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0014_auto_20210314_1455'),
]
operations = [
migrations.AlterField(
model_name='unassignedticket',
name='status',
field=models.IntegerField(choices=[(0, 'Снят с пользователя, перенесён в буферную группу'), (1, 'Авторство восстановлено'), (2, 'Пока нас не было, тикет испарился из буферной группы. Дополнительные действия не требуются'), (3, 'Тикет уже был закрыт. Дополнительные действия не требуются'), (4, 'Тикет решён. Записан на пользователя с почтой SOLVED_TICKETS_EMAIL')], default=0),
),
]

View File

@ -0,0 +1,14 @@
# Generated by Django 3.1.6 on 2021-03-29 21:43
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0015_auto_20210330_0007'),
('main', '0015_auto_20210321_1600'),
]
operations = [
]

View File

@ -56,7 +56,12 @@
<tr>
<td><a href="#">{{ user.name }}</a></td>
<td>{{ user.user.email }}</td>
<td>{{ user.role }}</td>
<td>{% if user.custom_role_id == ZENDESK_ROLES.engineer %}
engineer
{% elif user.custom_role_id == ZENDESK_ROLES.light_agent %}
light_agent
{% endif %}
</td>
<td class="checkbox_field"></td>
</tr>
{% endfor %}

View File

@ -37,7 +37,13 @@
<br>
<h5><span class="badge bg-secondary text-light">Электронная почта</span> {{ profile.user.email }}</h5>
<br>
<h5><span class="badge bg-secondary text-light">Текущая роль</span> {{ profile.role }}</h5>
<h5><span class="badge bg-secondary text-light">Текущая роль</span>
{% if profile.custom_role_id == ZENDESK_ROLES.engineer %}
engineer
{% elif profile.custom_role_id == ZENDESK_ROLES.light_agent %}
light_agent
{% endif %}
</h5>
</div>
</div>
<div align="center">

View File

@ -133,7 +133,8 @@ def profile_page(request: WSGIRequest) -> HttpResponse:
update_profile(user_profile)
context = {
'profile': user_profile,
'pagename': 'Страница профиля'
'pagename': 'Страница профиля',
'ZENDESK_ROLES': ZENDESK_ROLES,
}
return render(request, 'pages/profile.html', context)
@ -228,18 +229,7 @@ def work_become_engineer(request: WSGIRequest) -> HttpResponseRedirect:
return HttpResponseRedirect(reverse('work', args=(request.user.id,)))
def main_page(request: WSGIRequest) -> HttpResponse:
"""
Функция отображения логгирования на главной странице.
.. todo::
Дописать параметры в документацию:
:param request:
:return:
"""
logger = logging.getLogger('main.index')
logger.info('Index page opened')
def main_page(request):
return render(request, 'pages/index.html')
@ -298,6 +288,7 @@ class AdminPageView(LoginRequiredMixin, PermissionRequiredMixin,SuccessMessageMi
users = get_list_or_404(
UserProfile, role='agent')
context['users'] = users
context['ZENDESK_ROLES'] = ZENDESK_ROLES
context['engineers'], context['light_agents'] = count_users(get_users_list())
context['licences_remaining'] = max(0, ZENDESK_MAX_AGENTS - context['engineers'])
return context # TODO: need to get profile page url