Extended editable() method to parse requested permission type as argument.

This commit is contained in:
Martin Edenhofer 2018-01-31 10:26:41 +01:00
parent 3ad13472d8
commit 789afc592a

View file

@ -245,18 +245,18 @@ class App.Ticket extends App.Model
result result
editable: -> editable: (permission = 'change') ->
user_id = App.Session.get('id') user_id = App.Session.get('id')
return true if user_id is @customer_id return true if user_id is @customer_id
group_ids = App.Session.get('group_ids') group_ids = App.Session.get('group_ids')
if group_ids if group_ids
return true if group_ids[@group_id] && (_.include(group_ids[@group_id], 'change') || _.include(group_ids[@group_id], 'full')) return true if group_ids[@group_id] && (_.include(group_ids[@group_id], permission) || _.include(group_ids[@group_id], 'full'))
role_ids = App.Session.get('role_ids') role_ids = App.Session.get('role_ids')
if role_ids if role_ids
for role_id in role_ids for role_id in role_ids
if App.Role.exists(role_id) if App.Role.exists(role_id)
role = App.Role.find(role_id) role = App.Role.find(role_id)
if role.group_ids if role.group_ids
return true if role.group_ids[@group_id] && (_.include(role.group_ids[@group_id], 'change') || _.include(role.group_ids[@group_id], 'full')) return true if role.group_ids[@group_id] && (_.include(role.group_ids[@group_id], permission) || _.include(role.group_ids[@group_id], 'full'))
false false