Skip to content

Commit c97f637

Browse files
committed
Simplified the email.origin assignment code for outgoing liaisons.
- Legacy-Id: 15176
1 parent 2fd1f81 commit c97f637

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

ietf/liaisons/forms.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,12 @@ def clean_to_groups(self):
266266

267267
def clean_from_contact(self):
268268
contact = self.cleaned_data.get('from_contact')
269+
from_groups = self.cleaned_data.get('from_groups')
269270
try:
270271
email = Email.objects.get(address=contact)
272+
if not email.origin:
273+
email.origin = "liaison: %s" % (','.join([ g.acronym for g in from_groups.all() ]))
274+
email.save()
271275
except ObjectDoesNotExist:
272276
raise forms.ValidationError('Email address does not exist')
273277
return email
@@ -500,14 +504,6 @@ def set_to_fields(self):
500504
if has_role(self.user, "Liaison Manager"):
501505
self.fields['to_groups'].initial = [queryset.first()]
502506

503-
def save(self, commit=False):
504-
instance = super(EditModelForm, self).save(commit=False)
505-
506-
if 'from_contact' in self.changed_data:
507-
email = self.cleaned_data.get('from_contact')
508-
if not email.origin:
509-
email.origin = "liaison: %s" % (','.join([ g.acronym for g in instance.from_groups.all() ]))
510-
email.save()
511507

512508
class EditLiaisonForm(LiaisonModelForm):
513509
def __init__(self, *args, **kwargs):

0 commit comments

Comments
 (0)