Esempio n. 1
0
    def setUp(self):
        super(LimitsTestCase, self).setUp()
        from modoboa.extensions.limits.models import LimitTemplates

        for tpl in LimitTemplates().templates:
            parameters.save_admin('DEFLT_%s' % tpl[0].upper(), 2, app='limits')
        self.user = UserFactory.create(username='******',
                                       groups=('Resellers', ))
        self.clt.logout()
        self.clt.login(username='******', password='******')
Esempio n. 2
0
    def setUp(self):
        """Custom setUp method.

        The 'limits' is manually loaded to ensure extra parameters
        provided by 'postfix_relay_domains' are properly received.
        """
        super(ResourceTestCase, self).setUp()
        for tpl in LimitTemplates().templates:
            parameters.save_admin('DEFLT_%s' % tpl[0].upper(), 2, app='limits')
        populate_database()
Esempio n. 3
0
def display_pool_usage(user, target, currentpage):
    from django.template.loader import render_to_string

    if target != "leftcol" or user.is_superuser:
        return []
    if currentpage == "identities":
        names = ["mailboxes_limit", "mailbox_aliases_limit"]
        if user.has_perm("admin.add_domain"):
            names += ["domain_admins_limit"]
    else:
        names = [
            tpl[0] for tpl in LimitTemplates().templates if tpl[0] not in [
                "domain_admins_limit", "mailboxes_limit",
                "mailbox_aliases_limit"
            ] and (len(tpl) == 3 or tpl[3] == user.group)
        ]

    limits = user.limitspool.limit_set.filter(name__in=names, maxvalue__gt=0)
    if len(limits) == 0:
        return []
    return [render_to_string("limits/poolusage.html", dict(limits=limits))]