Merge branch 'master' into ticket-show-page
This commit is contained in:
commit
121192d21a
66 changed files with 2647 additions and 1492 deletions
|
|
@ -20,14 +20,6 @@
|
|||
color: black;
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
input[type=text],
|
||||
input[type=password] {
|
||||
text-align: center;
|
||||
padding: 5px;
|
||||
display: block;
|
||||
margin: auto;
|
||||
width: 255px;
|
||||
}
|
||||
.btn-group {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,12 @@ module Admin
|
|||
class BaseController < ApplicationController
|
||||
before_filter :verify_user_admin
|
||||
|
||||
private
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= AdminAbility.new(current_user)
|
||||
end
|
||||
|
||||
def verify_user_admin
|
||||
if (current_user.nil?)
|
||||
redirect_to sign_in_path
|
||||
|
|
@ -9,7 +15,8 @@ module Admin
|
|||
end
|
||||
unless (current_user.has_role? :organizer, :any) || (current_user.has_role? :cfp, :any) ||
|
||||
(current_user.has_role? :info_desk, :any) || (current_user.has_role? :organization_admin, :any) ||
|
||||
(current_user.has_role? :volunteers_coordinator, :any) || current_user.is_admin
|
||||
(current_user.has_role? :volunteers_coordinator, :any) ||
|
||||
(current_user.has_role? :track_organizer, :any) || current_user.is_admin
|
||||
raise CanCan::AccessDenied.new('You are not authorized to access this page.')
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
module Admin
|
||||
class RegistrationPeriodsController < ApplicationController
|
||||
class RegistrationPeriodsController < Admin::BaseController
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource through: :conference, singleton: true
|
||||
|
||||
|
|
|
|||
|
|
@ -8,14 +8,26 @@ module Admin
|
|||
|
||||
def index
|
||||
@roles = Role.where(resource: @conference)
|
||||
tracks = @conference.program.tracks.where.not(submitter: nil)
|
||||
@roles += Role.where(resource: tracks)
|
||||
authorize! :index, @role
|
||||
end
|
||||
|
||||
def show
|
||||
@url = if @track
|
||||
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
|
||||
@users = @role.users
|
||||
end
|
||||
|
||||
def edit
|
||||
@url = if @track
|
||||
track_admin_conference_role_path(@conference.short_title, @role.name, @track)
|
||||
else
|
||||
admin_conference_role_path(@conference.short_title, @role.name)
|
||||
end
|
||||
@users = @role.users
|
||||
end
|
||||
|
||||
|
|
@ -23,7 +35,13 @@ module Admin
|
|||
role_name = @role.name
|
||||
|
||||
if @role.update_attributes(role_params)
|
||||
redirect_to admin_conference_role_path(@conference.short_title, @role.name),
|
||||
url = if @track
|
||||
track_admin_conference_role_path(@conference.short_title, @role.name, @track)
|
||||
else
|
||||
admin_conference_role_path(@conference.short_title, @role.name)
|
||||
end
|
||||
|
||||
redirect_to url,
|
||||
notice: 'Successfully updated role ' + @role.name
|
||||
else
|
||||
@role.name = role_name
|
||||
|
|
@ -36,8 +54,14 @@ module Admin
|
|||
user = User.find_by(email: user_params[:email])
|
||||
state = user_params[:state]
|
||||
|
||||
url = if @track
|
||||
track_admin_conference_role_path(@conference.short_title, @role.name, @track)
|
||||
else
|
||||
admin_conference_role_path(@conference.short_title, @role.name)
|
||||
end
|
||||
|
||||
unless user
|
||||
redirect_to admin_conference_role_path(@conference.short_title, @role.name),
|
||||
redirect_to url,
|
||||
error: 'Could not find user. Please provide a valid email!'
|
||||
return
|
||||
end
|
||||
|
|
@ -49,17 +73,23 @@ module Admin
|
|||
return
|
||||
end
|
||||
|
||||
if @role.resource_type == 'Conference'
|
||||
role_resource = @conference
|
||||
elsif @role.resource_type == 'Track'
|
||||
role_resource = @track
|
||||
end
|
||||
|
||||
# Remove user
|
||||
if state == 'false'
|
||||
if user.remove_role @role.name, @conference
|
||||
if user.remove_role @role.name, role_resource
|
||||
flash[:notice] = "Successfully removed role #{@role.name} from user #{user.email}"
|
||||
else
|
||||
flash[:error] = "Could not remove role #{@role.name} from user #{user.email}"
|
||||
end
|
||||
elsif user.has_role? @role.name, @conference
|
||||
elsif user.has_role? @role.name, role_resource
|
||||
flash[:error] = "User #{user.email} already has the role #{@role.name}"
|
||||
# Add user
|
||||
elsif user.add_role @role.name, @conference
|
||||
elsif user.add_role @role.name, role_resource
|
||||
flash[:notice] = "Successfully added role #{@role.name} to user #{user.email}"
|
||||
else
|
||||
flash[:error] = "Coud not add role #{@role.name} to #{user.email}"
|
||||
|
|
@ -67,7 +97,7 @@ module Admin
|
|||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html { redirect_to admin_conference_role_path(@conference.short_title, @role.name) }
|
||||
format.html { redirect_to url }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -77,7 +107,12 @@ module Admin
|
|||
# Set 'organizer' as default role, when there is no other selection
|
||||
@selection = params[:id] ? params[:id].parameterize.underscore : 'organizer'
|
||||
|
||||
@role = Role.find_by(name: @selection, resource: @conference)
|
||||
if @selection == 'track_organizer'
|
||||
@track = @conference.program.tracks.find_by(short_name: params[:track_name])
|
||||
@role = Role.find_by(name: @selection, resource: @track)
|
||||
else
|
||||
@role = Role.find_by(name: @selection, resource: @conference)
|
||||
end
|
||||
end
|
||||
|
||||
def role_params
|
||||
|
|
|
|||
|
|
@ -50,10 +50,19 @@ module Admin
|
|||
end
|
||||
end
|
||||
|
||||
def toggle_cfp_inclusion
|
||||
@track.cfp_active = !@track.cfp_active
|
||||
if @track.save
|
||||
head :ok
|
||||
else
|
||||
head :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def track_params
|
||||
params.require(:track).permit(:name, :description, :color, :short_name)
|
||||
params.require(:track).permit(:name, :description, :color, :short_name, :cfp_active)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ module Admin
|
|||
|
||||
def show
|
||||
if can_manage_volunteers?(@conference)
|
||||
if @conference.use_vpositions
|
||||
@volunteers = @conference.registrations.joins(:vchoices).uniq
|
||||
else
|
||||
@volunteers = @conference.registrations.where(volunteer: true)
|
||||
end
|
||||
@volunteers = if @conference.use_vpositions
|
||||
@conference.registrations.joins(:vchoices).uniq
|
||||
else
|
||||
@conference.registrations.where(volunteer: true)
|
||||
end
|
||||
else
|
||||
authorize! :index, :volunteer
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ class ConferenceRegistrationsController < ApplicationController
|
|||
def create
|
||||
@registration = @conference.registrations.new(registration_params)
|
||||
|
||||
if current_user.nil?
|
||||
# @user variable needs to be set so that _sign_up_form_embedded works properly
|
||||
@user = @registration.build_user(user_params)
|
||||
else
|
||||
@user = current_user
|
||||
end
|
||||
@user = if current_user.nil?
|
||||
# @user variable needs to be set so that _sign_up_form_embedded works properly
|
||||
@registration.build_user(user_params)
|
||||
else
|
||||
current_user
|
||||
end
|
||||
|
||||
@registration.user = @user
|
||||
authorize! :create, @registration
|
||||
|
|
|
|||
|
|
@ -13,5 +13,15 @@ class PhysicalTicketController < ApplicationController
|
|||
@file_name = "ticket_for_#{@conference.short_title}"
|
||||
@user = @physical_ticket.user
|
||||
@ticket_layout = @conference.ticket_layout.to_sym
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.pdf do
|
||||
pdf = TicketPdf.new(@conference, @user, @physical_ticket, @ticket_layout, @file_name)
|
||||
send_data pdf.render,
|
||||
filename: @file_name,
|
||||
type: 'application/pdf',
|
||||
disposition: 'attachment'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
47
app/controllers/tracks_controller.rb
Normal file
47
app/controllers/tracks_controller.rb
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
class TracksController < ApplicationController
|
||||
load_resource :conference, find_by: :short_title
|
||||
load_resource :program, through: :conference, singleton: true
|
||||
load_and_authorize_resource through: :program, find_by: :short_name
|
||||
|
||||
def index
|
||||
@tracks = current_user.tracks.where(program: @program)
|
||||
end
|
||||
|
||||
def show; end
|
||||
|
||||
def new
|
||||
@track = @program.tracks.new(color: @conference.next_color_for_collection(:tracks))
|
||||
end
|
||||
|
||||
def edit; end
|
||||
|
||||
def create
|
||||
@track = @program.tracks.new(track_params)
|
||||
@track.submitter = current_user
|
||||
@track.state = 'new'
|
||||
@track.cfp_active = false
|
||||
if @track.save
|
||||
redirect_to conference_program_tracks_path(conference_id: @conference.short_title),
|
||||
notice: 'Track request successfully created.'
|
||||
else
|
||||
flash.now[:error] = "Creating Track request failed: #{@track.errors.full_messages.join('. ')}."
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @track.update_attributes(track_params)
|
||||
redirect_to conference_program_tracks_path(conference_id: @conference.short_title),
|
||||
notice: 'Track request successfully updated.'
|
||||
else
|
||||
flash.now[:error] = "Track request update failed: #{@track.errors.full_messages.join('. ')}."
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def track_params
|
||||
params.require(:track).permit(:name, :description, :color, :short_name)
|
||||
end
|
||||
end
|
||||
|
|
@ -102,13 +102,12 @@ module FormatHelper
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Lint/EndAlignment
|
||||
def word_pluralize(count, singular, plural = nil)
|
||||
word = if (count == 1 || count =~ /^1(\.0+)?$/)
|
||||
singular
|
||||
else
|
||||
plural || singular.pluralize
|
||||
end
|
||||
singular
|
||||
else
|
||||
plural || singular.pluralize
|
||||
end
|
||||
|
||||
"#{word}"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,27 +3,13 @@ class Ability
|
|||
|
||||
# Initializes the ability class
|
||||
def initialize(user)
|
||||
# Order Abilities
|
||||
# (Check https://github.com/CanCanCommunity/cancancan/wiki/Ability-Precedence)
|
||||
# Check roles of user, using rolify. Role name is *case sensitive*
|
||||
# user.is_organizer? or user.has_role? :organizer
|
||||
# user.is_cfp_of? Conference or user.has_role? :cfp, Conference
|
||||
# user.is_info_desk_of? Conference
|
||||
# user.is_volunteers_coordinator_of? Conference
|
||||
# user.is_attendee_of? Conference
|
||||
# The following is wrong because a user will only have 'cfp' role for a specific conference
|
||||
# user.is_cfp? # This is always false
|
||||
|
||||
user ||= User.new
|
||||
|
||||
# This is what sets up the different abilities
|
||||
if user.new_record?
|
||||
not_signed_in
|
||||
# Checks if the user does not have any role and is not an admin
|
||||
elsif user.roles.any? || user.is_admin
|
||||
signed_in_with_roles(user)
|
||||
else
|
||||
signed_in(user)
|
||||
common_abilities_for_admins(user) if user.roles.any? || user.is_admin?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -74,7 +60,6 @@ class Ability
|
|||
def signed_in(user)
|
||||
# Abilities from not_signed_in user are also inherited
|
||||
not_signed_in
|
||||
|
||||
can :manage, User, id: user.id
|
||||
|
||||
can :manage, Registration, user_id: user.id
|
||||
|
|
@ -106,198 +91,38 @@ class Ability
|
|||
can [:destroy], Openid
|
||||
end
|
||||
|
||||
# Abilities for signed in users with roles
|
||||
def signed_in_with_roles(user)
|
||||
# Abilities from not_signed_in and signed_in are also inherited
|
||||
signed_in(user)
|
||||
|
||||
signed_in_with_organization_admin_role(user) if user.has_role? :organization_admin, :any
|
||||
signed_in_with_organizer_role(user) if user.has_role? :organizer, :any
|
||||
signed_in_with_cfp_role(user) if user.has_role? :cfp, :any
|
||||
signed_in_with_info_desk_role(user) if user.has_role? :info_desk, :any
|
||||
signed_in_with_volunteers_coordinator_role(user) if user.has_role? :volunteers_coordinator, :any
|
||||
|
||||
# for users with any role
|
||||
# Abilities for users with roles wandering around in non-admin views.
|
||||
def common_abilities_for_admins(user)
|
||||
can :access, Admin
|
||||
can [:show], Conference
|
||||
can :index, Commercial, commercialable_type: 'Conference'
|
||||
cannot [:edit, :update, :destroy], Question, global: true
|
||||
# for admins
|
||||
can :manage, :all if user.is_admin
|
||||
can :manage, :all if user.is_admin?
|
||||
|
||||
# even admin cannot create new users with ICHAIN enabled
|
||||
cannot [:new, :create], User if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||
|
||||
cannot :revert_object, PaperTrail::Version do |version|
|
||||
(version.event == 'create' && %w(Conference User Event).include?(version.item_type))
|
||||
end
|
||||
|
||||
cannot :revert_attribute, PaperTrail::Version do |version|
|
||||
version.event != 'update' || version.item.nil?
|
||||
end
|
||||
|
||||
cannot :destroy, Program
|
||||
# Do not delete venue, when there are rooms being used
|
||||
cannot :destroy, Venue do |venue|
|
||||
venue.conference.program.events.where.not(room_id: nil).any?
|
||||
end
|
||||
|
||||
# Can't create cfp if there are no available cfp types
|
||||
cannot [:new, :create], Cfp do |cfp|
|
||||
cfp.program.remaining_cfp_types.empty?
|
||||
end
|
||||
end
|
||||
|
||||
def signed_in_with_organization_admin_role(user)
|
||||
org_ids_for_organization_admin = Organization.with_role(:organization_admin, user).pluck(:id)
|
||||
conf_ids_for_organization_admin = Conference.where(organization_id: org_ids_for_organization_admin).pluck(:id)
|
||||
|
||||
can [:read, :update, :destroy], Organization, id: org_ids_for_organization_admin
|
||||
can :new, Conference
|
||||
can :manage, Conference, organization_id: org_ids_for_organization_admin
|
||||
can [:index, :show], Role
|
||||
can [:edit, :update], Role do |role|
|
||||
role.resource_type == 'Organization' && (org_ids_for_organization_admin.include? role.resource_id)
|
||||
end
|
||||
signed_in_with_organizer_role(user, conf_ids_for_organization_admin)
|
||||
end
|
||||
|
||||
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'
|
||||
conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq
|
||||
can :manage, Resource, conference_id: conf_ids
|
||||
can [:read, :update, :destroy], Conference, id: conf_ids
|
||||
can :manage, Splashpage, conference_id: conf_ids
|
||||
can :manage, Contact, conference_id: conf_ids
|
||||
can :manage, EmailSettings, conference_id: conf_ids
|
||||
can :manage, Campaign, conference_id: conf_ids
|
||||
can :manage, Target, conference_id: conf_ids
|
||||
can :manage, Commercial, commercialable_type: 'Conference',
|
||||
commercialable_id: conf_ids
|
||||
can :manage, Registration, conference_id: conf_ids
|
||||
can :manage, RegistrationPeriod, conference_id: conf_ids
|
||||
can :manage, Question, conference_id: conf_ids
|
||||
can :manage, Question do |question|
|
||||
!(question.conferences.pluck(:id) & conf_ids).empty?
|
||||
end
|
||||
can :manage, Vposition, conference_id: conf_ids
|
||||
can :manage, Vday, conference_id: conf_ids
|
||||
can :manage, Program, conference_id: conf_ids
|
||||
can :manage, Schedule, program: { conference_id: conf_ids }
|
||||
can :manage, EventSchedule, schedule: { program: { conference_id: conf_ids } }
|
||||
can :manage, Cfp, program: { conference_id: conf_ids}
|
||||
can :manage, Event, program: { conference_id: conf_ids}
|
||||
can :manage, EventType, program: { conference_id: conf_ids}
|
||||
can :manage, Track, program: { conference_id: conf_ids}
|
||||
can :manage, DifficultyLevel, program: { conference_id: conf_ids}
|
||||
can :manage, Commercial, commercialable_type: 'Event',
|
||||
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
|
||||
can :manage, Venue, conference_id: conf_ids
|
||||
can :manage, Commercial, commercialable_type: 'Venue',
|
||||
commercialable_id: Venue.where(conference_id: conf_ids).pluck(:id)
|
||||
can :manage, Lodging, conference_id: conf_ids
|
||||
can :manage, Room, venue: { conference_id: conf_ids}
|
||||
can :manage, Sponsor, conference_id: conf_ids
|
||||
can :manage, SponsorshipLevel, conference_id: conf_ids
|
||||
can :manage, Ticket, conference_id: conf_ids
|
||||
can :index, Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.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'
|
||||
end
|
||||
|
||||
can [:edit, :update, :toggle_user], Role do |role|
|
||||
role.resource_type == 'Conference' && (conf_ids.include? role.resource_id)
|
||||
end
|
||||
|
||||
can [:index, :revert_object, :revert_attribute], PaperTrail::Version do |version|
|
||||
version.item_type == 'User' || (conf_ids.include? version.conference_id)
|
||||
end
|
||||
end
|
||||
|
||||
def signed_in_with_cfp_role(user)
|
||||
# ids of all the conferences for which the user has the 'cfp' role
|
||||
conf_ids_for_organizer = Conference.with_role(:organizer, user).pluck(:id)
|
||||
conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id)
|
||||
|
||||
can [:index, :show, :update], Resource, conference_id: conf_ids_for_cfp
|
||||
can :manage, Event, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, EventType, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, Track, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, DifficultyLevel, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, EmailSettings, conference_id: conf_ids_for_cfp
|
||||
can :manage, Schedule, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, Room, venue: { conference_id: conf_ids_for_cfp }
|
||||
can :show, Venue, conference_id: conf_ids_for_cfp
|
||||
can :show, Commercial, commercialable_type: 'Venue', commercialable_id: Venue.where(conference_id: conf_ids_for_cfp).pluck(:id)
|
||||
can :manage, Cfp, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, Program, conference_id: conf_ids_for_cfp
|
||||
can :manage, Commercial, commercialable_type: 'Event',
|
||||
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
|
||||
can :index, Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference'
|
||||
end
|
||||
# Can add or remove users from role, when user has that same role for the conference
|
||||
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
|
||||
can :toggle_user, Role do |role|
|
||||
role.resource_type == 'Conference' && role.name == 'cfp' &&
|
||||
(Conference.with_role(:cfp, user).pluck(:id).include? role.resource_id)
|
||||
end
|
||||
|
||||
can [:index, :revert_object, :revert_attribute], PaperTrail::Version, item_type: 'Event', conference_id: conf_ids_for_cfp
|
||||
can [:index, :revert_object, :revert_attribute], PaperTrail::Version, item_type: 'Vote', conference_id: conf_ids_for_cfp
|
||||
can [:index, :revert_object, :revert_attribute], PaperTrail::Version do |version|
|
||||
version.item_type == 'Commercial' && conf_ids_for_cfp.include?(version.conference_id) &&
|
||||
(version.object.to_s.include?('Event') || version.object_changes.to_s.include?('Event'))
|
||||
end
|
||||
end
|
||||
|
||||
def signed_in_with_info_desk_role(user)
|
||||
# ids of all the conferences for which the user has the 'info_desk' role
|
||||
conf_ids_for_info_desk = Conference.with_role(:info_desk, user).pluck(:id)
|
||||
|
||||
can [:index, :show, :update], Resource, conference_id: conf_ids_for_info_desk
|
||||
can :manage, Registration, conference_id: conf_ids_for_info_desk
|
||||
can :manage, Question, conference_id: conf_ids_for_info_desk
|
||||
can :manage, Question do |question|
|
||||
!(question.conferences.pluck(:id) & conf_ids_for_info_desk).empty?
|
||||
if conf_ids_for_organizer
|
||||
# To access splashpage of their conference if it is not public
|
||||
can :show, Conference, id: conf_ids_for_organizer
|
||||
# To access conference/proposals/registrations
|
||||
can :manage, Registration, conference_id: conf_ids_for_organizer
|
||||
# To access conference/proposals
|
||||
can :manage, Event, program: { conference_id: conf_ids_for_organizer }
|
||||
# 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)
|
||||
end
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference'
|
||||
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)
|
||||
# To access conference/proposals
|
||||
can :manage, Event, program: { conference_id: conf_ids_for_cfp }
|
||||
end
|
||||
# Can add or remove users from role, when user has that same role for the conference
|
||||
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
|
||||
can :toggle_user, Role do |role|
|
||||
role.resource_type == 'Conference' && role.name == 'info_desk' &&
|
||||
(Conference.with_role(:info_desk, user).pluck(:id).include? role.resource_id)
|
||||
end
|
||||
end
|
||||
|
||||
def signed_in_with_volunteers_coordinator_role(user)
|
||||
# ids of all the conferences for which the user has the 'volunteers_coordinator' role
|
||||
conf_ids_for_volunteers_coordinator = Conference.with_role(:volunteers_coordinator, user).pluck(:id)
|
||||
|
||||
can [:index, :show, :update], Resource, conference_id: conf_ids_for_volunteers_coordinator
|
||||
can :manage, Vposition, conference_id: conf_ids_for_volunteers_coordinator
|
||||
can :manage, Vday, conference_id: conf_ids_for_volunteers_coordinator
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference'
|
||||
end
|
||||
# Can add or remove users from role, when user has that same role for the conference
|
||||
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
|
||||
can :toggle_user, Role do |role|
|
||||
role.resource_type == 'Conference' && role.name == 'volunteers_coordinator' &&
|
||||
(Conference.with_role(:volunteers_coordinator, user).pluck(:id).include? role.resource_id)
|
||||
if conf_ids_for_info_desk
|
||||
# To access conference/proposals/registrations
|
||||
can :manage, Registration, conference_id: conf_ids_for_info_desk
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
286
app/models/admin_ability.rb
Normal file
286
app/models/admin_ability.rb
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
class AdminAbility
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
# Order Abilities
|
||||
# (Check https://github.com/CanCanCommunity/cancancan/wiki/Ability-Precedence)
|
||||
# Check roles of user, using rolify. Role name is *case sensitive*
|
||||
# user.is_organizer? or user.has_role? :organizer
|
||||
# user.is_cfp_of? Conference or user.has_role? :cfp, Conference
|
||||
# user.is_info_desk_of? Conference
|
||||
# user.is_volunteers_coordinator_of? Conference
|
||||
# user.is_attendee_of? Conference
|
||||
# The following is wrong because a user will only have 'cfp' role for a specific conference
|
||||
# user.is_cfp? # This is always false
|
||||
|
||||
user ||= User.new
|
||||
signed_in_with_roles(user)
|
||||
end
|
||||
|
||||
def common_abilities_for_roles(user)
|
||||
can :manage, User, id: user.id
|
||||
can :manage, Registration, user_id: user.id
|
||||
|
||||
can :index, Conference
|
||||
can :show, Registration, &:new_record?
|
||||
|
||||
can [:new, :create], Registration do |registration|
|
||||
conference = registration.conference
|
||||
conference.registration_open? && !conference.registration_limit_exceeded? || conference.program.speakers.confirmed.include?(user)
|
||||
end
|
||||
|
||||
can :index, Organization
|
||||
can :index, Ticket
|
||||
can :manage, TicketPurchase, user_id: user.id
|
||||
can [:new, :create], Payment, user_id: user.id
|
||||
|
||||
can [:create, :destroy], Subscription, user_id: user.id
|
||||
|
||||
can [:new, :create], Event do |event|
|
||||
event.program.cfp_open? && event.new_record?
|
||||
end
|
||||
|
||||
can [:update, :show, :delete, :index], Event do |event|
|
||||
event.users.include?(user)
|
||||
end
|
||||
|
||||
# can manage the commercials of their own events
|
||||
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id)
|
||||
|
||||
can [:destroy], Openid
|
||||
can :access, Admin
|
||||
can :index, Commercial, commercialable_type: 'Conference'
|
||||
cannot [:edit, :update, :destroy], Question, global: true
|
||||
# for admins
|
||||
can :manage, :all if user.is_admin
|
||||
# even admin cannot create new users with ICHAIN enabled
|
||||
cannot [:new, :create], User if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||
cannot :revert_object, PaperTrail::Version do |version|
|
||||
(version.event == 'create' && %w[Conference User Event].include?(version.item_type))
|
||||
end
|
||||
cannot :revert_attribute, PaperTrail::Version do |version|
|
||||
version.event != 'update' || version.item.nil?
|
||||
end
|
||||
# Can't create cfp if there are no available cfp types
|
||||
cannot [:new, :create], Cfp do |cfp|
|
||||
cfp.program.remaining_cfp_types.empty?
|
||||
end
|
||||
cannot :destroy, Program
|
||||
# Do not delete venue, when there are rooms being used
|
||||
cannot :destroy, Venue do |venue|
|
||||
venue.conference.program.events.where.not(room_id: nil).any?
|
||||
end
|
||||
|
||||
# Prevent requests for tracks from being destroyed
|
||||
cannot :destroy, Track do |track|
|
||||
track.self_organized?
|
||||
end
|
||||
end
|
||||
|
||||
# Abilities for signed in users with roles
|
||||
def signed_in_with_roles(user)
|
||||
signed_in_with_organization_admin_role(user) if user.has_role? :organization_admin, :any
|
||||
signed_in_with_organizer_role(user) if user.has_role? :organizer, :any
|
||||
signed_in_with_cfp_role(user) if user.has_role? :cfp, :any
|
||||
signed_in_with_info_desk_role(user) if user.has_role? :info_desk, :any
|
||||
signed_in_with_volunteers_coordinator_role(user) if user.has_role? :volunteers_coordinator, :any
|
||||
signed_in_with_track_organizer_role(user) if user.has_role? :track_organizer, :any
|
||||
common_abilities_for_roles(user)
|
||||
end
|
||||
|
||||
def signed_in_with_organization_admin_role(user)
|
||||
org_ids_for_organization_admin = Organization.with_role(:organization_admin, user).pluck(:id)
|
||||
conf_ids_for_organization_admin = Conference.where(organization_id: org_ids_for_organization_admin).pluck(:id)
|
||||
|
||||
can [:read, :update, :destroy], Organization, id: org_ids_for_organization_admin
|
||||
can :new, Conference
|
||||
can :manage, Conference, organization_id: org_ids_for_organization_admin
|
||||
can [:index, :show], Role
|
||||
can [:edit, :update], Role do |role|
|
||||
role.resource_type == 'Organization' && (org_ids_for_organization_admin.include? role.resource_id)
|
||||
end
|
||||
signed_in_with_organizer_role(user, conf_ids_for_organization_admin)
|
||||
end
|
||||
|
||||
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'
|
||||
conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq
|
||||
# ids of all the tracks that belong to the programs of the above conferences
|
||||
track_ids = Track.joins(:program).where('programs.conference_id IN (?)', conf_ids).pluck(:id)
|
||||
|
||||
can :manage, Resource, conference_id: conf_ids
|
||||
can [:read, :update, :destroy], Conference, id: conf_ids
|
||||
can :manage, Splashpage, conference_id: conf_ids
|
||||
can :manage, Contact, conference_id: conf_ids
|
||||
can :manage, EmailSettings, conference_id: conf_ids
|
||||
can :manage, Campaign, conference_id: conf_ids
|
||||
can :manage, Target, conference_id: conf_ids
|
||||
can :manage, Commercial, commercialable_type: 'Conference',
|
||||
commercialable_id: conf_ids
|
||||
can :manage, Registration, conference_id: conf_ids
|
||||
can :manage, RegistrationPeriod, conference_id: conf_ids
|
||||
can :manage, Question, conference_id: conf_ids
|
||||
can :manage, Question do |question|
|
||||
!(question.conferences.pluck(:id) & conf_ids).empty?
|
||||
end
|
||||
can :manage, Vposition, conference_id: conf_ids
|
||||
can :manage, Vday, conference_id: conf_ids
|
||||
can :manage, Program, conference_id: conf_ids
|
||||
can :manage, Schedule, program: { conference_id: conf_ids }
|
||||
can :manage, EventSchedule, schedule: { program: { conference_id: conf_ids } }
|
||||
can :manage, Cfp, program: { conference_id: conf_ids }
|
||||
can :manage, Event, program: { conference_id: conf_ids }
|
||||
can :manage, EventType, program: { conference_id: conf_ids }
|
||||
can :manage, Track, program: { conference_id: conf_ids }
|
||||
can :manage, DifficultyLevel, program: { conference_id: conf_ids }
|
||||
can :manage, Commercial, commercialable_type: 'Event',
|
||||
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
|
||||
can :manage, Venue, conference_id: conf_ids
|
||||
can :manage, Commercial, commercialable_type: 'Venue',
|
||||
commercialable_id: Venue.where(conference_id: conf_ids).pluck(:id)
|
||||
can :manage, Lodging, conference_id: conf_ids
|
||||
can :manage, Room, venue: { conference_id: conf_ids }
|
||||
can :manage, Sponsor, conference_id: conf_ids
|
||||
can :manage, SponsorshipLevel, conference_id: conf_ids
|
||||
can :manage, Ticket, conference_id: conf_ids
|
||||
can :index, Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.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'
|
||||
end
|
||||
|
||||
can [:edit, :update, :toggle_user], Role do |role|
|
||||
role.resource_type == 'Conference' && (conf_ids.include? role.resource_id) ||
|
||||
role.resource_type == 'Track' && (track_ids.include? role.resource_id)
|
||||
end
|
||||
|
||||
can [:index, :revert_object, :revert_attribute], PaperTrail::Version do |version|
|
||||
version.item_type == 'User' || (conf_ids.include? version.conference_id)
|
||||
end
|
||||
end
|
||||
|
||||
def signed_in_with_cfp_role(user)
|
||||
# ids of all the conferences for which the user has the 'cfp' role
|
||||
conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id)
|
||||
|
||||
can :show, Conference do |conf|
|
||||
conf_ids_for_cfp.include?(conf.id)
|
||||
end
|
||||
can [:index, :show, :update], Resource, conference_id: conf_ids_for_cfp
|
||||
can :manage, Event, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, EventType, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, Track, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, DifficultyLevel, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, EmailSettings, conference_id: conf_ids_for_cfp
|
||||
can :manage, Schedule, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, Room, venue: { conference_id: conf_ids_for_cfp }
|
||||
can :show, Venue, conference_id: conf_ids_for_cfp
|
||||
can :show, Commercial, commercialable_type: 'Venue', commercialable_id: Venue.where(conference_id: conf_ids_for_cfp).pluck(:id)
|
||||
can :manage, Cfp, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, Program, conference_id: conf_ids_for_cfp
|
||||
can :manage, Commercial, commercialable_type: 'Event',
|
||||
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
|
||||
can :index, Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference' || role.resource_type == 'Track'
|
||||
end
|
||||
# Can add or remove users from role, when user has that same role for the conference
|
||||
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
|
||||
can :toggle_user, Role do |role|
|
||||
role.resource_type == 'Conference' && role.name == 'cfp' &&
|
||||
(Conference.with_role(:cfp, user).pluck(:id).include? role.resource_id)
|
||||
end
|
||||
|
||||
can [:index, :revert_object, :revert_attribute], PaperTrail::Version, item_type: 'Event', conference_id: conf_ids_for_cfp
|
||||
can [:index, :revert_object, :revert_attribute], PaperTrail::Version, item_type: 'Vote', conference_id: conf_ids_for_cfp
|
||||
can [:index, :revert_object, :revert_attribute], PaperTrail::Version do |version|
|
||||
version.item_type == 'Commercial' && conf_ids_for_cfp.include?(version.conference_id) &&
|
||||
(version.object.to_s.include?('Event') || version.object_changes.to_s.include?('Event'))
|
||||
end
|
||||
end
|
||||
|
||||
def signed_in_with_info_desk_role(user)
|
||||
# ids of all the conferences for which the user has the 'info_desk' role
|
||||
conf_ids_for_info_desk = Conference.with_role(:info_desk, user).pluck(:id)
|
||||
|
||||
can :show, Conference do |conf|
|
||||
conf_ids_for_info_desk.include?(conf.id)
|
||||
end
|
||||
can [:index, :show, :update], Resource, conference_id: conf_ids_for_info_desk
|
||||
can :manage, Registration, conference_id: conf_ids_for_info_desk
|
||||
can :manage, Question, conference_id: conf_ids_for_info_desk
|
||||
can :manage, Question do |question|
|
||||
!(question.conferences.pluck(:id) & conf_ids_for_info_desk).empty?
|
||||
end
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference' || role.resource_type == 'Track'
|
||||
end
|
||||
# Can add or remove users from role, when user has that same role for the conference
|
||||
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
|
||||
can :toggle_user, Role do |role|
|
||||
role.resource_type == 'Conference' && role.name == 'info_desk' &&
|
||||
(Conference.with_role(:info_desk, user).pluck(:id).include? role.resource_id)
|
||||
end
|
||||
end
|
||||
|
||||
def signed_in_with_volunteers_coordinator_role(user)
|
||||
# ids of all the conferences for which the user has the 'volunteers_coordinator' role
|
||||
conf_ids_for_volunteers_coordinator = Conference.with_role(:volunteers_coordinator, user).pluck(:id)
|
||||
|
||||
can :show, Conference do |conf|
|
||||
conf_ids_for_volunteers_coordinator.include?(conf.id)
|
||||
end
|
||||
can [:index, :show, :update], Resource, conference_id: conf_ids_for_volunteers_coordinator
|
||||
can :manage, Vposition, conference_id: conf_ids_for_volunteers_coordinator
|
||||
can :manage, Vday, conference_id: conf_ids_for_volunteers_coordinator
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference' || role.resource_type == 'Track'
|
||||
end
|
||||
# Can add or remove users from role, when user has that same role for the conference
|
||||
# Eg. If you are member of the CfP team, you can add more CfP team members (add users to the role 'CfP')
|
||||
can :toggle_user, Role do |role|
|
||||
role.resource_type == 'Conference' && role.name == 'volunteers_coordinator' &&
|
||||
(Conference.with_role(:volunteers_coordinator, user).pluck(:id).include? role.resource_id)
|
||||
end
|
||||
end
|
||||
|
||||
def signed_in_with_track_organizer_role(user)
|
||||
# ids of all the conferences for which the user has the 'track organizer' role
|
||||
conf_ids_for_track_organizer = Track.with_role(:track_organizer, user).joins(:program).pluck(:conference_id)
|
||||
# ids of all the tracks for which the user has the 'track_organizer' role
|
||||
track_ids_for_track_organizer = Track.with_role(:track_organizer, user).pluck(:id)
|
||||
|
||||
can :show, Conference do |conf|
|
||||
conf_ids_for_track_organizer.include?(conf.id)
|
||||
end
|
||||
|
||||
# Show Program in the admin sidebar
|
||||
can :show, Program, conference_id: conf_ids_for_track_organizer
|
||||
|
||||
# Show Tracks in the admin sidebar
|
||||
can :update, Track do |track|
|
||||
track.new_record? && conf_ids_for_track_organizer.include?(track.program.conference_id)
|
||||
end
|
||||
|
||||
can :manage, Track, id: track_ids_for_track_organizer
|
||||
|
||||
# Show Roles in the admin sidebar and allow authorization of the index action
|
||||
can [:index, :show], Role do |role|
|
||||
role.resource_type == 'Conference' || role.resource_type == 'Track'
|
||||
end
|
||||
|
||||
can :toggle_user, Role do |role|
|
||||
role.resource_type == 'Track' && track_ids_for_track_organizer.include?(role.resource_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# cannot delete program if there are events submitted
|
||||
|
||||
class Cfp < ActiveRecord::Base
|
||||
TYPES = %w(events).freeze
|
||||
TYPES = %w(events booths).freeze
|
||||
|
||||
scope :for_events, (-> { find_by(cfp_type: 'events') })
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ class Conference < ActiveRecord::Base
|
|||
resourcify :roles, dependent: :delete_all
|
||||
|
||||
default_scope { order('start_date DESC') }
|
||||
scope :upcoming, (-> { where('end_date >= ?', Date.current) })
|
||||
scope :past, (-> { where('end_date < ?', Date.current) })
|
||||
|
||||
belongs_to :organization
|
||||
|
||||
|
|
@ -561,11 +563,11 @@ class Conference < ActiveRecord::Base
|
|||
# ====Returns
|
||||
# * +hash+ -> track => {color, value}
|
||||
def tracks_distribution(state = nil)
|
||||
if state
|
||||
tracks_grouped = program.events.select(:track_id).where('state = ?', state).group(:track_id)
|
||||
else
|
||||
tracks_grouped = program.events.select(:track_id).group(:track_id)
|
||||
end
|
||||
tracks_grouped = if state
|
||||
program.events.select(:track_id).where('state = ?', state).group(:track_id)
|
||||
else
|
||||
program.events.select(:track_id).group(:track_id)
|
||||
end
|
||||
tracks_counted = tracks_grouped.count
|
||||
|
||||
calculate_track_distribution_hash(tracks_grouped, tracks_counted)
|
||||
|
|
@ -999,11 +1001,11 @@ class Conference < ActiveRecord::Base
|
|||
# ====Returns
|
||||
# * +hash+ -> object_type => {color, value}
|
||||
def calculate_event_distribution(group_by_id, association_symbol, state = nil)
|
||||
if state
|
||||
grouped = program.events.select(group_by_id).where('state = ?', 'confirmed').group(group_by_id)
|
||||
else
|
||||
grouped = program.events.select(group_by_id).group(group_by_id)
|
||||
end
|
||||
grouped = if state
|
||||
program.events.select(group_by_id).where('state = ?', 'confirmed').group(group_by_id)
|
||||
else
|
||||
program.events.select(group_by_id).group(group_by_id)
|
||||
end
|
||||
counted = grouped.count
|
||||
|
||||
calculate_distribution_hash(grouped, counted, association_symbol)
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ class TicketPurchase < ActiveRecord::Base
|
|||
conference.tickets.each do |ticket|
|
||||
quantity = purchases[ticket.id.to_s].to_i
|
||||
# if the user bought the ticket and is still unpaid, just update the quantity
|
||||
if ticket.bought?(user) && ticket.unpaid?(user)
|
||||
purchase = update_quantity(conference, quantity, ticket, user)
|
||||
else
|
||||
purchase = purchase_ticket(conference, quantity, ticket, user)
|
||||
end
|
||||
purchase = if ticket.bought?(user) && ticket.unpaid?(user)
|
||||
update_quantity(conference, quantity, ticket, user)
|
||||
else
|
||||
purchase_ticket(conference, quantity, ticket, user)
|
||||
end
|
||||
|
||||
if purchase && !purchase.save
|
||||
errors.push(purchase.errors.full_messages)
|
||||
|
|
|
|||
|
|
@ -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,31 @@ 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
|
||||
|
||||
def to_param
|
||||
short_name
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_guid
|
||||
|
|
@ -38,4 +60,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
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ class User < ActiveRecord::Base
|
|||
# :lockable, :timeoutable and :omniauthable
|
||||
devise_modules = []
|
||||
|
||||
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||
devise_modules += [:ichain_authenticatable, :ichain_registerable, :omniauthable, omniauth_providers: []]
|
||||
else
|
||||
devise_modules += [:database_authenticatable, :registerable,
|
||||
devise_modules += if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||
[:ichain_authenticatable, :ichain_registerable, :omniauthable, omniauth_providers: []]
|
||||
else
|
||||
[:database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
|
||||
:omniauthable, omniauth_providers: [:suse, :google, :facebook, :github]]
|
||||
end
|
||||
end
|
||||
|
||||
devise(*devise_modules)
|
||||
|
||||
|
|
@ -55,6 +55,7 @@ class User < ActiveRecord::Base
|
|||
has_many :votes, dependent: :destroy
|
||||
has_many :voted_events, through: :votes, source: :events
|
||||
has_many :subscriptions, dependent: :destroy
|
||||
has_many :tracks, foreign_key: 'submitter_id'
|
||||
accepts_nested_attributes_for :roles
|
||||
|
||||
scope :admin, -> { where(is_admin: true) }
|
||||
|
|
|
|||
81
app/pdfs/ticket_pdf.rb
Normal file
81
app/pdfs/ticket_pdf.rb
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
class TicketPdf < Prawn::Document
|
||||
def initialize(conference, user, physical_ticket, ticket_layout, file_name)
|
||||
super(page_layout: ticket_layout, page_size: 'A4', filename: file_name)
|
||||
@user = user
|
||||
@physical_ticket = physical_ticket
|
||||
@conference = conference
|
||||
|
||||
@left = bounds.left
|
||||
@right = bounds.right
|
||||
@mid_vertical = (bounds.top - bounds.bottom) / 2
|
||||
@mid_horizontal = (bounds.right - bounds.left) / 2
|
||||
@x = 0
|
||||
|
||||
draw_first_square
|
||||
draw_second_square
|
||||
draw_third_square
|
||||
draw_fourth_square
|
||||
end
|
||||
|
||||
def draw_first_square
|
||||
move_down @mid_vertical
|
||||
dash(2, space: 1)
|
||||
stroke_horizontal_rule
|
||||
stroke_vertical_line bounds.top, bounds.bottom, at: @mid_horizontal
|
||||
move_up @mid_vertical
|
||||
draw_text 'TICKET HOLDER', at: [@x, cursor - 30], size: 17
|
||||
dash(2, space: 0)
|
||||
stroke_rectangle [@x, cursor - 50], 230, 150
|
||||
move_down 80
|
||||
draw_text 'NAME', at: [@x + 10, cursor], size: 13
|
||||
fill_color '808080'
|
||||
draw_text @user.name.to_s, at: [@x + 10, cursor - 25], size: 20
|
||||
fill_color '000000'
|
||||
draw_text 'EMAIL', at: [@x + 10, cursor - 50], size: 13
|
||||
fill_color '808080'
|
||||
draw_text @user.email.to_s, at: [@x + 10, cursor - 75], size: 20
|
||||
fill_color '000000'
|
||||
move_up 20
|
||||
end
|
||||
|
||||
def draw_second_square
|
||||
if @conference.picture?
|
||||
if 7 * @conference.picture.image[:width] > 12 * @conference.picture.image[:height]
|
||||
image "#{Rails.root}/public#{@conference.picture_url}", at: [@mid_horizontal + 30, cursor], width: 120
|
||||
else
|
||||
image "#{Rails.root}/public#{@conference.picture_url}", at: [@mid_horizontal + 30, cursor], height: 70
|
||||
end
|
||||
else
|
||||
image "#{Rails.root}/public/img/osem-logo.png", at: [@mid_horizontal + 30, cursor], height: 70
|
||||
end
|
||||
move_down 70
|
||||
draw_text @conference.title.to_s, at: [@mid_horizontal + 30, cursor - 30], size: 12
|
||||
draw_text @conference.organization.name.to_s, at: [@mid_horizontal + 30, cursor - 50], size: 12
|
||||
draw_text @conference.venue.name.to_s, at: [@mid_horizontal + 30, cursor - 70]
|
||||
move_up 130
|
||||
move_down @mid_vertical
|
||||
end
|
||||
|
||||
def draw_third_square
|
||||
draw_text 'EVENT', at: [@x, cursor - 40], size: 15
|
||||
fill_color '808080'
|
||||
draw_text @conference.title.to_s, at: [@x, cursor - 60], size: 12
|
||||
draw_text @conference.start_date.strftime('%B %d, %Y').to_s, at: [@x, cursor - 80], size: 12
|
||||
move_down 80
|
||||
fill_color '000000'
|
||||
draw_text 'TICKET', at: [@x, cursor - 30], size: 15
|
||||
fill_color '808080'
|
||||
draw_text @physical_ticket.ticket.title.to_s, at: [@x, cursor - 50], size: 12
|
||||
move_down 50
|
||||
fill_color '000000'
|
||||
draw_text 'TICKET REF.', at: [@x, cursor - 30], size: 15
|
||||
fill_color '808080'
|
||||
draw_text @physical_ticket.ticket_purchase.id.to_s, at: [@x, cursor - 50], size: 12
|
||||
move_down 50
|
||||
fill_color '000000'
|
||||
draw_text 'Powered By OSEM', at: [(@mid_horizontal - @left - 100) / 2, cursor - 100], size: 11
|
||||
move_up 180
|
||||
end
|
||||
|
||||
def draw_fourth_square; end
|
||||
end
|
||||
|
|
@ -60,7 +60,7 @@ class ConferenceSerializer < ActiveModel::Serializer
|
|||
|
||||
def date_range
|
||||
if defined? date_string(object.start_date, object.end_date)
|
||||
date_string(object.start_date, object.end_date).try(:split, ',').try(:first)
|
||||
date_string(object.start_date, object.end_date).try(:split, ',').try(:first)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
12
app/views/admin/cfps/_booths_cfp.html.haml
Normal file
12
app/views/admin/cfps/_booths_cfp.html.haml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
%dt
|
||||
Start Date
|
||||
%dd
|
||||
= @cfp.start_date.strftime('%A, %B %e. %Y')
|
||||
%dt
|
||||
End Date
|
||||
%dd
|
||||
= @cfp.end_date.strftime('%A, %B %e. %Y')
|
||||
%dt
|
||||
Days Left
|
||||
%dd
|
||||
= pluralize(@cfp.remaining_days, 'day')
|
||||
|
|
@ -1,6 +1,23 @@
|
|||
.text-center
|
||||
%h4 #{title}
|
||||
%canvas.doughnut_chart{ 'data-chart' => data.to_json }
|
||||
%canvas.doughnut_chart{ id: "dough_#{title}", 'data-chart' => data.to_json }
|
||||
- if data
|
||||
- data.each do |key, value|
|
||||
%span{ 'style' => "border-bottom: 3px solid #{value['color']}" } #{key}: #{value['value']}
|
||||
|
||||
:javascript
|
||||
$(document).ready( function(){
|
||||
|
||||
var d = $("#dough_#{title}");
|
||||
var dt = d.get(0).getContext('2d');
|
||||
|
||||
$(window).resize( respondCanvas );
|
||||
|
||||
function respondCanvas(){
|
||||
dt.canvas.width = 150;
|
||||
dt.canvas.height = 150;
|
||||
}
|
||||
|
||||
respondCanvas();
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,3 +27,21 @@
|
|||
%span{ 'style' => "border-bottom: 3px solid #{conference[:color]};", 'data-chart' => "#{name}" }
|
||||
%input{ 'type' => 'checkbox', 'name' => "#{conference[:short_title]}" }
|
||||
#{conference[:short_title]}
|
||||
|
||||
:javascript
|
||||
$(document).ready( function(){
|
||||
|
||||
var c = $("#line_chart_#{name}");
|
||||
var ct = c.get(0).getContext('2d');
|
||||
var container = $(c).parent();
|
||||
|
||||
$(window).resize( respondCanvas );
|
||||
|
||||
function respondCanvas(){
|
||||
c.attr('width', $(container).width() );
|
||||
c.attr('height', $(container).height() );
|
||||
}
|
||||
|
||||
respondCanvas();
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
%td
|
||||
= organization.name
|
||||
%td
|
||||
= organization.conferences.count
|
||||
= organization.conferences.upcoming.count
|
||||
%td
|
||||
= organization.conferences.count
|
||||
= organization.conferences.past.count
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_organization_path(organization),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
.text-muted
|
||||
= @role.description
|
||||
|
||||
= semantic_form_for @role, url: admin_conference_role_path(@conference.short_title, @role.name) do |f|
|
||||
= semantic_form_for @role, url: @url do |f|
|
||||
.row
|
||||
.col-md-5
|
||||
= f.input :description
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
- if ( can? :toggle_user, @role )
|
||||
%td.text-right
|
||||
= hidden_field_tag "role[user_ids][]", nil
|
||||
= check_box_tag @conference.short_title, @role.id, (@role.user_ids.include? user.id), method: :post, url: "/admin/conferences/#{@conference.short_title}/roles/#{@role.name}/toggle_user?user[email]=#{user.email}&user[state]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
|
||||
= check_box_tag @conference.short_title, @role.id, (@role.user_ids.include? user.id), method: :post, url: "#{@url}?user[email]=#{user.email}&user[state]=", class: 'switch-checkbox', data: { size: 'small', off_color: 'warning', on_text: 'Yes', off_text: 'No' }
|
||||
%td= user.id
|
||||
%td= user.name
|
||||
%td= user.email
|
||||
|
|
|
|||
|
|
@ -19,13 +19,24 @@
|
|||
%tr
|
||||
%td= role.id
|
||||
%td= role.name.titleize
|
||||
%td= role.description
|
||||
%td
|
||||
= role.description
|
||||
- if role.resource_type == '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
|
||||
= link_to 'Users', admin_conference_role_path(@conference.short_title, role.name), class: 'btn btn-success'
|
||||
- if can? :edit, role
|
||||
= link_to 'Edit', edit_admin_conference_role_path(@conference.short_title, role.name), class: 'btn btn-primary'
|
||||
- if role.resource_type == 'Track'
|
||||
= 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, 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
|
||||
= link_to 'Edit', edit_admin_conference_role_path(@conference.short_title, role.name), class: 'btn btn-primary'
|
||||
|
|
|
|||
|
|
@ -6,14 +6,20 @@
|
|||
Role
|
||||
= @role.name.titleize
|
||||
- if can? :edit, @role
|
||||
= link_to 'Edit', edit_admin_conference_role_path(@conference.short_title, @role.name), class: 'btn btn-primary pull-right'
|
||||
- if @track
|
||||
= 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
|
||||
= @role.description
|
||||
- if @track
|
||||
= link_to @track.name, admin_conference_program_track_path(@conference.short_title, @track)
|
||||
|
||||
|
||||
.row.col-md-3
|
||||
- if ( can? :toggle_user, @role ) && !@role.new_record?
|
||||
|
||||
= semantic_form_for :user, url: toggle_user_admin_conference_role_path(@conference.short_title, @role.name), method: :post do |u|
|
||||
= semantic_form_for :user, url: @url, method: :post do |u|
|
||||
|
||||
= u.label 'Add user by email: '
|
||||
.input-group
|
||||
|
|
|
|||
|
|
@ -8,9 +8,11 @@
|
|||
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
|
||||
= f.input :description, input_html: {rows: 2, data: { provide: 'markdown-editable' } }, hint: markdown_hint
|
||||
- if @track.self_organized?
|
||||
= f.input :cfp_active, label: 'Allow event submitters to select this track for their proposal'
|
||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||
|
|
|
|||
|
|
@ -11,29 +11,55 @@
|
|||
%th Name
|
||||
%th Short name
|
||||
%th Description
|
||||
%th Submitter
|
||||
%th Color
|
||||
%th State
|
||||
%th Included in the Cfp
|
||||
%th Actions
|
||||
%tbody
|
||||
- @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
|
||||
%td
|
||||
%p
|
||||
= truncate(track.description)
|
||||
%td
|
||||
- if track.self_organized?
|
||||
= link_to track.submitter.name, admin_user_path(track.submitter)
|
||||
- else
|
||||
N/A
|
||||
%td
|
||||
%span.label{style: "background-color: #{track.color}; color: #{ contrast_color(track.color) }"}
|
||||
= track.color
|
||||
%td
|
||||
- if track.self_organized?
|
||||
= track.state
|
||||
- else
|
||||
N/A
|
||||
%td
|
||||
- if track.self_organized?
|
||||
= check_box_tag "#{@conference.short_title}_#{track.short_name}", track.id, track.cfp_active,
|
||||
class: 'switch-checkbox', method: :patch,
|
||||
url: toggle_cfp_inclusion_admin_conference_program_track_path(@conference.short_title, id: track.short_name)+"?included=",
|
||||
data: { size: 'small',
|
||||
on_color: 'success',
|
||||
off_color: 'warning',
|
||||
on_text: 'Yes',
|
||||
off_text: 'No' }
|
||||
- else
|
||||
%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'
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
%span.fa.fa-cog
|
||||
Manage
|
||||
= conference.short_title
|
||||
- if (current_user.is_admin) || (current_user.has_role? :organizer, :any)
|
||||
- if can? :new, Conference.new
|
||||
%li
|
||||
= link_to(new_admin_conference_path) do
|
||||
%span.fa.fa-plus
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
%span.fa.fa-cog
|
||||
Manage
|
||||
= conference.short_title
|
||||
- if can? :create, Conference
|
||||
- if can? :new, Conference.new
|
||||
%li
|
||||
= link_to(new_admin_conference_path) do
|
||||
%span.fa.fa-plus
|
||||
|
|
|
|||
|
|
@ -60,13 +60,13 @@
|
|||
.dropdown-menu
|
||||
- if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||
= form_tag User.ichain_login_url do
|
||||
= text_field_tag 'username', nil, id: 'user_ichain_email_dd', placeholder: 'Username'
|
||||
= password_field_tag 'password', nil, id: 'user_ichain_password_dd', placeholder: 'Password'
|
||||
= text_field_tag 'username', nil, id: 'user_ichain_email_dd', class: 'form-control', placeholder: 'Username'
|
||||
= password_field_tag 'password', nil, id: 'user_ichain_password_dd', class: 'form-control', placeholder: 'Password'
|
||||
%button.btn.btn-success.btn-block Sign in
|
||||
- else
|
||||
= form_tag new_user_session_path do
|
||||
= text_field_tag 'user[login]', nil, id: 'user_login_dd', placeholder: 'Username / E-Mail'
|
||||
= password_field_tag 'user[password]', nil, id: 'user_password_dd', placeholder: 'Password'
|
||||
= text_field_tag 'user[login]', nil, id: 'user_login_dd', class: 'form-control', placeholder: 'Username / E-Mail'
|
||||
= password_field_tag 'user[password]', nil, id: 'user_password_dd', class: 'form-control', placeholder: 'Password'
|
||||
%p.text-right
|
||||
%small
|
||||
%label{for: 'user_remember_me'} Remember me
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@
|
|||
= link_to(admin_conferences_path()) do
|
||||
%span.fa.fa-home
|
||||
Administration
|
||||
- if can? :create, Conference
|
||||
- if can? :new, Conference.new
|
||||
=link_to(new_admin_conference_path) do
|
||||
%span.fa.fa-plus
|
||||
Create Conference
|
||||
New Conference
|
||||
-if @conference and @conference.id and can? :show, @conference
|
||||
%li
|
||||
= link_to(admin_conference_path(@conference.short_title)) do
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
prawn_document(filename: @file_name, page_layout: @ticket_layout, :page_size =>'A4' ) do |pdf|
|
||||
# Vertical Layout
|
||||
top = pdf.bounds.top
|
||||
bottom = pdf.bounds.bottom
|
||||
left = pdf.bounds.left
|
||||
right = pdf.bounds.right
|
||||
mid_vertical = (pdf.bounds.top-pdf.bounds.bottom)/2
|
||||
mid_horizontal = (pdf.bounds.right-pdf.bounds.left)/2
|
||||
x = 0
|
||||
|
||||
pdf.move_down mid_vertical
|
||||
pdf.dash(2, :space => 1)
|
||||
pdf.stroke_horizontal_rule
|
||||
pdf.stroke_vertical_line pdf.bounds.top, pdf.bounds.bottom, :at => mid_horizontal
|
||||
pdf.move_up mid_vertical
|
||||
pdf.draw_text "TICKET HOLDER", :at => [x,pdf.cursor-30], :size => 17
|
||||
pdf.dash(2, :space => 0)
|
||||
pdf.stroke_rectangle [x, pdf.cursor-50], 230, 150
|
||||
pdf.move_down 80
|
||||
pdf.draw_text "NAME", :at => [x+10,pdf.cursor], :size => 13
|
||||
pdf.fill_color "808080"
|
||||
pdf.draw_text "#{@user.name}", :at => [x+10,pdf.cursor-25], size: 20
|
||||
pdf.fill_color "000000"
|
||||
pdf.draw_text "EMAIL", :at => [x+10,pdf.cursor-50], :size => 13
|
||||
pdf.fill_color "808080"
|
||||
pdf.draw_text "#{@user.email}", :at => [x+10,pdf.cursor-75], size: 20
|
||||
pdf.fill_color "000000"
|
||||
pdf.move_up 20
|
||||
if @conference.picture?
|
||||
if 7 * @conference.picture.image[:width] > 12 * @conference.picture.image[:height]
|
||||
pdf.image "#{Rails.root}/public#{@conference.picture_url}", :at => [mid_horizontal+30, pdf.cursor], :width => 120
|
||||
else
|
||||
pdf.image "#{Rails.root}/public#{@conference.picture_url}", :at => [mid_horizontal+30, pdf.cursor], :height => 70
|
||||
end
|
||||
else
|
||||
pdf.image "#{Rails.root}/public/img/osem-logo.png", :at => [mid_horizontal+30, pdf.cursor], :height => 70
|
||||
end
|
||||
pdf.move_down 70
|
||||
pdf.draw_text "#{@conference.title}", :at => [mid_horizontal+30,pdf.cursor-30], :size => 12
|
||||
pdf.draw_text "#{@conference.organization.name}", :at => [mid_horizontal+30,pdf.cursor-50], :size => 12
|
||||
pdf.draw_text "#{@conference.venue.name}", :at => [mid_horizontal+30,pdf.cursor-70]
|
||||
pdf.move_up 130
|
||||
pdf.move_down mid_vertical
|
||||
pdf.draw_text "EVENT", :at => [x,pdf.cursor-40], :size => 15
|
||||
pdf.fill_color "808080"
|
||||
pdf.draw_text "#{@conference.title}", :at => [x,pdf.cursor-60], size: 12
|
||||
pdf.draw_text "#{@conference.start_date.strftime('%B %d, %Y')}", :at => [x,pdf.cursor-80], size: 12
|
||||
pdf.move_down 80
|
||||
pdf.fill_color "000000"
|
||||
pdf.draw_text "TICKET", :at => [x,pdf.cursor-30], :size => 15
|
||||
pdf.fill_color "808080"
|
||||
pdf.draw_text "#{@physical_ticket.ticket.title}", :at => [x,pdf.cursor-50], size: 12
|
||||
pdf.move_down 50
|
||||
pdf.fill_color "000000"
|
||||
pdf.draw_text "TICKET REF.", :at => [x,pdf.cursor-30], :size => 15
|
||||
pdf.fill_color "808080"
|
||||
pdf.draw_text "#{@physical_ticket.ticket_purchase.id}", :at => [x,pdf.cursor-50], size: 12
|
||||
pdf.move_down 50
|
||||
pdf.fill_color "000000"
|
||||
pdf.draw_text "Powered By OSEM", :at => [(mid_horizontal-left-100)/2,pdf.cursor-100], :size => 11
|
||||
pdf.move_up 180
|
||||
end
|
||||
17
app/views/tracks/_form.html.haml
Normal file
17
app/views/tracks/_form.html.haml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
.container
|
||||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1
|
||||
- if @track.new_record?
|
||||
New
|
||||
= @track.name
|
||||
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))) 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
|
||||
= f.input :description, input_html: {rows: 2, data: { provide: 'markdown-editable' } }, required: true, hint: markdown_hint
|
||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||
43
app/views/tracks/index.html.haml
Normal file
43
app/views/tracks/index.html.haml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
.container
|
||||
.row
|
||||
.col-md-12.page-header
|
||||
%h1
|
||||
Track requests for
|
||||
%span.notranslate
|
||||
= @conference.title
|
||||
|
||||
- if @tracks.any?
|
||||
.row
|
||||
.col-md-12
|
||||
%table.table.table-hover#tracks
|
||||
%thead
|
||||
%th Name
|
||||
%th Short name
|
||||
%th Description
|
||||
%th Color
|
||||
%th State
|
||||
%th Actions
|
||||
%tbody
|
||||
- @tracks.each do |track|
|
||||
%tr
|
||||
%td
|
||||
= link_to(conference_program_track_path(@conference.short_title, track)) do
|
||||
= track.name
|
||||
%td
|
||||
= track.short_name
|
||||
%td
|
||||
%p
|
||||
= truncate(track.description)
|
||||
%td
|
||||
%span.label{style: "background-color: #{track.color}; color: #{ contrast_color(track.color) }"}
|
||||
= track.color
|
||||
%td
|
||||
= track.state
|
||||
%td
|
||||
= link_to 'Edit', edit_conference_program_track_path(@conference.short_title, track),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
- if can? :create, @track
|
||||
= link_to "New Track request", new_conference_program_track_path(@conference.short_title), class: 'btn btn-success pull-right'
|
||||
26
app/views/tracks/show.html.haml
Normal file
26
app/views/tracks/show.html.haml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
.container
|
||||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1
|
||||
= @track.name
|
||||
Track
|
||||
.row
|
||||
.col-md-8
|
||||
%dl.dl-horizontal
|
||||
%dt
|
||||
Color:
|
||||
%dd
|
||||
%span.label{style: "background-color: #{@track.color}; color: #{ contrast_color(@track.color) }"}
|
||||
= @track.color
|
||||
%dt
|
||||
State:
|
||||
%dd
|
||||
= @track.state
|
||||
%dt
|
||||
Description
|
||||
%dd
|
||||
= @track.description
|
||||
.row
|
||||
.col-md-12.text-right
|
||||
= link_to 'Edit Track request', edit_conference_program_track_path(@conference.short_title, @track), class: 'btn btn-primary'
|
||||
Loading…
Add table
Add a link
Reference in a new issue