diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index 15bf5e2b..e4b83241 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -15,7 +15,7 @@ module Admin def show @url = if @track - toggle_user_track_admin_conference_role_path(@conference.short_title, @role.name, @track.name.tr(' ', '_')) + toggle_user_track_admin_conference_role_path(@conference.short_title, @role.name, @track) else toggle_user_admin_conference_role_path(@conference.short_title, @role.name) end @@ -24,7 +24,7 @@ module Admin def edit @url = if @track - track_admin_conference_role_path(@conference.short_title, @role.name, @track.name.tr(' ', '_')) + track_admin_conference_role_path(@conference.short_title, @role.name, @track) else admin_conference_role_path(@conference.short_title, @role.name) end @@ -36,7 +36,7 @@ module Admin if @role.update_attributes(role_params) url = if @track - track_admin_conference_role_path(@conference.short_title, @role.name, @track.name.tr(' ', '_')) + track_admin_conference_role_path(@conference.short_title, @role.name, @track) else admin_conference_role_path(@conference.short_title, @role.name) end @@ -55,7 +55,7 @@ module Admin state = user_params[:state] url = if @track - track_admin_conference_role_path(@conference.short_title, @role.name, @track.name.tr(' ', '_')) + track_admin_conference_role_path(@conference.short_title, @role.name, @track) else admin_conference_role_path(@conference.short_title, @role.name) end diff --git a/app/models/track.rb b/app/models/track.rb index a38cf458..2b37d1bb 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -39,6 +39,10 @@ class Track < ActiveRecord::Base false end + def to_param + short_name + end + private def generate_guid diff --git a/app/views/admin/roles/index.html.haml b/app/views/admin/roles/index.html.haml index 1310b133..4a100025 100644 --- a/app/views/admin/roles/index.html.haml +++ b/app/views/admin/roles/index.html.haml @@ -22,19 +22,20 @@ %td = role.description - if role.resource_type == 'Track' - - track = Track.find(role.resource_id) - = link_to track.name, admin_conference_program_track_path(@conference.short_title, track) + = link_to role.resource.name, admin_conference_program_track_path(@conference.short_title, role.resource) %td = role.users.pluck(:name).first(5).join ', ' - if role.users.count > 5 - = link_to '...', admin_conference_role_path(@conference.short_title, role.name) + - if role.resource_type == 'Track' + = link_to '...', track_admin_conference_role_path(@conference.short_title, role.name, role.resource) + - else + = link_to '...', admin_conference_role_path(@conference.short_title, role.name) %td .btn-group - if role.resource_type == 'Track' - - track_name = Track.find(role.resource_id).short_name - = link_to 'Users', track_admin_conference_role_path(@conference.short_title, role.name, track_name), class: 'btn btn-success' + = link_to 'Users', track_admin_conference_role_path(@conference.short_title, role.name, role.resource), class: 'btn btn-success' - if can? :edit, role - = link_to 'Edit', track_edit_admin_conference_role_path(@conference.short_title, role.name, track_name), class: 'btn btn-primary' + = link_to 'Edit', track_edit_admin_conference_role_path(@conference.short_title, role.name, role.resource), class: 'btn btn-primary' - else = link_to 'Users', admin_conference_role_path(@conference.short_title, role.name), class: 'btn btn-success' - if can? :edit, role diff --git a/app/views/admin/roles/show.html.haml b/app/views/admin/roles/show.html.haml index d7dcef8d..ee249975 100644 --- a/app/views/admin/roles/show.html.haml +++ b/app/views/admin/roles/show.html.haml @@ -7,7 +7,7 @@ = @role.name.titleize - if can? :edit, @role - if @track - = link_to 'Edit', track_edit_admin_conference_role_path(@conference.short_title, @role.name, @track.short_name), class: 'btn btn-primary pull-right' + = link_to 'Edit', track_edit_admin_conference_role_path(@conference.short_title, @role.name, @track), class: 'btn btn-primary pull-right' - else = link_to 'Edit', edit_admin_conference_role_path(@conference.short_title, @role.name), class: 'btn btn-primary pull-right' .text-muted diff --git a/app/views/admin/tracks/_form.html.haml b/app/views/admin/tracks/_form.html.haml index 76833e66..fe7f014a 100644 --- a/app/views/admin/tracks/_form.html.haml +++ b/app/views/admin/tracks/_form.html.haml @@ -8,7 +8,7 @@ Track .row .col-md-12 - = semantic_form_for(@track, url: (@track.new_record? ? admin_conference_program_tracks_path : admin_conference_program_track_path(@conference.short_title, @track.short_name))) do |f| + = semantic_form_for(@track, url: (@track.new_record? ? admin_conference_program_tracks_path : admin_conference_program_track_path(@conference.short_title, @track))) do |f| = f.input :name = f.input :short_name, hint: "A short and unique handle for the track, using only letters, numbers, underscores, and dashes. This will be used to identify the track in URLs etc. Example: 'my_awesome_track'", input_html: { required: 'required', pattern: '[a-zA-Z0-9_-]+', title: 'Only letters, numbers, underscores, and dashes.' } = f.input :color, input_html: {size: 6, type: 'color'}, required: true diff --git a/app/views/admin/tracks/index.html.haml b/app/views/admin/tracks/index.html.haml index 94193088..9abf1d98 100644 --- a/app/views/admin/tracks/index.html.haml +++ b/app/views/admin/tracks/index.html.haml @@ -20,7 +20,7 @@ - @tracks.each do |track| %tr %td - = link_to(admin_conference_program_track_path(@conference.short_title, track.short_name)) do + = link_to(admin_conference_program_track_path(@conference.short_title, track)) do = track.name %td = track.short_name @@ -54,11 +54,12 @@ %i.fa.fa-check %td .btn-group{role: "group"} - = link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track.short_name), + = link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track), method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track.short_name), - method: :delete, class: 'btn btn-danger', - data: { confirm: "Do you really want to delete #{track.name}? Attention: This track will be removed from all Events that have it set" } + - if can? :destroy, track + = link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track), + method: :delete, class: 'btn btn-danger', + data: { confirm: "Do you really want to delete #{track.name}? Attention: This track will be removed from all Events that have it set" } .row .col-md-12.text-right = link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-success' diff --git a/app/views/tracks/_form.html.haml b/app/views/tracks/_form.html.haml index a10a72a9..0e48a851 100644 --- a/app/views/tracks/_form.html.haml +++ b/app/views/tracks/_form.html.haml @@ -9,7 +9,7 @@ Track .row .col-md-12 - = semantic_form_for(@track, url: (@track.new_record? ? conference_program_tracks_path : conference_program_track_path(@conference.short_title, @track.short_name))) do |f| + = semantic_form_for(@track, url: (@track.new_record? ? conference_program_tracks_path : conference_program_track_path(@conference.short_title, @track))) do |f| = f.input :name = f.input :short_name, hint: "A short and unique handle for the track, using only letters, numbers, underscores, and dashes. This will be used to identify the track in URLs etc. Example: 'my_awesome_track'", input_html: { required: 'required', pattern: '[a-zA-Z0-9_-]+', title: 'Only letters, numbers, underscores, and dashes.' } = f.input :color, input_html: {size: 6, type: 'color'}, required: true diff --git a/app/views/tracks/index.html.haml b/app/views/tracks/index.html.haml index a6347747..d4670bf4 100644 --- a/app/views/tracks/index.html.haml +++ b/app/views/tracks/index.html.haml @@ -21,7 +21,7 @@ - @tracks.each do |track| %tr %td - = link_to(conference_program_track_path(@conference.short_title, track.short_name)) do + = link_to(conference_program_track_path(@conference.short_title, track)) do = track.name %td = track.short_name @@ -34,7 +34,7 @@ %td = track.state %td - = link_to 'Edit', edit_conference_program_track_path(@conference.short_title, track.short_name), + = link_to 'Edit', edit_conference_program_track_path(@conference.short_title, track), method: :get, class: 'btn btn-primary' .row diff --git a/app/views/tracks/show.html.haml b/app/views/tracks/show.html.haml index 7ea80c58..c08818eb 100644 --- a/app/views/tracks/show.html.haml +++ b/app/views/tracks/show.html.haml @@ -23,4 +23,4 @@ = @track.description .row .col-md-12.text-right - = link_to 'Edit Track request', edit_conference_program_track_path(@conference.short_title, @track.short_name), class: 'btn btn-primary' + = link_to 'Edit Track request', edit_conference_program_track_path(@conference.short_title, @track), class: 'btn btn-primary' diff --git a/spec/features/track_organizer_ability_spec.rb b/spec/features/track_organizer_ability_spec.rb index f32392ba..f79eba05 100644 --- a/spec/features/track_organizer_ability_spec.rb +++ b/spec/features/track_organizer_ability_spec.rb @@ -209,17 +209,17 @@ feature 'Has correct abilities' do expect(current_path).to eq root_path other_track = create(:track, program: conference.program) - visit admin_conference_program_track_path(conference.short_title, other_track.short_name) + visit admin_conference_program_track_path(conference.short_title, other_track) expect(current_path).to eq root_path - visit edit_admin_conference_program_track_path(conference.short_title, other_track.short_name) + visit edit_admin_conference_program_track_path(conference.short_title, other_track) expect(current_path).to eq root_path - visit admin_conference_program_track_path(conference.short_title, self_organized_track.short_name) - expect(current_path).to eq admin_conference_program_track_path(conference.short_title, self_organized_track.short_name) + visit admin_conference_program_track_path(conference.short_title, self_organized_track) + expect(current_path).to eq admin_conference_program_track_path(conference.short_title, self_organized_track) - visit edit_admin_conference_program_track_path(conference.short_title, self_organized_track.short_name) - expect(current_path).to eq edit_admin_conference_program_track_path(conference.short_title, self_organized_track.short_name) + visit edit_admin_conference_program_track_path(conference.short_title, self_organized_track) + expect(current_path).to eq edit_admin_conference_program_track_path(conference.short_title, self_organized_track) visit admin_conference_roles_path(conference.short_title) expect(current_path).to eq admin_conference_roles_path(conference.short_title)