From: Jan Szejko Date: Fri, 20 Jan 2017 15:13:29 +0000 (+0100) Subject: don't notify when editing existing organizations X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/02d8ce2efb84683b087b102087d125d5b3d293ca don't notify when editing existing organizations --- diff --git a/apps/organizations/forms.py b/apps/organizations/forms.py index 55807663..16a8207e 100644 --- a/apps/organizations/forms.py +++ b/apps/organizations/forms.py @@ -18,11 +18,13 @@ class OrganizationForm(forms.ModelForm): exclude = ['_html'] def save(self, commit=True): + new = self.instance.id is None organization = super(OrganizationForm, self).save(commit=commit) - site = Site.objects.get_current() - send_notify_email( - 'New organization in MIL/PEER', - '''New organization in MIL/PEER: %s. View their profile: https://%s%s. + if new: + site = Site.objects.get_current() + send_notify_email( + 'New organization in MIL/PEER', + '''New organization in MIL/PEER: %s. View their profile: https://%s%s. -- MIL/PEER team.''' % (organization.name, site.domain, organization.get_absolute_url()))