ADDED: <TicketCCForm.clean> to validate if either a valid user or a valid email is provided when saving <TicketCC> instances

This commit is contained in:
Bruno Tikami 2016-02-19 11:00:35 -02:00
parent 99bfc340f9
commit e4337cef1d

View File

@ -540,6 +540,16 @@ class TicketCCForm(forms.ModelForm):
model = TicketCC
exclude = ('ticket',)
def clean(self):
cleaned_data = super(TicketCCForm, self).clean()
user = cleaned_data.get('user', None)
email = cleaned_data.get('email', '')
if user is None and len(email) == 0:
raise forms.ValidationError(_('When you add somebody on Cc, you must provided either an User or a valid email.'))
class TicketDependencyForm(forms.ModelForm):
class Meta:
model = TicketDependency