Esempio n. 1
0
def domain_new(request):
    form_initial = {'site': Site.objects.get_current(request)}
    if request.method == 'POST':
        form = DomainForm(request.POST, initial=form_initial)
        if form.is_valid():
            domain = Domain(mail_host=form.cleaned_data['mail_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"))
            MailDomain.objects.get_or_create(
                site=form.cleaned_data['site'],
                mail_domain=form.cleaned_data['mail_host'])
            return redirect("domain_index")
        else:
            messages.error(request, _('Please check the errors below'))
    else:
        form = DomainForm(initial=form_initial)
    return render(request, 'postorius/domain/new.html', {'form': form})
Esempio n. 2
0
def domain_new(request):
    message = None
    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'])
            try:
                domain.save()
            except MailmanApiError:
                return utils.render_api_error(request)
            except HTTPError, e:
                messages.error(request, e)
            else:
                messages.success(request, _("New Domain registered"))
            return redirect("domain_index")
Esempio n. 3
0
def domain_new(request):
    message = None
    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, e:
                messages.error(request, e)
            else:
                messages.success(request, _("New Domain registered"))
            return redirect("domain_index")
Esempio n. 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})