mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
@@ -6,7 +6,7 @@ from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from modoboa.core.models import User
|
||||
from modoboa.lib import parameters, events
|
||||
from modoboa.lib.exceptions import ModoboaException
|
||||
from modoboa.lib.exceptions import PermDeniedException
|
||||
from modoboa.lib.emailutils import split_mailbox
|
||||
from modoboa.extensions.admin.models import (
|
||||
Domain, Alias
|
||||
@@ -24,7 +24,7 @@ def needs_mailbox():
|
||||
def wrapped_f(request, *args, **kwargs):
|
||||
if request.user.mailbox_set.count():
|
||||
return f(request, *args, **kwargs)
|
||||
raise ModoboaException()
|
||||
raise PermDeniedException(_("A mailbox is required"))
|
||||
return wrapped_f
|
||||
return decorator
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.db import transaction, IntegrityError
|
||||
from django.contrib.auth.decorators import (
|
||||
login_required, permission_required, user_passes_test
|
||||
)
|
||||
from modoboa.lib.exceptions import ModoboaException
|
||||
from modoboa.lib.exceptions import ModoboaException, Conflict
|
||||
from modoboa.core.models import User
|
||||
from modoboa.extensions.admin.models import (
|
||||
Domain, DomainAlias, Alias
|
||||
@@ -118,7 +118,7 @@ def importdata(request, formclass=ImportDataForm):
|
||||
except IntegrityError, e:
|
||||
if form.cleaned_data["continue_if_exists"]:
|
||||
continue
|
||||
raise ModoboaException(_("Object already exists: %s" % row))
|
||||
raise Conflict(_("Object already exists: %s" % row))
|
||||
cpt += 1
|
||||
msg = _("%d objects imported successfully" % cpt)
|
||||
return render(request, "admin/import_done.html", {
|
||||
|
||||
@@ -7,7 +7,7 @@ from functools import wraps
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
from modoboa.lib import parameters
|
||||
from modoboa.lib.exceptions import ModoboaException
|
||||
from modoboa.lib.exceptions import InternalError
|
||||
|
||||
|
||||
def selfservice(ssfunc=None):
|
||||
@@ -50,7 +50,7 @@ class AMrelease(object):
|
||||
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
self.sock.connect(path)
|
||||
except socket.error, err:
|
||||
raise ModoboaException(
|
||||
raise InternalError(
|
||||
_("Connection to amavis failed: %s" % str(err))
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"""
|
||||
from django.utils.translation import ugettext as _
|
||||
from modoboa.lib.exceptions import ModoboaException
|
||||
from .models import LimitsPool
|
||||
from modoboa.extensions.limits.models import LimitsPool
|
||||
|
||||
|
||||
class LimitReached(ModoboaException):
|
||||
@@ -30,7 +30,7 @@ class UnsufficientResource(ModoboaException):
|
||||
|
||||
|
||||
class BadLimitValue(ModoboaException):
|
||||
pass
|
||||
http_code = 400
|
||||
|
||||
|
||||
def inc_limit_usage(user, lname):
|
||||
|
||||
@@ -5,7 +5,7 @@ from django.contrib.auth.decorators import (
|
||||
login_required, user_passes_test, permission_required
|
||||
)
|
||||
from modoboa.lib import events
|
||||
from modoboa.lib.exceptions import ModoboaException, PermDeniedException
|
||||
from modoboa.lib.exceptions import BadRequest, PermDeniedException, NotFound
|
||||
from modoboa.lib.webutils import (
|
||||
_render_to_string, render_to_json_response
|
||||
)
|
||||
@@ -24,7 +24,7 @@ def index(request):
|
||||
deflocation = "graphs/?gset=mailtraffic"
|
||||
if not request.user.is_superuser:
|
||||
if not Domain.objects.get_for_admin(request.user).count():
|
||||
raise ModoboaException(_("No statistics available"))
|
||||
raise NotFound(_("No statistics available"))
|
||||
|
||||
period = request.GET.get("period", "day")
|
||||
graph_sets = events.raiseDictEvent('GetGraphSets')
|
||||
@@ -43,7 +43,7 @@ def graphs(request):
|
||||
gset = request.GET.get("gset", None)
|
||||
gsets = events.raiseDictEvent("GetGraphSets")
|
||||
if not gset in gsets:
|
||||
raise ModoboaException(_("Unknown graphic set"))
|
||||
raise NotFound(_("Unknown graphic set"))
|
||||
searchq = request.GET.get("searchquery", None)
|
||||
period = request.GET.get("period", "day")
|
||||
tplvars = dict(graphs=[], period=period)
|
||||
@@ -66,7 +66,7 @@ def graphs(request):
|
||||
|
||||
if period == "custom":
|
||||
if not "start" in request.GET or not "end" in request.GET:
|
||||
raise ModoboaException(_("Bad custom period"))
|
||||
raise BadRequest(_("Bad custom period"))
|
||||
start = request.GET["start"]
|
||||
end = request.GET["end"]
|
||||
G = Grapher()
|
||||
|
||||
Reference in New Issue
Block a user