personnes: show inactive accesses and allow to re-active an access.
This commit is contained in:
parent
01e321c760
commit
0a4f779fa4
|
@ -6,7 +6,11 @@
|
|||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('.icon-minus').click(function() {
|
||||
generic_ajaxform_dialog($(this).data('id') + '/delete/', "Supprimer un utilisateur",
|
||||
generic_ajaxform_dialog($(this).data('id') + '/delete/', "Désactiver un utilisateur",
|
||||
'#ajax-dlg', '500px', 'Oui');
|
||||
});
|
||||
$('.icon-plus').click(function() {
|
||||
generic_ajaxform_dialog($(this).data('id') + '/activate/', "Activer un utilisateur",
|
||||
'#ajax-dlg', '500px', 'Oui');
|
||||
});
|
||||
});
|
||||
|
@ -44,6 +48,7 @@
|
|||
{% block content %}
|
||||
<div class="content">
|
||||
{% if active_list %}
|
||||
<h2>Accès actifs</h2>
|
||||
<table class="main" id="timetable-table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -51,7 +56,7 @@
|
|||
<th>Courriel</th>
|
||||
<th>Fiche Personnel</th>
|
||||
<th>Roles</th>
|
||||
<th>Supprimer</th>
|
||||
<th>Désactiver</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -69,9 +74,36 @@
|
|||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>Il n'y a aucun compte actif</p>
|
||||
<p>Il n'y a aucun compte actif.</p>
|
||||
{% endif %}
|
||||
<br/>
|
||||
{% if inactive_list %}
|
||||
<h2>Accès inactifs</h2>
|
||||
<table class="main" id="timetable-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Identifiant</th>
|
||||
<th>Courriel</th>
|
||||
<th>Fiche Personnel</th>
|
||||
<th>Activer</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for object in inactive_list %}
|
||||
<tr data-pk="{{object.pk}}" id="object-{{ object.pk}}">
|
||||
<td>{{object.username}}</td>
|
||||
<td>{{object.email}}</td>
|
||||
{% with worker=object.userworker.worker %}
|
||||
<td>{% if worker %}<a href="{{ worker.get_absolute_url }}">{{ worker }}</a>{% else %}-{% endif %}</td>
|
||||
{% endwith %}
|
||||
<td><button class="icon-plus" data-id="{{ object.id }}"/></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>Il n'y a aucun compte inactif.</p>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{% load widget_tweaks %}
|
||||
|
||||
{% if error_message %}
|
||||
<p><strong>{{ error_message }}</strong></p>
|
||||
{% endif %}
|
||||
<form action="{{ request.get_full_path }}" method="post">{% csrf_token %}
|
||||
<p>Êtes-vous sûr de vouloir activer {{ object }} ?</p>
|
||||
</form>
|
|
@ -0,0 +1,8 @@
|
|||
{% load widget_tweaks %}
|
||||
|
||||
{% if error_message %}
|
||||
<p><strong>{{ error_message }}</strong></p>
|
||||
{% endif %}
|
||||
<form action="{{ request.get_full_path }}" method="post">{% csrf_token %}
|
||||
<p>Êtes-vous sûr de vouloir désactiver {{ object }} ?</p>
|
||||
</form>
|
|
@ -7,6 +7,7 @@ user_patterns = patterns('calebasse.personnes.views',
|
|||
url(r'^new/$', 'user_new'),
|
||||
url(r'^(?P<pk>\d+)/$', 'user_update'),
|
||||
url(r'^(?P<pk>\d+)/delete/$', 'user_delete'),
|
||||
url(r'^(?P<pk>\d+)/activate/$', 'user_activate'),
|
||||
)
|
||||
|
||||
holiday_actions_paterns = patterns('calebasse.personnes.views',
|
||||
|
|
|
@ -56,6 +56,7 @@ class AccessView(cbv.ListView):
|
|||
def get_context_data(self, **kwargs):
|
||||
ctx = super(AccessView, self).get_context_data(**kwargs)
|
||||
ctx['active_list'] = ctx['object_list'].filter(is_active=True)
|
||||
ctx['inactive_list'] = ctx['object_list'].filter(is_active=False)
|
||||
return ctx
|
||||
|
||||
|
||||
|
@ -132,7 +133,7 @@ class UserCreateView(cbv.ServiceFormMixin, cbv.CreateView):
|
|||
class UserDisactivateView(cbv.DeleteView):
|
||||
model = User
|
||||
success_url = "../../"
|
||||
template_name = 'calebasse/generic_confirm_delete.html'
|
||||
template_name = 'personnes/disactivate_access.html'
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
|
@ -140,10 +141,21 @@ class UserDisactivateView(cbv.DeleteView):
|
|||
self.object.save()
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
class UserActivateView(cbv.DeleteView):
|
||||
model = User
|
||||
success_url = "../../"
|
||||
template_name = 'personnes/activate_access.html'
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
self.object.is_active = True
|
||||
self.object.save()
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
user_new = super_user_only(UserCreateView.as_view())
|
||||
user_update = super_user_only(AccessUpdateView.as_view())
|
||||
user_delete = super_user_only(UserDisactivateView.as_view())
|
||||
user_activate = super_user_only(UserActivateView.as_view())
|
||||
|
||||
|
||||
class WorkerUpdateView(cbv.ServiceViewMixin, cbv.MultiUpdateView):
|
||||
|
|
Reference in New Issue