Simplified the email.origin assignment code for outgoing liaisons.
- Legacy-Id: 15176
This commit is contained in:
parent
2fd1f81749
commit
c97f6376a3
|
@ -266,8 +266,12 @@ class LiaisonModelForm(BetterModelForm):
|
|||
|
||||
def clean_from_contact(self):
|
||||
contact = self.cleaned_data.get('from_contact')
|
||||
from_groups = self.cleaned_data.get('from_groups')
|
||||
try:
|
||||
email = Email.objects.get(address=contact)
|
||||
if not email.origin:
|
||||
email.origin = "liaison: %s" % (','.join([ g.acronym for g in from_groups.all() ]))
|
||||
email.save()
|
||||
except ObjectDoesNotExist:
|
||||
raise forms.ValidationError('Email address does not exist')
|
||||
return email
|
||||
|
@ -500,14 +504,6 @@ class OutgoingLiaisonForm(LiaisonModelForm):
|
|||
if has_role(self.user, "Liaison Manager"):
|
||||
self.fields['to_groups'].initial = [queryset.first()]
|
||||
|
||||
def save(self, commit=False):
|
||||
instance = super(EditModelForm, self).save(commit=False)
|
||||
|
||||
if 'from_contact' in self.changed_data:
|
||||
email = self.cleaned_data.get('from_contact')
|
||||
if not email.origin:
|
||||
email.origin = "liaison: %s" % (','.join([ g.acronym for g in instance.from_groups.all() ]))
|
||||
email.save()
|
||||
|
||||
class EditLiaisonForm(LiaisonModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
Loading…
Reference in a new issue