Revision 9d75fa2a
Added by Benjamin Dauvergne over 12 years ago
calebasse/agenda/templates/agenda/act-validation.html | ||
---|---|---|
12 | 12 |
<input type="hidden" name="unlock-all" value="1"> |
13 | 13 |
<button id="unlock-all">Tout déverrouiller</button> |
14 | 14 |
</form> |
15 |
<form method="post"> |
|
16 |
{% csrf_token %} |
|
17 |
<input type="hidden" name="validate-all" value="1"> |
|
18 |
<button id="validate-all">Validation automatique</button> |
|
19 |
</form> |
|
15 |
<button id="validate-all">Validation automatique</button> |
|
20 | 16 |
{% endif %} |
21 | 17 |
{% endblock %} |
22 | 18 |
|
... | ... | |
81 | 77 |
<p><strong>Il n'y a pas d'acte à valider le {{ date|date:"DATE_FORMAT" }}.</strong></p> |
82 | 78 |
{% endif %} |
83 | 79 |
{% endblock %} |
80 |
|
|
81 |
{% block dialogs %} |
|
82 |
<div id="validate-all-dialog" title="Validation"> |
|
83 |
<div id="validate-all-dialog-content"> |
|
84 |
</div> |
|
85 |
<form action="{% url 'validation-all' service=service date=date %}" method="post"> |
|
86 |
{% csrf_token %} |
|
87 |
<input type="hidden" name="validate-all" value="1"> |
|
88 |
</form> |
|
89 |
</div> |
|
90 |
{% endblock %} |
|
91 |
|
|
92 |
|
|
84 | 93 |
{% block page-end %} |
85 | 94 |
<script> |
86 | 95 |
$('select[name^="act_state"]').on('change', function () { |
87 | 96 |
$(this).next('button').prop('disabled', |
88 | 97 |
($(this).data('previous') == $(this).val())); |
89 | 98 |
}) |
99 |
$('#validate-all-dialog').dialog({ |
|
100 |
autoOpen: false, |
|
101 |
modal: true, |
|
102 |
buttons: { |
|
103 |
"Valider": function () { $('#validate-all-dialog form').submit(); }, |
|
104 |
"Annuler": function () { $(this).dialog("close"); }, |
|
105 |
}, |
|
106 |
}); |
|
107 |
$('#validate-all').click(function () { |
|
108 |
$('#validate-all-dialog-content').load('{% url 'validation-all' service=service date=date %}', |
|
109 |
function () { |
|
110 |
$('#validate-all-dialog').dialog('open'); |
|
111 |
} |
|
112 |
); |
|
113 |
}); |
|
90 | 114 |
</script> |
91 | 115 |
{% endblock %} |
calebasse/agenda/templates/agenda/automated-validation.html | ||
---|---|---|
1 |
nb_acts_total: {{nb_acts_total}}<br/> |
|
2 |
nb_acts_validated: {{nb_acts_validated}}<br/> |
|
3 |
nb_acts_double: {{nb_acts_double}}<br/> |
|
4 |
nb_acts_abs_non_exc: {{nb_acts_abs_non_exc}}<br/> |
|
5 |
nb_acts_abs_exc: {{nb_acts_abs_exc}}<br/> |
|
6 |
nb_acts_annul_nous: {{nb_acts_annul_nous}}<br/> |
|
7 |
nb_acts_annul_famille: {{nb_acts_annul_famille}}<br/> |
|
8 |
nb_acts_abs_ess_pps: {{nb_acts_abs_ess_pps}}<br/> |
|
9 |
nb_acts_enf_hosp: {{nb_acts_enf_hosp}}<br/> |
calebasse/agenda/views.py | ||
---|---|---|
194 | 194 |
return get_acts_of_the_day(self.date) |
195 | 195 |
|
196 | 196 |
def post(self, request, *args, **kwargs): |
197 |
if 'validate-all' in request.POST: |
|
198 |
#TODO: check that the user is authorized |
|
199 |
(nb_acts_total, nb_acts_validated, nb_acts_double, |
|
200 |
nb_acts_abs_non_exc, nb_acts_abs_exc, nb_acts_annul_nous, |
|
201 |
nb_acts_annul_famille, nb_acts_abs_ess_pps, |
|
202 |
nb_acts_enf_hosp) = \ |
|
203 |
automated_validation(self.date, self.service, |
|
204 |
request.user, commit = False) |
|
205 |
#TODO: call confirmation pop-up |
|
206 |
elif 'unlock-all' in request.POST: |
|
197 |
if 'unlock-all' in request.POST: |
|
207 | 198 |
#TODO: check that the user is authorized |
208 | 199 |
unlock_all_acts_of_the_day(self.date) |
209 | 200 |
else: |
... | ... | |
242 | 233 |
return context |
243 | 234 |
|
244 | 235 |
|
245 |
class AutomatedValidationView(CreateView): |
|
246 |
pass |
|
236 |
class AutomatedValidationView(TemplateView): |
|
237 |
template_name = 'agenda/automated-validation.html' |
|
238 |
|
|
239 |
def post(self, request, *args, **kwargs): |
|
240 |
automated_validation(self.date, self.service, |
|
241 |
request.user) |
|
242 |
return HttpResponseRedirect('..') |
|
243 |
|
|
244 |
def get_context_data(self, **kwargs): |
|
245 |
context = super(AutomatedValidationView, self).get_context_data(**kwargs) |
|
246 |
request = self.request |
|
247 |
(nb_acts_total, nb_acts_validated, nb_acts_double, |
|
248 |
nb_acts_abs_non_exc, nb_acts_abs_exc, nb_acts_annul_nous, |
|
249 |
nb_acts_annul_famille, nb_acts_abs_ess_pps, |
|
250 |
nb_acts_enf_hosp) = \ |
|
251 |
automated_validation(self.date, self.service, |
|
252 |
request.user, commit = False) |
|
253 |
|
|
254 |
context.update({ |
|
255 |
'nb_acts_total': nb_acts_total, |
|
256 |
'nb_acts_validated': nb_acts_validated, |
|
257 |
'nb_acts_double': nb_acts_double, |
|
258 |
'nb_acts_abs_non_exc': nb_acts_abs_non_exc, |
|
259 |
'nb_acts_abs_exc': nb_acts_abs_exc, |
|
260 |
'nb_acts_annul_nous': nb_acts_annul_nous, |
|
261 |
'nb_acts_annul_famille': nb_acts_annul_famille, |
|
262 |
'nb_acts_abs_ess_pps': nb_acts_abs_ess_pps, |
|
263 |
'nb_acts_enf_hosp': nb_acts_enf_hosp}) |
|
264 |
return context |
|
247 | 265 |
|
248 | 266 |
class UnlockAllView(CreateView): |
249 | 267 |
pass |
Also available in: Unified diff
add detailed modal confirmation dialog when automatic validation button is clicked, fixes #1887