Small codestyle fixes

This commit is contained in:
Andrew Smirnov 2021-02-25 20:31:35 +03:00
parent 8ac6b10af2
commit 7bb3bf79f1
No known key found for this signature in database
GPG Key ID: 0EFE318E5BB2A82A
2 changed files with 45 additions and 28 deletions

View File

@ -120,18 +120,19 @@ class ZendeskAdmin:
return user
def make_engineer(user_profile):
def update_role(user_profile, role):
zendesk = ZendeskAdmin()
user = zendesk.get_user(user_profile.user.email)
user.custom_role_id = ROLES['engineer']
user.custom_role_id = role
zendesk.admin.users.update(user)
def make_engineer(user_profile):
update_role(user_profile, ROLES['engineer'])
def make_light_agent(user_profile):
zendesk = ZendeskAdmin()
user = zendesk.get_user(user_profile.user.email)
user.custom_role_id = ROLES['light_agent']
zendesk.admin.users.update(user)
update_role(user_profile, ROLES['light_agent'])
def get_users_list():
@ -143,10 +144,10 @@ def get_users_list():
def update_profile(user_profile: UserProfile):
"""
Функция обновляет профиль пользователя в соотвтетствии с текущим в Zendesk
Функция обновляет профиль пользователя в соотвтетствии с текущим в Zendesk
:param user_profile: Объект профиля пользователя
:type user_profile: :class:`main.models.UserProfile`
:param user_profile: Объект профиля пользователя
:type user_profile: :class:`main.models.UserProfile`
"""
user = ZendeskAdmin().get_user(user_profile.user.email)
user_profile.name = user.name
@ -167,7 +168,7 @@ def check_user_exist(email: str) -> bool:
return ZendeskAdmin().check_user(email)
def get_user_organization(email: str) -> bool:
def get_user_organization(email: str) -> str:
"""
Функция возвращает организацию пользователя

View File

@ -17,43 +17,53 @@
{% block content %}
<div class="container-md">
<div class="new-section">
<p class="row page-description">Основаная информация о странице</p>
<p class="row page-description">Основная информация о странице</p>
</div>
<form method="post">
{% csrf_token %}
<div class="row justify-content-center new-section">
<div style="display: none">
{% for field in form.users %}
{{ field.tag }}
{% endfor %}
</div>
<div class="col-10">
<h6 class="table-title">Список сотрудников</h6>
<table class="light-table">
<thead>
<th>ID</th>
<th>Email</th>
<th>Role</th>
<th>Name(link to profile)</th>
<th>Checked</th>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.id }}</td>
<td>{{ user.user.email }}</td>
<td>{{ user.role }}</td>
<td><a href="#">{{ user.name }}</a></td>
<td class="checkbox_field"></td>
</tr>
{% endfor %}
</tbody>
<th>ID</th>
<th>Email</th>
<th>Role</th>
<th>Name(link to profile)</th>
<th>Checked</th>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.id }}</td>
<td>{{ user.user.email }}</td>
<td>{{ user.role }}</td>
<td><a href="#">{{ user.name }}</a></td>
<td class="checkbox_field"></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="row justify-content-center new-section">
<div class="col-5">
<div class="info">
<div class="info-row">
<div class="info-target">Инженеров:</div>
<div class="info-quantity">
@ -61,6 +71,7 @@
<span class="info-quantity-value">{{ engineers }}</span>
</div>
</div>
<div class="info-row">
<div class="info-target">Легких агентов:</div>
<div class="info-quantity">
@ -68,15 +79,20 @@
<span class="info-quantity-value">{{ light_agents }}</span>
</div>
</div>
</div>
</div>
<div class="col-5">
<button type="submit" name="engineer" class="request-acess-button default-button">
Назначить выбранных на роль инженера
</button>
<button type="submit" name="light_agent" class="hand-over-acess-button default-button">
Назначить выбранных на роль легкого агента
</button>
</div>
</div>
</form>