Example #1
0
 def test_form_fields_webhost_invalid(self):
     form = DomainNew({
         'mail_host': 'mailman.most-desirable.org',
         'web_host': 'mailman.most-desirable.org',
         'description': 'The Most Desirable organization',
         'contact_address': '*****@*****.**',
     })
     self.assertFalse(form.is_valid())
Example #2
0
 def test_form_fields_webhost_invalid(self):
     form = DomainNew(
         {
             "mail_host": "mailman.most-desirable.org",
             "web_host": "mailman.most-desirable.org",
             "description": "The Most Desirable organization",
             "contact_address": "*****@*****.**",
         }
     )
     self.assertFalse(form.is_valid())
Example #3
0
 def test_form_fields_webhost_invalid(self):
     form = DomainNew({
         'mail_host':
         'mailman.most-desirable.org',
         'web_host':
         'mailman.most-desirable.org',
         'description':
         'The Most Desirable organization',
         'contact_address':
         '*****@*****.**',
     })
     self.assertFalse(form.is_valid())
Example #4
0
def domain_new(request):
    if request.method == 'POST':
        form = DomainNew(request.POST)
        if form.is_valid():
            domain = Domain(mail_host=form.cleaned_data['mail_host'],
                            base_url=form.cleaned_data['web_host'],
                            description=form.cleaned_data['description'],
                            owner=request.user.email)
            try:
                domain.save()
            except MailmanApiError:
                return utils.render_api_error(request)
            except HTTPError as e:
                messages.error(request, e)
            else:
                messages.success(request, _("New Domain registered"))
            return redirect("domain_index")
        else:
            messages.error(request, _('Please check the errors below'))
    else:
        form = DomainNew()
    return render(request, 'postorius/domain/new.html', {'form': form})