Skip to content

Commit

Permalink
#127 - Adding error mensages in template.
Browse files Browse the repository at this point in the history
  • Loading branch information
GuiMarques98 committed Dec 7, 2017
1 parent 1694159 commit 42f9f3a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions medical_prescription/prescription/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@
# 250MB - 214958080
# 500MB - 429916160
MAX_UPLOAD_SIZE = 20971520

# Medicine form validation.
MEDICINE_AUTOCOMPLETE = 'Medicine must be in our system.'
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<link rel="stylesheet" href="{% static "prescription/css/modal_prescription.css" %}">
<link rel="stylesheet" href="{% static "prescription/css/select.css" %}">
<link rel="stylesheet" href="{% static "prescription/css/hidden_email.css" %}">
<link rel="stylesheet" href="{% static "prescription/css/error_mensage.css" %}">

<script>
var sortable = "{% static "prescription/js/sortable.js" %}";
Expand Down Expand Up @@ -33,6 +34,10 @@ <h3 class="modal-title">Prescrição</h3>
<!-- This fields are responsable off patient information. -->
{% csrf_token %}
<div class="form-group">
{% if prescription_form.non_field_errors %}
<div class="alert alert-danger" role="alert">{{ prescription_form.non_field_errors }}</div>
{% endif %}

{% for error in prescription_form.patient.errors %}
<div class="alert alert-danger" role="alert">{{error}}</div>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<link rel="stylesheet" href="{% static "prescription/css/autocomplete.css" %}">
<link rel="stylesheet" href="{% static "prescription/css/modal_prescription.css" %}">
<link rel="stylesheet" href="{% static "prescription/css/select.css" %}">
<link rel="stylesheet" href="{% static "prescription/css/error_mensage.css" %}">
<link rel="stylesheet" href="{% static "prescription/css/hidden_email.css" %}">

<script>
Expand Down Expand Up @@ -35,6 +36,10 @@ <h3 class="modal-title">Prescrição</h3>
<!-- This fields are responsable off patient information. -->
{% csrf_token %}
<div class="form-group">
{% if prescription_form.non_field_errors %}
<div class="alert alert-danger" role="alert">{{ prescription_form.non_field_errors }}</div>
{% endif %}

{% for error in prescription_form.patient.errors %}
<div class="alert alert-danger" role="alert">{{error}}</div>
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def validate_length_prescription(self, medicine, exam, recommendation):
else:
# Nothing to do.
pass
else:
# Nothing to do.
pass

if not valid:
raise forms.ValidationError(_(constants.EMPTY_PRESCRIPTION))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.nonfield {
list-style:outside none none;
}

0 comments on commit 42f9f3a

Please sign in to comment.