Fixed bug with disappearance of table rows in control page at start
This commit is contained in:
parent
abe44fec5f
commit
c1a10b6f2c
@ -8,7 +8,7 @@ from main.models import UserProfile
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
|
||||
from access_controller.settings import ZENDESK_ROLES as ROLES, ZENDESK_ROLES
|
||||
from access_controller.settings import ZENDESK_ROLES
|
||||
|
||||
|
||||
class ZendeskAdmin:
|
||||
@ -132,14 +132,14 @@ def make_engineer(user_profile: UserProfile) -> UserProfile:
|
||||
"""
|
||||
Функция **make_engineer** устанавливапет пользователю роль инженера.
|
||||
"""
|
||||
update_role(user_profile, ROLES['engineer'])
|
||||
update_role(user_profile, ZENDESK_ROLES['engineer'])
|
||||
|
||||
|
||||
def make_light_agent(user_profile: UserProfile) -> UserProfile:
|
||||
"""
|
||||
Функция **make_light_agent** устанавливапет пользователю роль легкого агента.
|
||||
"""
|
||||
update_role(user_profile, ROLES['light_agent'])
|
||||
update_role(user_profile, ZENDESK_ROLES['light_agent'])
|
||||
|
||||
|
||||
def get_users_list() -> list:
|
||||
@ -150,7 +150,8 @@ def get_users_list() -> list:
|
||||
|
||||
# У пользователей должна быть организация SYSTEM
|
||||
org = next(zendesk.admin.search(type='organization', name='SYSTEM'))
|
||||
return zendesk.admin.organizations.users(org)
|
||||
users = zendesk.admin.organizations.users(org)
|
||||
return users
|
||||
|
||||
|
||||
def update_profile(user_profile: UserProfile) -> UserProfile:
|
||||
|
@ -50,7 +50,7 @@
|
||||
<th>Checked</th>
|
||||
</thead>
|
||||
|
||||
<tbody id="table">
|
||||
<tbody id="old_tbody">
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td><a href="#">{{ user.name }}</a></td>
|
||||
@ -60,6 +60,7 @@
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tbody id="new_tbody"></tbody>
|
||||
</table>
|
||||
{% endblock%}
|
||||
|
||||
|
@ -22,16 +22,13 @@ from main.forms import CustomRegistrationForm, AdminPageUsers, CustomAuthenticat
|
||||
from django_registration.views import RegistrationView
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from access_controller.settings import ZENDESK_ROLES
|
||||
from zenpy.lib.api_objects import User as ZenpyUser
|
||||
|
||||
# Django REST
|
||||
from rest_framework import viewsets, status
|
||||
from main.serializers import ProfileSerializer
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import action
|
||||
|
||||
content_type_temp = ContentType.objects.get_for_model(UserProfile)
|
||||
permission_temp, created = Permission.objects.get_or_create(
|
||||
@ -226,7 +223,7 @@ class UsersViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
serializer_class = ProfileSerializer
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
users = update_users_in_model()
|
||||
users = update_users_in_model().values
|
||||
count = count_users(users)
|
||||
profiles = UserProfile.objects.filter(role='agent')
|
||||
serializer = self.get_serializer(profiles, many=True)
|
||||
|
@ -8,6 +8,10 @@ function move_checkboxes() {
|
||||
let el = checkboxes[i].cloneNode(true);
|
||||
fields[i].appendChild(el);
|
||||
}
|
||||
} else {
|
||||
alert(
|
||||
"Количество пользователей агентов не соответствует количеству полей в форме AdminPageUsers"
|
||||
);
|
||||
}
|
||||
}
|
||||
move_checkboxes();
|
||||
@ -27,6 +31,7 @@ class TableRow extends React.Component {
|
||||
type="checkbox"
|
||||
value={this.props.user.id}
|
||||
className="form-check-input"
|
||||
name="users"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
@ -52,7 +57,6 @@ class TableBody extends React.Component {
|
||||
light_agents: response.data.light_agents,
|
||||
});
|
||||
let elements = document.querySelectorAll(".info-quantity-value");
|
||||
console.log(elements)
|
||||
elements[0].innerHTML = this.state.engineers;
|
||||
elements[1].innerHTML = this.state.light_agents;
|
||||
});
|
||||
@ -75,5 +79,5 @@ class TableBody extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
ReactDOM.render(<TableBody />, document.getElementById("table"));
|
||||
|
||||
ReactDOM.render(<TableBody />, document.getElementById("new_tbody"));
|
||||
setTimeout(() => document.getElementById("old_tbody").remove(), 10000);
|
||||
|
Loading…
x
Reference in New Issue
Block a user