Implement track requests and add the track organizer role
About track requests: Create migration that adds the fields submitter_id, state, and cfp_active to Tracks Add validations and the self_organized? method to the Track model Create a new TracksController outide of the admin namespace Create the relevant views for index, show, new and edit Modify the admin views for tracks to include extra info for self-organized tracks About track organizers: Create the role when a self-organized track is created Define track organizer abilities Modify the roles views and controller to handle the new role The route for Roles#edit needs to have higher priority than the nested routes for track roles, otherwise, the word edit in the url is matched as a track with short_name edit
This commit is contained in:
parent
98fc1137e1
commit
68fc750e9f
26 changed files with 766 additions and 27 deletions
|
|
@ -1,6 +1,10 @@
|
|||
class Track < ActiveRecord::Base
|
||||
include RevisionCount
|
||||
|
||||
resourcify :roles, dependent: :delete_all
|
||||
|
||||
belongs_to :program
|
||||
belongs_to :submitter, class_name: 'User'
|
||||
has_many :events, dependent: :nullify
|
||||
|
||||
has_paper_trail only: [:name, :description, :color], meta: { conference_id: :conference_id }
|
||||
|
|
@ -14,13 +18,27 @@ class Track < ActiveRecord::Base
|
|||
uniqueness: {
|
||||
scope: :program
|
||||
}
|
||||
validates :state, presence: true, if: :self_organized?
|
||||
validates :cfp_active, inclusion: { in: [true, false] }, if: :self_organized?
|
||||
|
||||
before_validation :capitalize_color
|
||||
|
||||
after_create :create_organizer_role, if: :self_organized?
|
||||
|
||||
def conference
|
||||
program.conference
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if the track is self-organized
|
||||
# ====Returns
|
||||
# * +true+ -> If the track has a submitter
|
||||
# * +false+ -> if the track doesn't have a submitter
|
||||
def self_organized?
|
||||
return true if submitter
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_guid
|
||||
|
|
@ -38,4 +56,10 @@ class Track < ActiveRecord::Base
|
|||
def conference_id
|
||||
program.conference_id
|
||||
end
|
||||
|
||||
##
|
||||
# Creates the role of the track organizer
|
||||
def create_organizer_role
|
||||
Role.where(name: 'track_organizer', resource: self).first_or_create(description: 'For the organizers of the Track')
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue