Add comment functionality to tracks

This commit is contained in:
Rishabh Singh 2019-07-18 12:49:50 +05:30
parent 770a63e15c
commit 58208c73ac
19 changed files with 153 additions and 48 deletions

View file

@ -155,15 +155,17 @@ class Ability
can :manage, Registration, conference_id: conf_ids_for_organizer
# To access conference/proposals
can :manage, Event, program: { conference_id: conf_ids_for_organizer }
can :manage, Comment
# To access comment link in menu bar
can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
# can :index, Comment, commentable_type: 'Event',
# commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
end
if conf_ids_for_cfp
# To access comment link in menu bar
can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
can :manage, Comment
# can :index, Comment, commentable_type: 'Event',
# commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
# To access conference/proposals
can :manage, Event, program: { conference_id: conf_ids_for_cfp }
end

View file

@ -102,6 +102,7 @@ class AdminAbility
signed_in_with_organizer_role(user, conf_ids_for_organization_admin)
end
# rubocop:disable Metrics/AbcSize
def signed_in_with_organizer_role(user, conf_ids_for_organization_admin = [])
# ids of all the conferences for which the user has the 'organizer' role and
# conferences that belong to organizations for which user is 'organization_admin'
@ -149,7 +150,8 @@ class AdminAbility
end
can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
can :index, Comment, commentable_type: 'Track',
commentable_id: Track.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
# Abilities for Role (Conference resource)
can [:index, :show], Role do |role|
role.resource_type == 'Conference' || role.resource_type == 'Track'
@ -163,6 +165,7 @@ class AdminAbility
can [:index, :revert_object, :revert_attribute], PaperTrail::Version, item_type: 'User'
can [:index, :revert_object, :revert_attribute], PaperTrail::Version, conference_id: conf_ids
end
# rubocop:enable Metrics/AbcSize
def signed_in_with_cfp_role(user)
# ids of all the conferences for which the user has the 'cfp' role
@ -189,6 +192,8 @@ class AdminAbility
can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
can :index, Comment, commentable_type: 'Track',
commentable_id: Track.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
# Abilities for Role (Conference resource)
can [:index, :show], Role do |role|
role.resource_type == 'Conference' || role.resource_type == 'Track'

View file

@ -15,6 +15,8 @@ class Track < ApplicationRecord
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
acts_as_commentable
before_create :generate_guid
validates :name, presence: true
validates :color, format: /\A#[0-9A-F]{6}\z/