Commit 239dd056 authored by ibuler's avatar ibuler

Finish admin user view

parent ff30435e
This diff is collapsed.
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<tr class="gradeX"> <tr class="gradeX">
<td class="text-center">{{ admin_user.id }}</td> <td class="text-center">{{ admin_user.id }}</td>
<td> <td>
<a href="{% url 'users:user-detail' pk=user.id %}"> <a href="{% url 'assets:admin-user-detail' pk=admin_user.id %}">
{{ admin_user.name }} {{ admin_user.name }}
</a> </a>
</td> </td>
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div class="ibox-title"> <div class="ibox-title">
<span>{% trans 'Asset list of ' %} <b>{{ asset_group.name }}</b></span> <span style="float: left"></span>{% trans 'Asset list of ' %} <b>{{ asset_group.name }}</b></span>
<div class="ibox-tools"> <div class="ibox-tools">
<a class="collapse-link"> <a class="collapse-link">
<i class="fa fa-chevron-up"></i> <i class="fa fa-chevron-up"></i>
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
<div class="col-sm-5" style="padding-left: 0;padding-right: 0"> <div class="col-sm-5" style="padding-left: 0;padding-right: 0">
<div class="panel panel-primary"> <div class="panel panel-primary">
<div class="panel-heading"> <div class="panel-heading">
<i class="fa fa-info-circle"></i> {% trans 'Associate asset user(system/admin)' %} <i class="fa fa-info-circle"></i> {% trans 'Associate system user' %}
</div> </div>
<div class="panel-body"> <div class="panel-body">
<table class="table"> <table class="table">
...@@ -207,23 +207,23 @@ ...@@ -207,23 +207,23 @@
{% endblock %} {% endblock %}
{% block custom_foot_js %} {% block custom_foot_js %}
<script> <script>
function switch_user_status(obj) { {# function switch_user_status(obj) {#}
var status = $(obj).prop('checked'); {# var status = $(obj).prop('checked');#}
{##}
$.ajax({ {# $.ajax({#}
url: "{% url 'users:user-active-api' pk=user.id %}", {# url: "{% url 'users:user-active-api' pk=user.id %}",#}
type: "PUT", {# type: "PUT",#}
data: { {# data: {#}
'is_active': status {# 'is_active': status#}
}, {# },#}
success: function (data, status) { {# success: function (data, status) {#}
console.log(data) {# console.log(data)#}
}, {# },#}
error: function () { {# error: function () {#}
console.log('error') {# console.log('error')#}
} {# }#}
}) {# })#}
} {# }#}
$(document).ready(function () { $(document).ready(function () {
$('.select2').select2(); $('.select2').select2();
}) })
......
...@@ -213,7 +213,7 @@ class AdminUserListView(AdminUserRequiredMixin, ListView): ...@@ -213,7 +213,7 @@ class AdminUserListView(AdminUserRequiredMixin, ListView):
return super(AdminUserListView, self).get_context_data(**kwargs) return super(AdminUserListView, self).get_context_data(**kwargs)
def get_queryset(self): def get_queryset(self):
# Todo: Default group by lose asset connection num # Todo: Default order by lose asset connection num
self.queryset = super(AdminUserListView, self).get_queryset() self.queryset = super(AdminUserListView, self).get_queryset()
self.keyword = keyword = self.request.GET.get('keyword', '') self.keyword = keyword = self.request.GET.get('keyword', '')
self.sort = sort = self.request.GET.get('sort', '-date_created') self.sort = sort = self.request.GET.get('sort', '-date_created')
...@@ -230,7 +230,7 @@ class AdminUserListView(AdminUserRequiredMixin, ListView): ...@@ -230,7 +230,7 @@ class AdminUserListView(AdminUserRequiredMixin, ListView):
class AdminUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView): class AdminUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
model = AdminUser model = AdminUser
form_class = AdminUserForm form_class = AdminUserForm
template_name = 'assets/admin_user_create.html' template_name = 'assets/admin_user_create_update.html'
success_url = reverse_lazy('assets:admin-user-list') success_url = reverse_lazy('assets:admin-user-list')
success_message = _('Create admin user <a href="%s">%s</a> successfully.') success_message = _('Create admin user <a href="%s">%s</a> successfully.')
...@@ -250,12 +250,46 @@ class AdminUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVie ...@@ -250,12 +250,46 @@ class AdminUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVie
class AdminUserUpdateView(AdminUserRequiredMixin, UpdateView): class AdminUserUpdateView(AdminUserRequiredMixin, UpdateView):
pass model = AdminUser
form_class = AdminUserForm
template_name = 'assets/admin_user_create_update.html'
success_message = _('Update admin user <a href="%s">%s</a> successfully.')
def get_context_data(self, **kwargs):
context = {
'app': 'assets',
'action': 'Update admin user'
}
kwargs.update(context)
return super(AdminUserUpdateView, self).get_context_data(**kwargs)
class AdminUserDetailView(AdminUserRequiredMixin, DetailView): def get_success_url(self):
pass success_url = reverse_lazy('assets:admin-user-detail', pk=self.object.pk)
return success_url
class AdminUserDetailView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
paginate_by = settings.CONFIG.DISPLAY_PER_PAGE
template_name = 'assets/admin_user_detail.html'
context_object_name = 'admin_user'
def get(self, request, *args, **kwargs):
self.object = self.get_object(queryset=AdminUser.objects.all())
return super(AdminUserDetailView, self).get(request, *args, **kwargs)
def get_queryset(self):
return self.object.assets.all()
def get_context_data(self, **kwargs):
context = {
'app': 'assets',
'action': 'Admin user detail'
}
kwargs.update(context)
return super(AdminUserDetailView, self).get_context_data(**kwargs)
class AdminUserDeleteView(AdminUserRequiredMixin, DeleteView): class AdminUserDeleteView(AdminUserRequiredMixin, DeleteView):
pass model = AdminUser
template_name = 'assets/delete_confirm.html'
success_url = 'assets:admin-user-list'
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<div class="col-sm-5" style="padding-left: 0;padding-right: 0"> <div class="col-sm-5" style="padding-left: 0;padding-right: 0">
<div class="panel panel-primary"> <div class="panel panel-primary">
<div class="panel-heading"> <div class="panel-heading">
<i class="fa fa-info-circle"></i> {% trans 'Quick modify' %} <i class="fa fa-info-circle"></i> {% trans 'Quick update' %}
</div> </div>
<div class="panel-body"> <div class="panel-body">
<table class="table"> <table class="table">
...@@ -191,7 +191,7 @@ ...@@ -191,7 +191,7 @@
<tr> <tr>
<td ><b class="bdg_user_group" data-gid={{ group.id }}>{{ group.name }}</b></td> <td ><b class="bdg_user_group" data-gid={{ group.id }}>{{ group.name }}</b></td>
<td> <td>
<button class="btn btn-danger btn-sm btn_delete_user_group" type="button" style="float: right;"><i class="fa fa-minus"></i></button> <button class="btn btn-danger btn-xs btn_delete_user_group" type="button" style="float: right;"><i class="fa fa-minus"></i></button>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
......
...@@ -16,7 +16,6 @@ urlpatterns = [ ...@@ -16,7 +16,6 @@ urlpatterns = [
name='reset-password-success'), name='reset-password-success'),
url(r'^user$', views.UserListView.as_view(), name='user-list'), url(r'^user$', views.UserListView.as_view(), name='user-list'),
url(r'^user/(?P<pk>[0-9]+)$', views.UserDetailView.as_view(), name='user-detail'), url(r'^user/(?P<pk>[0-9]+)$', views.UserDetailView.as_view(), name='user-detail'),
url(r'^user/(?P<pk>[0-9]+)/assets-perm$', views.UserDetailView.as_view(), name='user-detail'),
url(r'^user/create$', views.UserCreateView.as_view(), name='user-create'), url(r'^user/create$', views.UserCreateView.as_view(), name='user-create'),
url(r'^user/(?P<pk>[0-9]+)/update$', views.UserUpdateView.as_view(), name='user-update'), url(r'^user/(?P<pk>[0-9]+)/update$', views.UserUpdateView.as_view(), name='user-update'),
url(r'^user/(?P<pk>[0-9]+)/delete$', views.UserDeleteView.as_view(), name='user-delete'), url(r'^user/(?P<pk>[0-9]+)/delete$', views.UserDeleteView.as_view(), name='user-delete'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment