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
|
def show
|
||||||
@url = if @track
|
@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
|
else
|
||||||
toggle_user_admin_conference_role_path(@conference.short_title, @role.name)
|
toggle_user_admin_conference_role_path(@conference.short_title, @role.name)
|
||||||
end
|
end
|
||||||
|
|
@ -24,7 +24,7 @@ module Admin
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@url = if @track
|
@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
|
else
|
||||||
admin_conference_role_path(@conference.short_title, @role.name)
|
admin_conference_role_path(@conference.short_title, @role.name)
|
||||||
end
|
end
|
||||||
|
|
@ -36,7 +36,7 @@ module Admin
|
||||||
|
|
||||||
if @role.update_attributes(role_params)
|
if @role.update_attributes(role_params)
|
||||||
url = if @track
|
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
|
else
|
||||||
admin_conference_role_path(@conference.short_title, @role.name)
|
admin_conference_role_path(@conference.short_title, @role.name)
|
||||||
end
|
end
|
||||||
|
|
@ -55,7 +55,7 @@ module Admin
|
||||||
state = user_params[:state]
|
state = user_params[:state]
|
||||||
|
|
||||||
url = if @track
|
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
|
else
|
||||||
admin_conference_role_path(@conference.short_title, @role.name)
|
admin_conference_role_path(@conference.short_title, @role.name)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,10 @@ class Track < ActiveRecord::Base
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_param
|
||||||
|
short_name
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_guid
|
def generate_guid
|
||||||
|
|
|
||||||
|
|
@ -22,19 +22,20 @@
|
||||||
%td
|
%td
|
||||||
= role.description
|
= role.description
|
||||||
- if role.resource_type == 'Track'
|
- if role.resource_type == 'Track'
|
||||||
- track = Track.find(role.resource_id)
|
= link_to role.resource.name, admin_conference_program_track_path(@conference.short_title, role.resource)
|
||||||
= link_to track.name, admin_conference_program_track_path(@conference.short_title, track)
|
|
||||||
%td
|
%td
|
||||||
= role.users.pluck(:name).first(5).join ', '
|
= role.users.pluck(:name).first(5).join ', '
|
||||||
- if role.users.count > 5
|
- 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
|
%td
|
||||||
.btn-group
|
.btn-group
|
||||||
- if role.resource_type == 'Track'
|
- 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, role.resource), class: 'btn btn-success'
|
||||||
= link_to 'Users', track_admin_conference_role_path(@conference.short_title, role.name, track_name), class: 'btn btn-success'
|
|
||||||
- if can? :edit, role
|
- 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
|
- else
|
||||||
= link_to 'Users', admin_conference_role_path(@conference.short_title, role.name), class: 'btn btn-success'
|
= link_to 'Users', admin_conference_role_path(@conference.short_title, role.name), class: 'btn btn-success'
|
||||||
- if can? :edit, role
|
- if can? :edit, role
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
= @role.name.titleize
|
= @role.name.titleize
|
||||||
- if can? :edit, @role
|
- if can? :edit, @role
|
||||||
- if @track
|
- 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
|
- else
|
||||||
= link_to 'Edit', edit_admin_conference_role_path(@conference.short_title, @role.name), class: 'btn btn-primary pull-right'
|
= link_to 'Edit', edit_admin_conference_role_path(@conference.short_title, @role.name), class: 'btn btn-primary pull-right'
|
||||||
.text-muted
|
.text-muted
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
Track
|
Track
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.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 :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 :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
|
= f.input :color, input_html: {size: 6, type: 'color'}, required: true
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
- @tracks.each do |track|
|
- @tracks.each do |track|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%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
|
= track.name
|
||||||
%td
|
%td
|
||||||
= track.short_name
|
= track.short_name
|
||||||
|
|
@ -54,11 +54,12 @@
|
||||||
%i.fa.fa-check
|
%i.fa.fa-check
|
||||||
%td
|
%td
|
||||||
.btn-group{role: "group"}
|
.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'
|
method: :get, class: 'btn btn-primary'
|
||||||
= link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track.short_name),
|
- if can? :destroy, track
|
||||||
method: :delete, class: 'btn btn-danger',
|
= link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track),
|
||||||
data: { confirm: "Do you really want to delete #{track.name}? Attention: This track will be removed from all Events that have it set" }
|
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
|
.row
|
||||||
.col-md-12.text-right
|
.col-md-12.text-right
|
||||||
= link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-success'
|
= link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-success'
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
Track
|
Track
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.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 :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 :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
|
= f.input :color, input_html: {size: 6, type: 'color'}, required: true
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
- @tracks.each do |track|
|
- @tracks.each do |track|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%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
|
= track.name
|
||||||
%td
|
%td
|
||||||
= track.short_name
|
= track.short_name
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
%td
|
%td
|
||||||
= track.state
|
= track.state
|
||||||
%td
|
%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'
|
method: :get, class: 'btn btn-primary'
|
||||||
|
|
||||||
.row
|
.row
|
||||||
|
|
|
||||||
|
|
@ -23,4 +23,4 @@
|
||||||
= @track.description
|
= @track.description
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-right
|
.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
|
expect(current_path).to eq root_path
|
||||||
|
|
||||||
other_track = create(:track, program: conference.program)
|
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
|
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
|
expect(current_path).to eq root_path
|
||||||
|
|
||||||
visit 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.short_name)
|
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)
|
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.short_name)
|
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)
|
visit admin_conference_roles_path(conference.short_title)
|
||||||
expect(current_path).to eq 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