Pārlūkot izejas kodu

Fix bug on stories creation

omassot 6 gadi atpakaļ
vecāks
revīzija
43e1384eec
1 mainītis faili ar 6 papildinājumiem un 1 dzēšanām
  1. 6 1
      main/forms.py

+ 6 - 1
main/forms.py

@@ -55,6 +55,7 @@ class StoryForm(forms.ModelForm):
         fields = ('epic', 'author', 'name', 'weight', 'time_spent', 'story_type', 'description', 'assignees', 'sprints')
         
     def __init__(self, *args, **kwargs):
+        
         super(StoryForm, self).__init__(*args, **kwargs)
         self.fields['description'].required = False
         self.fields['assignees'].required = False
@@ -63,12 +64,16 @@ class StoryForm(forms.ModelForm):
         self.fields['time_spent'].required = False
         self.fields['story_type'].required = False
     
+    def clean(self):
+        cleaned_data = super().clean()
+        cleaned_data["epic"] = Epic.objects.get(pk=int(cleaned_data["epic"]))
+        return cleaned_data
+    
     def save(self, *args, **kwargs):
         if self.cleaned_data['weight'] == '':
             self.cleaned_data['weight'] = None
         return super(StoryForm, self).save(*args, **kwargs)
         
-        
 class CommentForm(forms.ModelForm):
     class Meta:
         model = Comment