Projet

Général

Profil

« Précédent | Suivant » 

Révision 0a4f779f

Ajouté par Mikaël Ates il y a plus de 9 ans

personnes: show inactive accesses and allow to re-active an access.

Voir les différences:

calebasse/personnes/templates/personnes/acces.html
6 6
<script type="text/javascript">
7 7
    $(function() {
8 8
            $('.icon-minus').click(function() {
9
                generic_ajaxform_dialog($(this).data('id') + '/delete/', "Supprimer un utilisateur",
9
                generic_ajaxform_dialog($(this).data('id') + '/delete/', "Désactiver un utilisateur",
10
                    '#ajax-dlg', '500px', 'Oui');
11
                });
12
            $('.icon-plus').click(function() {
13
                generic_ajaxform_dialog($(this).data('id') + '/activate/', "Activer un utilisateur",
10 14
                    '#ajax-dlg', '500px', 'Oui');
11 15
                });
12 16
            });
......
44 48
{% block content %}
45 49
<div class="content">
46 50
  {% if active_list %}
51
  <h2>Accès actifs</h2>
47 52
  <table class="main" id="timetable-table">
48 53
    <thead>
49 54
    <tr>
......
51 56
      <th>Courriel</th>
52 57
      <th>Fiche Personnel</th>
53 58
      <th>Roles</th>
54
      <th>Supprimer</th>
59
      <th>Désactiver</th>
55 60
    </tr>
56 61
    </thead>
57 62
    <tbody>
......
69 74
    </tbody>
70 75
  </table>
71 76
  {% else %}
72
  <p>Il n'y a aucun compte actif</p>
77
  <p>Il n'y a aucun compte actif.</p>
78
  {% endif %}
79
  <br/>
80
  {% if inactive_list %}
81
  <h2>Accès inactifs</h2>
82
  <table class="main" id="timetable-table">
83
    <thead>
84
    <tr>
85
      <th>Identifiant</th>
86
      <th>Courriel</th>
87
      <th>Fiche Personnel</th>
88
      <th>Activer</th>
89
    </tr>
90
    </thead>
91
    <tbody>
92
   {% for object in inactive_list %}
93
     <tr data-pk="{{object.pk}}" id="object-{{ object.pk}}">
94
      <td>{{object.username}}</td>
95
      <td>{{object.email}}</td>
96
      {% with worker=object.userworker.worker %}
97
      <td>{% if worker %}<a href="{{ worker.get_absolute_url }}">{{ worker }}</a>{% else %}-{% endif %}</td>
98
      {% endwith %}
99
      <td><button class="icon-plus" data-id="{{ object.id }}"/></a></td>
100
    </tr>
101
   {% endfor %}
102
    </tbody>
103
  </table>
104
  {% else %}
105
  <p>Il n'y a aucun compte inactif.</p>
73 106
  {% endif %}
74

  
75 107
</div>
76 108
{% endblock %}
77 109

  
calebasse/personnes/templates/personnes/activate_access.html
1
{% load widget_tweaks %}
2

  
3
{% if error_message %}
4
<p><strong>{{ error_message }}</strong></p>
5
{% endif %}
6
<form action="{{ request.get_full_path }}" method="post">{% csrf_token %}
7
  <p>Êtes-vous sûr de vouloir activer {{ object }} ?</p>
8
</form>
calebasse/personnes/templates/personnes/disactivate_access.html
1
{% load widget_tweaks %}
2

  
3
{% if error_message %}
4
<p><strong>{{ error_message }}</strong></p>
5
{% endif %}
6
<form action="{{ request.get_full_path }}" method="post">{% csrf_token %}
7
  <p>Êtes-vous sûr de vouloir désactiver {{ object }} ?</p>
8
</form>
calebasse/personnes/urls.py
7 7
    url(r'^new/$', 'user_new'),
8 8
    url(r'^(?P<pk>\d+)/$', 'user_update'),
9 9
    url(r'^(?P<pk>\d+)/delete/$', 'user_delete'),
10
    url(r'^(?P<pk>\d+)/activate/$', 'user_activate'),
10 11
)
11 12

  
12 13
holiday_actions_paterns = patterns('calebasse.personnes.views',
calebasse/personnes/views.py
56 56
    def get_context_data(self, **kwargs):
57 57
        ctx = super(AccessView, self).get_context_data(**kwargs)
58 58
        ctx['active_list'] = ctx['object_list'].filter(is_active=True)
59
        ctx['inactive_list'] = ctx['object_list'].filter(is_active=False)
59 60
        return ctx
60 61

  
61 62

  
......
132 133
class UserDisactivateView(cbv.DeleteView):
133 134
    model = User
134 135
    success_url = "../../"
135
    template_name = 'calebasse/generic_confirm_delete.html'
136
    template_name = 'personnes/disactivate_access.html'
136 137

  
137 138
    def delete(self, request, *args, **kwargs):
138 139
        self.object = self.get_object()
......
140 141
        self.object.save()
141 142
        return HttpResponseRedirect(self.get_success_url())
142 143

  
144
class UserActivateView(cbv.DeleteView):
145
    model = User
146
    success_url = "../../"
147
    template_name = 'personnes/activate_access.html'
148

  
149
    def delete(self, request, *args, **kwargs):
150
        self.object = self.get_object()
151
        self.object.is_active = True
152
        self.object.save()
153
        return HttpResponseRedirect(self.get_success_url())
143 154

  
144 155
user_new = super_user_only(UserCreateView.as_view())
145 156
user_update = super_user_only(AccessUpdateView.as_view())
146 157
user_delete = super_user_only(UserDisactivateView.as_view())
158
user_activate = super_user_only(UserActivateView.as_view())
147 159

  
148 160

  
149 161
class WorkerUpdateView(cbv.ServiceViewMixin, cbv.MultiUpdateView):

Formats disponibles : Unified diff