コード例 #1
0
ファイル: views.py プロジェクト: a740122/pcp
def delete_domain(request):
    user = request.session.get('switched_user', request.user)
    superuser = request.user

    domain = user.email_domain_set.get(id=request.GET.get("domain_pk"))
    backend = EmailBackend()
    backend.uninstall_domain(domain)
    backend.commit()
    domain.delete()

    messages.add_message(request, messages.INFO, _('Domain and it\'s mailboxes has been deleted.'))

    return HttpResponseRedirect(reverse("mailbox_list"))
コード例 #2
0
def delete_domain(request):
    user = request.session.get('switched_user', request.user)
    superuser = request.user

    domain = user.email_domain_set.get(id=request.GET.get("domain_pk"))
    backend = EmailBackend()
    backend.uninstall_domain(domain)
    backend.commit()
    domain.delete()

    messages.add_message(request, messages.INFO,
                         _('Domain and it\'s mailboxes has been deleted.'))

    return HttpResponseRedirect(reverse("mailbox_list"))
コード例 #3
0
ファイル: views.py プロジェクト: a740122/pcp
def mailbox_remove(request):
    object_id = request.GET['pk']
    u = request.session.get('switched_user', request.user)

    try:
        mail = Email.objects.get(domain__in=u.email_domain_set.all(), id=object_id)
    except EmailRedirect.DoesNotExist:
        raise Exception("redirect doesn't exist, obviously")

    backend = EmailBackend()
    backend.uninstall(mail)
    backend.commit()
    mail.delete()

    messages.add_message(request, messages.SUCCESS, _('E-mail has been added'))

    return HttpResponseRedirect(reverse("mailbox_list"))
コード例 #4
0
def mailbox_remove(request):
    object_id = request.GET['pk']
    u = request.session.get('switched_user', request.user)

    try:
        mail = Email.objects.get(domain__in=u.email_domain_set.all(),
                                 id=object_id)
    except EmailRedirect.DoesNotExist:
        raise Exception("redirect doesn't exist, obviously")

    backend = EmailBackend()
    backend.uninstall(mail)
    backend.commit()
    mail.delete()

    messages.add_message(request, messages.SUCCESS, _('E-mail has been added'))

    return HttpResponseRedirect(reverse("mailbox_list"))
コード例 #5
0
ファイル: views.py プロジェクト: a740122/pcp
def addBox(request):
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    domains = [(x.name, x.name) for x in u.email_domain_set.all()]

    if request.method == 'POST':
        form = FormEmail(request.POST)
        form.fields["xdomain"].choices = domains

        if form.is_valid():
            form.cleaned_data["xdomain"] = get_object_or_404(u.email_domain_set, name=
            form.cleaned_data["xdomain"])
            email = form.save(commit=False)
            email.login = form.cleaned_data["login"]
            email.domain = form.cleaned_data["xdomain"]
            email.password = crypt.crypt(form.cleaned_data["password1"],
                                         form.cleaned_data["login"]*2)
            email.save()

            backend = EmailBackend()
            backend.install(email)
            backend.commit()

            messages.add_message(request, messages.INFO, _('Box will be created in few minutes'))
            return HttpResponseRedirect(reverse("mailbox_list"))
    else:
        form = FormEmail()
        form.fields["xdomain"].choices = domains

    helper = RostiFormHelper()

    return render_to_response('universal.html',
            {
            "form": form,
            "form_helper": helper,
            "title": _("New e-mail"),
            "submit": _("Create box"),
            "u": u,
            "superuser": superuser,
            "menu_active": "emails",
            },
        context_instance=RequestContext(request)
    )
コード例 #6
0
def addBox(request):
    u = request.session.get('switched_user', request.user)
    superuser = request.user

    domains = [(x.name, x.name) for x in u.email_domain_set.all()]

    if request.method == 'POST':
        form = FormEmail(request.POST)
        form.fields["xdomain"].choices = domains

        if form.is_valid():
            form.cleaned_data["xdomain"] = get_object_or_404(
                u.email_domain_set, name=form.cleaned_data["xdomain"])
            email = form.save(commit=False)
            email.login = form.cleaned_data["login"]
            email.domain = form.cleaned_data["xdomain"]
            email.password = crypt.crypt(form.cleaned_data["password1"],
                                         form.cleaned_data["login"])
            email.save()

            backend = EmailBackend()
            backend.install(email)
            backend.commit()

            messages.add_message(request, messages.INFO,
                                 _('Box will be created in few minutes'))
            return HttpResponseRedirect(reverse("mailbox_list"))
    else:
        form = FormEmail()
        form.fields["xdomain"].choices = domains

    helper = RostiFormHelper()

    return render_to_response('universal.html', {
        "form": form,
        "form_helper": helper,
        "title": _("New e-mail"),
        "submit": _("Create box"),
        "u": u,
        "superuser": superuser,
        "menu_active": "emails",
    },
                              context_instance=RequestContext(request))