Add to_param to the Track model
And update the urls
This commit is contained in:
parent
68fc750e9f
commit
9671696adf
10 changed files with 33 additions and 27 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ class Track < ActiveRecord::Base
|
|||
false
|
||||
end
|
||||
|
||||
def to_param
|
||||
short_name
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_guid
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue