| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- '''
- @author: olivier.massot, 2018
- '''
- from django import forms
- from django.contrib.auth.forms import UserCreationForm
- from django.contrib.auth.models import User
- from martor.fields import MartorFormField
- from main.models import Story, Epic, Comment, Sprint
- class RegisterForm(UserCreationForm):
-
- class Meta:
- model = User
- fields = ('username', 'first_name', 'last_name', 'email')
-
- def save(self, commit=True):
- user = super(RegisterForm, self).save(commit=False)
- user.first_name = self.cleaned_data["first_name"]
- user.last_name = self.cleaned_data["last_name"]
- user.email = self.cleaned_data["email"]
- if commit:
- user.save()
- class ProfileForm(forms.ModelForm):
- class Meta:
- model = User
- fields = ('username', 'first_name', 'last_name', 'email')
- class EpicForm(forms.ModelForm):
-
- description = MartorFormField(label="Description")
-
- class Meta:
- model = Epic
- fields = ('project', 'name', 'size', 'value', 'description')
-
- def __init__(self, *args, **kwargs):
- super(EpicForm, self).__init__(*args, **kwargs)
- self.fields['description'].required = False
-
- class StoryForm(forms.ModelForm):
-
- description = MartorFormField(label="Description")
-
- class Meta:
- model = Story
- widgets = {'epic': forms.HiddenInput(), 'author': forms.HiddenInput()}
- fields = ('epic', 'author', 'name', 'weight', 'description', 'assignees', 'sprints')
-
- def __init__(self, *args, **kwargs):
- super(StoryForm, self).__init__(*args, **kwargs)
- self.fields['description'].required = False
- self.fields['assignees'].required = False
- self.fields['sprints'].required = False
- self.fields['weight'].required = False
-
- class CommentForm(forms.ModelForm):
- class Meta:
- model = Comment
- fields = ('content',)
- content = MartorFormField(label="Commentaire")
- class SprintForm(forms.ModelForm):
- class Meta:
- model = Sprint
- fields = ('retro',)
- retro = MartorFormField(label="Rétrospective")
-
-
-
-
|