[feat] Use existing #happening_now method; respond to both html and json requests
This commit is contained in:
parent
034313cccb
commit
871457f65b
5 changed files with 5 additions and 12 deletions
|
|
@ -112,11 +112,6 @@ class ConferencesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def live_events
|
|
||||||
conference = Conference.find_by(short_title: params[:conference_id])
|
|
||||||
render json: conference.find_live_events.to_json
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def conference_finder_conditions
|
def conference_finder_conditions
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,11 @@ class SchedulesController < ApplicationController
|
||||||
).select(&:happening_now?)
|
).select(&:happening_now?)
|
||||||
@events_schedules = [] unless @events_schedules
|
@events_schedules = [] unless @events_schedules
|
||||||
@current_time = Time.now.in_time_zone(@conference.timezone)
|
@current_time = Time.now.in_time_zone(@conference.timezone)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.json { render json: @events_schedules.to_json }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def app
|
def app
|
||||||
|
|
|
||||||
|
|
@ -784,10 +784,6 @@ class Conference < ApplicationRecord
|
||||||
end_date < Time.current
|
end_date < Time.current
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_live_events
|
|
||||||
program.events.select(&:happening_now?)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Returns a different html colour for every i and consecutive colors are
|
# Returns a different html colour for every i and consecutive colors are
|
||||||
|
|
|
||||||
|
|
@ -154,8 +154,6 @@ Osem::Application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :conferences, only: [:index, :show] do
|
resources :conferences, only: [:index, :show] do
|
||||||
get 'live_events', to: 'conferences#live_events'
|
|
||||||
|
|
||||||
resources :booths do
|
resources :booths do
|
||||||
member do
|
member do
|
||||||
patch :withdraw
|
patch :withdraw
|
||||||
|
|
|
||||||
|
|
@ -48,5 +48,4 @@ describe ConferencesController do
|
||||||
expect(response.response_code).to eq(200)
|
expect(response.response_code).to eq(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue