diff --git a/smash/web/forms.py b/smash/web/forms.py index c4fe054025fc6a62e56b823cc3ca41b192ead232..45b73ef30491cd3cff6e4b51bbfa55c7830e9a3b 100644 --- a/smash/web/forms.py +++ b/smash/web/forms.py @@ -94,13 +94,6 @@ class SubjectEditForm(ModelForm): if was_resigned: self.fields['resigned'].disabled = True - def clean_screening_number(self): - instance = getattr(self, 'instance', None) - if instance and instance.id: - return instance.screening_number - else: - return self.cleaned_data['screening_number'] - def clean(self): validate_subject_nd_number(self) diff --git a/smash/web/templates/subjects/edit.html b/smash/web/templates/subjects/edit.html index 1da6a65b6b820ba44e690e9e720cdb19274d71f5..0c8b2f5705b0de274e1cb6149ea7e249e3537b9b 100644 --- a/smash/web/templates/subjects/edit.html +++ b/smash/web/templates/subjects/edit.html @@ -51,9 +51,7 @@ </div> {% if field.errors %} - <span class="help-block"> - {{ field.errors }} - </span> + <span class="help-block"> {{ field.errors }} </span> {% endif %} </div> {% endfor %} @@ -74,7 +72,7 @@ </form> </div> - <div class="modal modal-danger fade" tabindex="-1" role="dialog"> + <div class="modal modal-danger fade" id="confirm-dead-resigned-mark-dialog" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> @@ -93,6 +91,25 @@ </div><!-- /.modal-dialog --> </div><!-- /.modal --> + <div class="modal modal-danger fade" id="enable-screening-number-dialog" tabindex="-1" role="dialog"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span + aria-hidden="true">×</span></button> + <h4 class="modal-title">Are you sure that you want to perfom this operation?</h4> + </div> + <div class="modal-body"> + <p>Screening number shouldn't change.</p> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">Cancel</button> + <button type="button" id="confirm-screening-change" class="btn btn-outline">Yes</button> + </div> + </div><!-- /.modal-content --> + </div><!-- /.modal-dialog --> + </div><!-- /.modal --> + {% endblock %} @@ -122,7 +139,7 @@ } if ((!dead_was_checked && $("#id_dead").is(":checked")) || (!resigned_was_checked && $("#id_resigned").is(":checked"))) { confirmed = false; - $(".modal").modal("show"); + $("#confirm-dead-resigned-mark-dialog").modal("show"); return false; } }); @@ -130,7 +147,24 @@ confirmed = true; $("form").submit(); }); + + $("#confirm-screening-change").click(function () { + $('#enable-screening-number-dialog').modal('hide'); + + $("input[name='screening_number']").attr("readonly", false); + $("input[name='screening_number']")[0].focus(); + }); + + $("input[name='screening_number']").attr("readonly", true); + $("input[name='screening_number']").after("<div><a class='btn btn-block btn-danger' onclick='show_screening_number_enable_dialog()'>modify<a/></div>"); + + }); + function show_screening_number_enable_dialog() { + $('#enable-screening-number-dialog').modal('show'); + } + + </script> {% include "includes/datepicker.js.html" %}