Commit 9a6bf3c266b72fbbd99d82896e3e37529d5db5c2
Exists in
master
and in
26 other branches
Merge branch 'fix_custom_roles_management' into 'master'
Fix custom roles management This patch updates the schema to add profile_id on roles table and fix the broken custom role creation and task management. See merge request !570
Showing
3 changed files
with
4 additions
and
2 deletions
Show diff stats
app/controllers/my_profile/profile_roles_controller.rb
... | ... | @@ -11,8 +11,9 @@ class ProfileRolesController < MyProfileController |
11 | 11 | end |
12 | 12 | |
13 | 13 | def create |
14 | - @role = Role.create({:name => params[:role][:name], :permissions => params[:role][:permissions], :profile_id => profile.id, :environment => environment }, :without_protection => true) | |
14 | + @role = Role.new({:name => params[:role][:name], :permissions => params[:role][:permissions], :environment => environment }, :without_protection => true) | |
15 | 15 | if @role.save |
16 | + profile.custom_roles << @role | |
16 | 17 | redirect_to :action => 'show', :id => @role |
17 | 18 | else |
18 | 19 | session[:notice] = _('Failed to create role') | ... | ... |
app/views/tasks/_add_member_accept_details.html.erb
1 | 1 | <%= content = _("Roles:")+"<br />" |
2 | -roles = Profile::Roles.organization_all_roles(task.target.environment.id) | |
2 | +roles = Profile::Roles.organization_member_roles(task.target.environment.id) + profile.custom_roles | |
3 | 3 | roles.each do |role| |
4 | 4 | content += labelled_check_box(role.name, "tasks[#{task.id}][task][roles][]", role.id, false)+"<br />" |
5 | 5 | end | ... | ... |
db/schema.rb
... | ... | @@ -593,6 +593,7 @@ ActiveRecord::Schema.define(:version => 20150408231524) do |
593 | 593 | t.boolean "system", :default => false |
594 | 594 | t.text "permissions" |
595 | 595 | t.integer "environment_id" |
596 | + t.integer "profile_id" | |
596 | 597 | end |
597 | 598 | |
598 | 599 | create_table "scraps", :force => true do |t| | ... | ... |