SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 62322275 authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Remove Contact-types check from PromotionForm

parent 49e2c3a4
No related branches found
No related tags found
No related merge requests found
...@@ -405,32 +405,6 @@ class PromoteToContactFormset(forms.BaseModelFormSet): ...@@ -405,32 +405,6 @@ class PromoteToContactFormset(forms.BaseModelFormSet):
This is a formset to process multiple `PromoteToContactForm`s at the same time This is a formset to process multiple `PromoteToContactForm`s at the same time
designed for the 'promote prospect to partner' action. designed for the 'promote prospect to partner' action.
""" """
def clean(self):
"""
Check if all CONTACT_TYPES are assigned to at least one contact.
"""
contact_type_keys = list(dict(CONTACT_TYPES).keys())
for form in self.forms:
try:
contact_types = form.cleaned_data['contact_types']
except KeyError:
# Form invalid for `contact_types`
continue
for _type in contact_types:
try:
contact_type_keys.remove(_type)
except ValueError:
# Type-key already removed
continue
if not contact_type_keys:
break
if contact_type_keys:
# Add error to all forms if not all CONTACT_TYPES are assigned
for form in self.forms:
form.add_error('contact_types', ("Not all contact types have been"
" divided over the contacts yet."))
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
raise DeprecationWarning(("This formset is not meant to used with the default" raise DeprecationWarning(("This formset is not meant to used with the default"
" `save` method. User the `promote_contacts` instead.")) " `save` method. User the `promote_contacts` instead."))
......
from common.utils import BaseMailUtil from common.utils import BaseMailUtil
class PartnerUtils(BaseMailUtil): class PartnerUtils(BaseMailUtil):
mail_sender = 'partners@scipost.org' mail_sender = 'partners@scipost.org'
mail_sender_title = 'SciPost Supporting Partners' mail_sender_title = 'SciPost Supporting Partners'
...@@ -14,8 +13,8 @@ class PartnerUtils(BaseMailUtil): ...@@ -14,8 +13,8 @@ class PartnerUtils(BaseMailUtil):
and invite participation to the Supporting Partners Board. and invite participation to the Supporting Partners Board.
""" """
cls._send_mail(cls, 'email_prospartner_contact', cls._send_mail(cls, 'email_prospartner_contact',
[cls._context['contact'].email,], [cls._context['contact'].email],
cls._context['email_subject']) cls._context['email_subject'])
@classmethod @classmethod
def email_prospartner_generic(cls): def email_prospartner_generic(cls):
...@@ -24,5 +23,5 @@ class PartnerUtils(BaseMailUtil): ...@@ -24,5 +23,5 @@ class PartnerUtils(BaseMailUtil):
for which no Contact could be defined. for which no Contact could be defined.
""" """
cls._send_mail(cls, 'email_prospartner_contact', cls._send_mail(cls, 'email_prospartner_contact',
[cls._context['email'],], [cls._context['email']],
cls._context['email_subject']) cls._context['email_subject'])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment