Added engineers and light_agents count from organization to control page

This commit is contained in:
Кулаков Юрий 2021-02-25 21:57:04 +03:00
parent a12476ff70
commit 8df2b66b7a
4 changed files with 12 additions and 19 deletions

View File

@ -134,8 +134,8 @@ def make_light_agent(user_profile):
def get_users_list():
zendesk = ZendeskAdmin()
admin = zendesk.get_user(zendesk.email)
group = next(zendesk.admin.users.groups(user=admin)) # TODO: user can be in many groups
return zendesk.admin.groups.users(group) # TODO: add role parameter
org = next(zendesk.admin.users.organizations(user=admin))
return zendesk.admin.organizations.users(org)
def update_profile(user_profile: UserProfile):

View File

@ -2,13 +2,9 @@
{% load static %}
{% block title %}
Управление
{%endblock %}
{% block title %}Управление{%endblock %}
{% block heading %}
Управление
{% endblock %}
{% block heading %}Управление{% endblock %}
{% block extra_css %}
<link rel="stylesheet" href="{% static 'main/css/work.css' %}"/>

View File

@ -1,10 +1,9 @@
{% extends 'base/base.html' %}
{% block title %}
Авторизация
{% endblock %}
{% block heading %}
Авторизация
{% endblock %}
{% block title %}Авторизация{% endblock %}
{% block heading %}Авторизация{% endblock %}
{% block content %}
<div class="container">
<div class="card mx-auto" style="width: 40rem">

View File

@ -114,13 +114,11 @@ class AdminPageView(FormView, LoginRequiredMixin):
@staticmethod
def make_engineers(users):
for user in users:
make_engineer(user)
[make_engineer(user) for user in users]
@staticmethod
def make_light_agents(users):
for user in users:
make_light_agent(user)
[make_light_agent(user) for user in users]
@staticmethod
def count_users(users): # TODO: this func counts users from all zendesk instead of just from a model
@ -132,7 +130,7 @@ class AdminPageView(FormView, LoginRequiredMixin):
light_agents += 1
return engineers, light_agents
def get_context_data(self, **kwargs): # TODO: add engineers and agents count
def get_context_data(self, **kwargs):
if self.request.user.userprofile.role != 'admin':
raise PermissionDenied
context = super().get_context_data(**kwargs)