]> git.parisson.com Git - teleforma.git/commitdiff
try to fix initial data
authorGuillaume Pellerin <yomguy@parisson.com>
Wed, 3 Feb 2016 17:45:40 +0000 (18:45 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Wed, 3 Feb 2016 17:45:40 +0000 (18:45 +0100)
teleforma/forms.py
teleforma/views/crfpa.py

index ac1f1b9a6047edd25fb69486aaf104087dcafb28..9d6a52c5981b5abd0f6f20285f9e21af59d6dc86 100644 (file)
@@ -34,6 +34,15 @@ RegistrationForm.base_fields.update(ProfileForm.base_fields)
 
 
 class StudentForm(ModelForm):
+
+    def has_changed(self):
+        """
+        Overriding this, as the initial data passed to the form does not get noticed, 
+        and so does not get saved, unless it actually changes
+        """
+        changed_data = super(ModelForm, self).has_changed()
+        return bool(self.initial or changed_data)
+
     class Meta:
         model = Student
         exclude = ['user', 'trainings', 'options']
@@ -65,7 +74,3 @@ class StudentInline(InlineFormSet):
     fields = ['iej', 'period', 'procedure', 'written_speciality', 'oral_speciality',
                 'oral_1', ]
 
-    def get_initial(self):
-        initial = super(StudentInline, self).get_initial()
-        initial['procedure'] = Course.objects.filter(title__contains='civil')
-        return initial
index 9a89fe9f699ab597f367afcda26fe109a1c85ff5..c804b6c5d47d987615c12784650be63b1d16dc1f 100644 (file)
@@ -411,6 +411,13 @@ class UserAddView(CreateWithInlinesView):
         user.save()
         return super(UserAddView, self).forms_valid(form, inlines)
 
+    #def construct_inlines(self):
+        #Filtra el socio de negocio del detalle por tipo=Proveedor (Aseguradora)
+    #    inlines = super(CreateWithInlinesView, self).construct_inlines()
+    #    student_inline = inlines[1]                        
+    #    student_inline.form.base_fields['procedure'].queryset = Course.objects.filter(title__contains='civil')
+    #    return inlines
+
 
 class UserCompleteView(TemplateView):