permissions for groups, scripts, productions
This commit is contained in:
parent
e39b9b26ad
commit
d4a9605c85
|
@ -336,6 +336,22 @@ class TheatreGroup(ItfModel):
|
|||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
def user_has_perms(self, user):
|
||||
from app.models import ItfModel
|
||||
if ItfModel.user_has_perms(self, user):
|
||||
return True
|
||||
else:
|
||||
if self.is_user_admin(user):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_user_admin(self, user):
|
||||
for pg in self.persongroup_set.all():
|
||||
if user.id == pg.person.user_id and pg.is_admin == True:
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_dict(self):
|
||||
return {
|
||||
#'object':self,
|
||||
|
@ -414,6 +430,11 @@ class Production(ItfModel):
|
|||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
def user_has_perms(self, user):
|
||||
if self.added_by_id == user.id:
|
||||
return True
|
||||
return self.group.user_has_perms(user)
|
||||
|
||||
def get_people(self):
|
||||
persons = [{"person":self.director, "role":"director", "assoc_type":'production', "assoc_name":self.name },
|
||||
{"person":self.playwright, "role":"playwright", "assoc_type":'production', "assoc_name":self.name }
|
||||
|
|
|
@ -56,6 +56,11 @@ class Script(ItfModel):
|
|||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
def user_has_perms(self, user):
|
||||
if self.added_by_id == user.id:
|
||||
return True
|
||||
return self.theatre_group.user_has_perms(user)
|
||||
|
||||
def list_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
|
|
Loading…
Reference in New Issue
Block a user