예제 #1
0
def create_permission(instance):
    content_type = ContentType.objects.get_for_model(instance)
    for acltype in ACLType.availables():
        codename = "%s.%s" % (instance.id, acltype.id)
        Permission(name=acltype.name,
                   codename=codename,
                   content_type=content_type).save()
예제 #2
0
파일: models.py 프로젝트: syucream/airone
    def save(self, *args, **kwargs):
        super(ACLBase, self).save(*args, **kwargs)

        # create Permission sets for this object at once
        content_type = ContentType.objects.get_for_model(self)
        for acltype in ACLType.availables():
            codename = '%s.%s' % (self.id, acltype.id)
            if not Permission.objects.filter(codename=codename).exists():
                Permission(name=acltype.name,
                           codename=codename,
                           content_type=content_type).save()