improve & fix permissions forms

This commit is contained in:
Élie Bouttier 2014-09-02 21:58:49 -07:00
parent be02d3657d
commit 90a3e749e5
2 changed files with 13 additions and 7 deletions

View file

@ -26,6 +26,9 @@ class ProjectPermissionField(PermissionField):
@python_2_unicode_compatible
class PermissionModel(models.Model):
class Meta:
abstract = True
GRANTEE_USER = 0
GRANTEE_GROUP = 1
GRANTEE_TEAM = 2
@ -37,7 +40,7 @@ class PermissionModel(models.Model):
grantee_type = models.IntegerField(choices=GRANTEE_TYPE,
default=GRANTEE_USER, verbose_name="Grantee type")
grantee_id = models.IntegerField(blank=True)
grantee_id = models.IntegerField()
def get_grantee(self):
if self.grantee_type == self.GRANTEE_USER:
@ -62,9 +65,6 @@ class PermissionModel(models.Model):
grantee = property(get_grantee, set_grantee)
class Meta:
abstract = True
def granted_to(self, user):
if not user.is_authenticated():
return False