Files
modoboa/extensions/limits/lib.py
T
Antoine Nguyen 3681bb4198 wip: resellers and limits
I've finally started to rethink the database structure. The goal I'm trying to reach: only use User objects to manage permissions and accesses to the webui and associate other objects to them if needed (like mailboxes).

see #105
2012-01-20 17:33:05 +01:00

28 lines
653 B
Python

# coding: utf-8
"""
:mod:`lib` --- public functions
-------------------------------
"""
from django.contrib.auth.models import Group
from modoboa.lib.exceptions import ModoboaException
class LimitReached(ModoboaException):
def __init__(self, limit):
self.limit = limit
def __str__(self):
return "%s reached" % self.limit.name
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()