Skip to content
Snippets Groups Projects
Commit 7c7cbf0f authored by Carlos Vega's avatar Carlos Vega
Browse files

finished visits now have read only details form

parent 1bc15e73
No related branches found
No related tags found
1 merge request!188Feature/improve management of visits from subject list
Pipeline #7818 passed
......@@ -60,6 +60,14 @@ class VisitDetailForm(ModelForm):
appointment_types = forms.ModelMultipleChoiceField(required=False, widget=forms.CheckboxSelectMultiple,
queryset=AppointmentType.objects.all())
def __init__(self, *args, **kwargs):
super(VisitDetailForm, self).__init__(*args, **kwargs)
instance = getattr(self, 'instance', None)
if instance.is_finished: #set form as readonly
for key in self.fields.keys():
self.fields[key].widget.attrs['readonly'] = True
class Meta:
model = Visit
exclude = ['is_finished', 'visit_number']
......
......@@ -13,7 +13,7 @@
background: orange;
{% endif %}{% endif %}{% endfor %}{% endfor %}
"></div>
<input {% if readonly %}disabled="disabled"{% endif %}
<input {% if field.field.widget.attrs.readonly %}disabled="disabled"{% endif %}
{% for option in field.value %}{% if option == pk|slugify or option == pk %}checked="checked"
{% endif %}{% endfor %} type="checkbox"
id="id_{{ field.name }}_{{ forloop.counter0 }}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment