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