mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 02:24:26 +00:00
Only begining of the mail is now needed
This commit is contained in:
parent
ce9e17ea24
commit
fe187dae38
@ -232,7 +232,7 @@ class Mailing(models.Model):
|
|||||||
email = models.EmailField(_('Email address'), unique=True)
|
email = models.EmailField(_('Email address'), unique=True)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if '@' + settings.SITH_MAILING_ALLOWED_DOMAIN not in self.email:
|
if '@' + settings.SITH_MAILING_DOMAIN not in self.email:
|
||||||
raise ValidationError(_('Unothorized mailing domain'))
|
raise ValidationError(_('Unothorized mailing domain'))
|
||||||
super(Mailing, self).clean()
|
super(Mailing, self).clean()
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ from django.utils.translation import ugettext as _t
|
|||||||
from ajax_select.fields import AutoCompleteSelectField
|
from ajax_select.fields import AutoCompleteSelectField
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.core.validators import RegexValidator, validate_email
|
||||||
|
|
||||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin
|
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin
|
||||||
from core.views.forms import SelectDate, SelectDateTime
|
from core.views.forms import SelectDate, SelectDateTime
|
||||||
@ -53,6 +54,16 @@ class MailingForm(forms.ModelForm):
|
|||||||
model = Mailing
|
model = Mailing
|
||||||
fields = ('email', 'club')
|
fields = ('email', 'club')
|
||||||
|
|
||||||
|
email = forms.CharField(
|
||||||
|
label=_('Email address'),
|
||||||
|
validators=[
|
||||||
|
RegexValidator(
|
||||||
|
validate_email.user_regex,
|
||||||
|
_('Enter a valid address. Only the root of the address is needed.')
|
||||||
|
)
|
||||||
|
],
|
||||||
|
required=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
club_id = kwargs.pop('club_id', None)
|
club_id = kwargs.pop('club_id', None)
|
||||||
super(MailingForm, self).__init__(*args, **kwargs)
|
super(MailingForm, self).__init__(*args, **kwargs)
|
||||||
@ -61,6 +72,12 @@ class MailingForm(forms.ModelForm):
|
|||||||
self.fields['club'].initial = club_id
|
self.fields['club'].initial = club_id
|
||||||
self.fields['club'].widget = forms.HiddenInput()
|
self.fields['club'].widget = forms.HiddenInput()
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
cleaned_data = super(MailingForm, self).clean()
|
||||||
|
if self.is_valid():
|
||||||
|
cleaned_data['email'] += '@' + settings.SITH_MAILING_DOMAIN
|
||||||
|
return cleaned_data
|
||||||
|
|
||||||
|
|
||||||
class MailingSubscriptionForm(forms.ModelForm):
|
class MailingSubscriptionForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -562,7 +562,7 @@ SITH_QUICK_NOTIF = {
|
|||||||
|
|
||||||
# Mailing related settings
|
# Mailing related settings
|
||||||
|
|
||||||
SITH_MAILING_ALLOWED_DOMAIN = 'utbm.fr'
|
SITH_MAILING_DOMAIN = 'utbm.fr'
|
||||||
SITH_MAILING_FETCH_KEY = 'IloveMails'
|
SITH_MAILING_FETCH_KEY = 'IloveMails'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user