summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Ates <mates@entrouvert.com>2014-10-07 15:39:22 (GMT)
committerMikaël Ates <mates@entrouvert.com>2014-10-07 15:39:22 (GMT)
commit0a4f779fa43dc39ba24ed6d25f7bf1eecfba8b27 (patch)
treecf388a6148650b30050952a7c1c8c2f4065679a6
parent01e321c7606d3f1af69da34b9da492618bffdca1 (diff)
downloadcalebasse-0a4f779fa43dc39ba24ed6d25f7bf1eecfba8b27.zip
calebasse-0a4f779fa43dc39ba24ed6d25f7bf1eecfba8b27.tar.gz
calebasse-0a4f779fa43dc39ba24ed6d25f7bf1eecfba8b27.tar.bz2
personnes: show inactive accesses and allow to re-active an access.
-rw-r--r--calebasse/personnes/templates/personnes/acces.html40
-rw-r--r--calebasse/personnes/templates/personnes/activate_access.html8
-rw-r--r--calebasse/personnes/templates/personnes/disactivate_access.html8
-rw-r--r--calebasse/personnes/urls.py1
-rw-r--r--calebasse/personnes/views.py14
5 files changed, 66 insertions, 5 deletions
diff --git a/calebasse/personnes/templates/personnes/acces.html b/calebasse/personnes/templates/personnes/acces.html
index 44b2d2c..ea76c5d 100644
--- a/calebasse/personnes/templates/personnes/acces.html
+++ b/calebasse/personnes/templates/personnes/acces.html
@@ -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 %}
diff --git a/calebasse/personnes/templates/personnes/activate_access.html b/calebasse/personnes/templates/personnes/activate_access.html
new file mode 100644
index 0000000..d0ea394
--- /dev/null
+++ b/calebasse/personnes/templates/personnes/activate_access.html
@@ -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>
diff --git a/calebasse/personnes/templates/personnes/disactivate_access.html b/calebasse/personnes/templates/personnes/disactivate_access.html
new file mode 100644
index 0000000..f280838
--- /dev/null
+++ b/calebasse/personnes/templates/personnes/disactivate_access.html
@@ -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>
diff --git a/calebasse/personnes/urls.py b/calebasse/personnes/urls.py
index b1aeb2f..48fe295 100644
--- a/calebasse/personnes/urls.py
+++ b/calebasse/personnes/urls.py
@@ -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',
diff --git a/calebasse/personnes/views.py b/calebasse/personnes/views.py
index e874508..51196ee 100644
--- a/calebasse/personnes/views.py
+++ b/calebasse/personnes/views.py
@@ -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):