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)
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)
def apply_obj(cls, obj): if isinstance(obj, User): return "customergroup" in Group.get_groups(obj) return False
def test_model_group(self): assert_that( Group.get_groups(self.product_C), is_(['group_product_model']))
def test_get_group_by_name(self): assert_that( Group.get_by_name("customergroup"), not_none())
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'))