Files
modoboa/extensions/limits/lib.py
T
Antoine Nguyen 14268578ba wip: UI refactoring
* translation files update
* various fixes

see #204
2012-04-25 16:45:01 +02:00

36 lines
885 B
Python

# coding: utf-8
"""
:mod:`lib` --- public functions
-------------------------------
"""
from django.contrib.auth.models import Group
from django.utils.translation import ugettext as _
from modoboa.lib.exceptions import ModoboaException
class LimitReached(ModoboaException):
def __init__(self, limit):
self.limit = limit
def __str__(self):
return _("%s: limit reached") % self.limit.label
class UnsifficientResource(ModoboaException):
def __init__(self, limit):
self.limit = limit
def __str__(self):
return _("Not enough resources")
class BadLimitValue(ModoboaException):
pass
def is_reseller(user):
"""Tell if a user is a reseller or not
:param user: a User object
:return: True if the user is a reseller, False otherwise.
"""
grp = Group.objects.get(name="Resellers")
return grp in user.groups.all()