Compare commits
4 Commits
77d98f9f71
...
89b184f776
Author | SHA1 | Date |
---|---|---|
Tocho Tochev | 89b184f776 | |
Petko Bordjukov | deebcbc95a | |
Tocho Tochev | 5660c3ef53 | |
Petko Bordjukov | 71e8ab74da |
|
@ -0,0 +1,9 @@
|
||||||
|
class Api::SchedulesController < Api::ApplicationController
|
||||||
|
include ::CurrentConferenceAssigning
|
||||||
|
include ::PublicApiExposing
|
||||||
|
before_action :require_current_conference!
|
||||||
|
|
||||||
|
def show
|
||||||
|
@halls = Conference.last.halls.includes(:translations, slots: {approved_event: [:participants_with_personal_profiles, :proposition]})
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,7 +8,11 @@ module Management
|
||||||
private
|
private
|
||||||
|
|
||||||
def authorize_user!
|
def authorize_user!
|
||||||
head :forbidden unless current_user.admin?
|
if params[:conference_id] && params[:conference_id].to_i < Conference.last.id
|
||||||
|
head :forbidden unless current_user.admin? && current_user.owner?
|
||||||
|
else
|
||||||
|
head :forbidden unless current_user.admin?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,6 +22,7 @@ class Event < ActiveRecord::Base
|
||||||
|
|
||||||
scope :ranked, -> { where.not(ranked: nil).where.not(votes: nil) }
|
scope :ranked, -> { where.not(ranked: nil).where.not(votes: nil) }
|
||||||
scope :approved, -> { where(propositions: {status: Proposition.statuses[:approved]})}
|
scope :approved, -> { where(propositions: {status: Proposition.statuses[:approved]})}
|
||||||
|
scope :approved_joined, -> { joins(:proposition).merge(Proposition.approved) }
|
||||||
|
|
||||||
validates :conference, presence: true
|
validates :conference, presence: true
|
||||||
validates :title, presence: true, length: {maximum: 65}
|
validates :title, presence: true, length: {maximum: 65}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class Slot < ActiveRecord::Base
|
class Slot < ActiveRecord::Base
|
||||||
belongs_to :hall
|
belongs_to :hall
|
||||||
belongs_to :event, required: false
|
belongs_to :event, required: false
|
||||||
|
belongs_to :approved_event, -> { joins(:proposition).approved_joined }, class_name: 'Event', foreign_key: 'event_id'
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
@halls.each do |hall|
|
||||||
|
json.set! hall.name do
|
||||||
|
json.days do
|
||||||
|
hall.slots.to_a.sort_by(&:starts_at).group_by { |slot| slot.starts_at.to_date }.each do |day, slots|
|
||||||
|
json.set! day do
|
||||||
|
json.array! slots do |slot|
|
||||||
|
next unless slot.approved_event
|
||||||
|
json.starts_at slot.starts_at
|
||||||
|
json.starts_at_human l(slot.starts_at, format: '%a, %H:%M')
|
||||||
|
json.title slot.approved_event.title
|
||||||
|
json.speakers do
|
||||||
|
json.array! slot.approved_event.participants_with_personal_profiles do |participant|
|
||||||
|
json.name participant.name
|
||||||
|
json.email participant.public_email
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -32,6 +32,7 @@ Rails.application.routes.draw do
|
||||||
resources :event_types, only: :index
|
resources :event_types, only: :index
|
||||||
resources :halls, only: :index
|
resources :halls, only: :index
|
||||||
resources :slots, only: :index
|
resources :slots, only: :index
|
||||||
|
resource :schedule, only: :show
|
||||||
resources :volunteers
|
resources :volunteers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddOwnerFieldToUsers < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
add_column :users, :owner, :boolean, null: false, default: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,4 +11,5 @@ User.create(
|
||||||
password_confirmation: "123qweASD",
|
password_confirmation: "123qweASD",
|
||||||
confirmed_at: Time.current,
|
confirmed_at: Time.current,
|
||||||
admin: true
|
admin: true
|
||||||
|
owner: true
|
||||||
)
|
)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,7 @@ FactoryBot.define do
|
||||||
|
|
||||||
factory :administrator do
|
factory :administrator do
|
||||||
admin { true }
|
admin { true }
|
||||||
|
owner { true }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue