diff --git a/config.py b/config.py index 45ac71b..e24b1f7 100644 --- a/config.py +++ b/config.py @@ -25,6 +25,7 @@ INSTALLED_APPS.extend([ 'anymail', 'ivatar', 'ivatar.ivataraccount', + 'ivatar.tools', ]) from ivatar.settings import MIDDLEWARE # noqa diff --git a/ivatar/tools/forms.py b/ivatar/tools/forms.py new file mode 100644 index 0000000..f09ed12 --- /dev/null +++ b/ivatar/tools/forms.py @@ -0,0 +1,64 @@ +''' +Classes for our ivatar.tools.forms +''' +from django import forms +from django.utils.translation import ugettext_lazy as _ +from django.core.exceptions import ValidationError + + +class CheckDomainForm(forms.Form): + ''' + Form handling domain check + ''' + can_distribute = forms.TextInput( + attrs={ + 'label': _('Domain'), + 'required': True, + 'error_messages': { + 'required': + _('Cannot check without a domain name.') + } + } + ) + + +class CheckForm(forms.Form): + ''' + Form handling check + ''' + mail = forms.EmailField( + label=_('E-Mail'), + required=False, + error_messages={ + 'required': + _('Cannot check without a domain name.') + }) + + openid = forms.CharField( + label=_('OpenID'), + required=False, + error_messages={ + 'required': + _('Cannot check without an openid name.') + }) + + size = forms.IntegerField( + label=_('Size'), + initial=80, + min_value=10, + max_value=160, + required=True, + ) + + default_url = forms.URLField( + label=_('Default URL'), + required=False, + ) + + def clean(self): + self.cleaned_data = super().clean() + mail = self.cleaned_data.get('mail') + openid = self.cleaned_data.get('openid') + if not mail and not openid: + raise ValidationError(_('Either OpenID or mail must be specified')) + return self.cleaned_data diff --git a/ivatar/tools/templates/check.html b/ivatar/tools/templates/check.html new file mode 100644 index 0000000..5541b96 --- /dev/null +++ b/ivatar/tools/templates/check.html @@ -0,0 +1,21 @@ +{% extends 'base.html' %} +{% load i18n %} +{% load bootstrap4 %} + +{% block title %}{% trans 'Check e-mail or openid' %}{% endblock title %} + +{% block content %} + +