Commit fbddca0a authored by root's avatar root

fix: edit mail dn search

parent 54addef3
......@@ -415,8 +415,8 @@ class EditEmailForm(GenericForm):
"correos entrantes en tu cuenta actual "
"también tendrás que incluirla en el listado.")
givenName = forms.CharField(label=_('Nombre'), required=False)
sn = forms.CharField(label=_('Apellidos'), required=False)
givenName = forms.CharField(label=_('Nombre'), required=True)
sn = forms.CharField(label=_('Apellidos'), required=True)
password = forms.CharField(label=_('Contraseña'), widget=forms.PasswordInput(),
required=False)
password_2 = forms.CharField(label=_('Vuelve a introducir la contraseña'),
......@@ -441,7 +441,11 @@ class EditEmailForm(GenericForm):
raise forms.ValidationError(
_("Parece que uno de los correos que has introducido no es válido.")
)
forward_active = self.cleaned_data.get("forwardActive")
if (forward_active and not maildrop):
raise forms.ValidationError(
_("Si activas el reenvío automático tienes que insertar almenos una cuenta de destino.")
)
def __init__(self, *args, **kwargs):
super(EditEmailForm,self).__init__(*args, **kwargs)
......@@ -584,8 +588,8 @@ class SuperuserForm(GenericForm):
""" Form to edit superuser account """
username = forms.CharField(label=_('Nombre de usuario no editable (Para autenticación SFTP/SSH)'), required=True)
name = forms.CharField(label=_('Nombre'), required=False)
surname = forms.CharField(label=_('Apellidos'), required=False)
name = forms.CharField(label=_('Nombre'), required=True)
surname = forms.CharField(label=_('Apellidos'), required=True)
email = forms.EmailField(label=_('Correo electrónico'), required=True,
help_text=_("Introduce un correo electrónico válido. "
"Este campo se autocompletará con correos existentes en el sistema. "
......
......@@ -165,20 +165,26 @@ class MailAccount(FormView):
def get_form_kwargs(self):
"""Return the keyword arguments for instantiating the form."""
kwargs = super().get_form_kwargs()
account = self.request.ldap.entries[0]
kwargs['initial'] = { k : utils.ldap_val(account[k].value) for k in self.ldap_attributes }
return kwargs
try:
account = self.request.ldap.entries[0]
kwargs['initial'] = { k : utils.ldap_val(account[k].value) for k in self.ldap_attributes }
return kwargs
except Exception as e:
messages.error(self.request, _('La cuenta de correo %s no existe' % self.mail_account))
def get_form(self):
"""Return an instance of the form to be used in this view."""
domain = self.mail_account.split('@')[1]
dn='mail=%s,vd=%s,%s' % (self.mail_account,domain,settings.LDAP_TREE_HOSTING)
try:
self.request.ldap.search(
settings.LDAP_TREE_BASE,
'(mail=%s)' % self.mail_account,
dn,
'(objectClass=VirtualMailAccount)',
attributes = self.ldap_attributes
)
except Exception as e:
print(e)
messages.error(self.request, _('La cuenta de correo %s no existe' % self.mail_account))
return EditEmailForm(**self.get_form_kwargs())
def form_valid(self, form):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment