def set_extra_fields(**kwargs): form = kwargs['form'] fields = form.fields organization = helpers.get_current_organization() fields['first_name'] = forms.CharField(label=_('Nom'), max_length=30) fields['last_name'] = forms.CharField(label=_('Cognoms'), max_length=30) if organization.uid_field == 'pid': fields['pid_number'] = forms.RegexField(regex='^[A-Za-z]?[0-9]{7,8}[A-Za-z]$', max_length=10, label=_('DNI'), error_messages={'invalid': _(u'Només pot contenir lletres i números.')}) fields['pid_upload'] = forms.FileField(label=_(u'Còpia del DNI (ambdues cares)')) return kwargs
def clean_extra_fields(form, **kwargs): organization = helpers.get_current_organization() if organization.uid_field == 'pid': if not 'pid_number' in form.cleaned_data: form.add_error('pid_number', _('DNI no vàlid')) return value = re.sub('[^A-Z0-9]', '', form.cleaned_data['pid_number'].upper()) try: PID.objects.get(organization=organization, value=value) form.add_error('pid_number', _(u'DNI ja registrat.')) except PID.DoesNotExist: form.cleaned_data['pid_number'] = value
def __init__(self, host=None, port=None, username=None, password=None, use_tls=None, fail_silently=False, use_ssl=None, timeout=None, ssl_keyfile=None, ssl_certfile=None, **kwargs): kwargs['fail_silently'] = fail_silently organization_ = helpers.get_current_organization() kwargs['host'] = host or organization_.email_host kwargs['password'] = str(password or organization_.email_host_password) kwargs['username'] = username or organization_.email_host_user kwargs['port'] = port or organization_.email_port kwargs['use_ssl'] = use_ssl or organization_.email_use_ssl kwargs['use_tls'] = use_tls or organization_.email_use_tls if ssl_keyfile or ssl_certfile: raise ValueError('SSL keyfile and certificate not supported.') settings.DEFAULT_FROM_EMAIL = organization_.contact super(EmailBackend, self).__init__(**kwargs)
def _send(self, email_message): #if email_message.from_email == 'webmaster@localhost': # email_message.from_email = organization_.contact organization_ = helpers.get_current_organization() email_message.from_email = settings.DEFAULT_FROM_EMAIL = organization_.contact return super(EmailBackend, self)._send(email_message)