mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-22 06:28:41 +02:00
* New events * Updated events API * New models to implement limits (more flexible)
25 lines
546 B
Python
25 lines
546 B
Python
# coding: utf-8
|
|
"""
|
|
:mod:`lib` --- public functions
|
|
-------------------------------
|
|
|
|
"""
|
|
|
|
from django.contrib.auth.models import Group
|
|
|
|
class LimitReached(Exception):
|
|
def __init__(self, limit):
|
|
self.limit = limit
|
|
|
|
def __str__(self):
|
|
return "%s reached" % self.limit.name
|
|
|
|
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()
|