acl/models.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
#from acl.manager import AclManager
from django.contrib.contenttypes import generic
class Acl(models.Model):
aco_id = models.PositiveIntegerField()
aco_ct = models.ForeignKey(ContentType, related_name='acos')
aco = generic.GenericForeignKey(fk_field='aco_id', ct_field='aco_ct')
aro_id = models.PositiveIntegerField()
aro_ct = models.ForeignKey(ContentType, related_name='aros')
aco = generic.GenericForeignKey(fk_field='aro_id', ct_field='aro_ct')
perm = models.CharField(maxlength=30)
allowed = models.BooleanField(blank=True, default=True)
def __unicode__(self):
return '%s --> %s: %s' % (self.aro, self.aco, self.allowed)
class AclGroup(models.Model):
name = models.CharField(maxlength=30)
users = models.ManyToManyField(User, blank=True, null=True)
acl = generic.GenericRelation(Acl, object_id_field='aro_id', content_type_field='aro_ct')
def __unicode__(self):
return name
#class AclManger
#objects = AclManager()
#class Admin:
#list_display = ('perm','user','allowed')
#def save(self):
#super(Acl,self).save()
import acl.signals