From e97141486d1d11ae4ce19c9232c12fb7cf46f56c Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 4 Dec 2017 11:53:58 +0100
Subject: [PATCH] default order of subject field added

---
 smash/web/forms/subject_forms.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/smash/web/forms/subject_forms.py b/smash/web/forms/subject_forms.py
index 008ab882..b4f12f65 100644
--- a/smash/web/forms/subject_forms.py
+++ b/smash/web/forms/subject_forms.py
@@ -1,9 +1,9 @@
 from django import forms
 from django.forms import ModelForm
 
+from web.forms.forms import DATEPICKER_DATE_ATTRS
 from web.models import Subject
 from web.models.constants import COUNTRY_OTHER_ID
-from web.forms.forms import DATEPICKER_DATE_ATTRS
 
 
 def validate_subject_country(self, cleaned_data):
@@ -11,12 +11,19 @@ def validate_subject_country(self, cleaned_data):
         self.add_error('country', "Select valid country")
 
 
+FIELD_ORDER = ["first_name", "last_name", "sex", "date_born", "social_security_number",
+               "default_written_communication_language", "languages", "phone_number", "phone_number_2",
+               "phone_number_3", "address", "city", "postal_code", "country"]
+
+
 class SubjectAddForm(ModelForm):
     date_born = forms.DateField(label="Date of birth",
                                 widget=forms.DateInput(DATEPICKER_DATE_ATTRS, "%Y-%m-%d"),
                                 required=False
                                 )
 
+    field_order = FIELD_ORDER
+
     class Meta:
         model = Subject
         fields = '__all__'
@@ -34,6 +41,8 @@ class SubjectEditForm(ModelForm):
                                 required=False
                                 )
 
+    field_order = FIELD_ORDER
+
     def __init__(self, *args, **kwargs):
         was_dead = kwargs.get('was_dead', False)
         if 'was_dead' in kwargs:
@@ -51,6 +60,8 @@ class SubjectEditForm(ModelForm):
 
 
 class SubjectDetailForm(ModelForm):
+    field_order = FIELD_ORDER
+
     class Meta:
         model = Subject
         fields = '__all__'
-- 
GitLab