This commit is contained in:
parent
6439203900
commit
b1caed65f5
6 changed files with 36 additions and 14 deletions
|
@ -73,7 +73,7 @@ class Index extends App.ControllerSubContent
|
|||
user_group_config = false
|
||||
|
||||
groups = []
|
||||
group_ids = App.User.find(@Session.get('id')).all_group_ids()
|
||||
group_ids = App.User.find(@Session.get('id')).allGroupIds()
|
||||
if group_ids
|
||||
for group_id in group_ids
|
||||
group = App.Group.find(group_id)
|
||||
|
|
|
@ -1222,9 +1222,9 @@ class Table extends App.Controller
|
|||
ticket_ids = _.map(items, (el) -> $(el).val() )
|
||||
ticket_group_ids = _.map(App.Ticket.findAll(ticket_ids), (ticket) -> ticket.group_id)
|
||||
ticket_group_ids = _.uniq(ticket_group_ids)
|
||||
user_permissions = App.Session.get('group_ids')
|
||||
group_permissions = ticket_group_ids.map (id) -> user_permissions[id]
|
||||
_.every(group_permissions, (list) -> 'full' in list || 'change' in list)
|
||||
allowed_group_ids = App.User.find(@Session.get('id')).allGroupIds('change')
|
||||
allowed_group_ids = _.map(allowed_group_ids, (id_string) -> parseInt(id_string, 10) )
|
||||
_.every(ticket_group_ids, (id) -> id in allowed_group_ids)
|
||||
|
||||
viewmode: (e) =>
|
||||
e.preventDefault()
|
||||
|
|
|
@ -249,7 +249,7 @@ class App.Ticket extends App.Model
|
|||
user_id = App.Session.get('id')
|
||||
return true if user_id is @customer_id
|
||||
return false if !App.User.exists(user_id)
|
||||
group_ids = App.User.find(user_id).all_group_ids(permission)
|
||||
group_ids = App.User.find(user_id).allGroupIds(permission)
|
||||
for local_group_id in group_ids
|
||||
if local_group_id.toString() is @group_id.toString()
|
||||
return true
|
||||
|
|
|
@ -254,7 +254,19 @@ class App.User extends App.Model
|
|||
return access if access
|
||||
false
|
||||
|
||||
all_group_ids: (permission = 'full') ->
|
||||
###
|
||||
|
||||
Returns a list of all groups for which the user is permitted to perform the given permission key
|
||||
|
||||
user = App.User.find(3)
|
||||
result = user.allGroupIds('change') # access to a given permission key
|
||||
|
||||
returns
|
||||
|
||||
["1", "2"]
|
||||
|
||||
###
|
||||
allGroupIds: (permission = 'full') ->
|
||||
group_ids = []
|
||||
user_group_ids = App.Session.get('group_ids')
|
||||
if user_group_ids
|
||||
|
|
|
@ -485,11 +485,12 @@ class AgentTicketOverviewLevel0Test < TestCase
|
|||
},
|
||||
)
|
||||
|
||||
click(
|
||||
css: 'a[href="#manage"]',
|
||||
)
|
||||
click(
|
||||
css: '.content.active a[href="#manage/groups"]',
|
||||
role_edit(
|
||||
data: {
|
||||
name: 'Agent',
|
||||
group_permissions: { 2 => ['full'],
|
||||
3 => ['full'], }
|
||||
},
|
||||
)
|
||||
|
||||
user_edit(
|
||||
|
@ -508,9 +509,7 @@ class AgentTicketOverviewLevel0Test < TestCase
|
|||
email: 'agent2@example.com',
|
||||
password: 'test',
|
||||
role: 'Agent',
|
||||
permissions: { 1 => %w[read create overview],
|
||||
2 => ['full'],
|
||||
3 => ['full'], }
|
||||
permissions: { 1 => %w[read create overview] }
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -3816,6 +3816,17 @@ wait untill text in selector disabppears
|
|||
end
|
||||
end
|
||||
|
||||
if data.key?(:group_permissions)
|
||||
data[:group_permissions].each do |key, value|
|
||||
value.each do |permission|
|
||||
check(
|
||||
browser: instance,
|
||||
css: ".modal input[name=\"group_ids::#{key}\"][value=\"#{permission}\"]",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if data.key?(:active)
|
||||
element = instance.find_elements(css: '.modal select[name="active"]')[0]
|
||||
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
||||
|
|
Loading…
Reference in a new issue