Beispiel #1
0
def create_group_model(sender, **kwargs):
    logging.debug("Receive prepared signal for %s", sender)
    if isinstance(sender, type):
        class_name = get_model_group_name(sender.__name__)
        if not Group.get_by_name(class_name):
            group = create_group_class(sender)
            Group.register(group)
            logger.info("Creating and registering automatic group %s", class_name)
Beispiel #2
0
 def save(self, *args, **kwargs):
     from rules_engine.rules import Group, Rule
     if self.group not in Group.get_group_names() and self.group:
         print "Group ID", id(Group)
         raise ValueError("Group %s has not been registered" % self.group)
     if self.rule not in Rule.get_rule_names() and self.rule:
         print "Rule ID", id(Rule)
         raise ValueError("Rule %s has not been registered" % self.rule)
     super(ACL, self).save(*args, **kwargs)
Beispiel #3
0
 def apply_obj(cls, obj):
     if isinstance(obj, User):
        return "customergroup" in Group.get_groups(obj)
     return False
Beispiel #4
0
 def test_model_group(self):
    assert_that( Group.get_groups(self.product_C), is_(['group_product_model']))
Beispiel #5
0
 def test_get_group_by_name(self):
    assert_that( Group.get_by_name("customergroup"), not_none())
Beispiel #6
0
 def test_get_group(self):
     assert_that( Group.get_groups(self.customer), has_item('customergroup'))
     assert_that( Group.get_groups(self.admin), has_item('admingroup'))