Merge b9a2a80a75 into 24f0625be1
This commit is contained in:
commit
8384f7a00e
3 changed files with 82 additions and 1 deletions
|
|
@ -1,6 +1,13 @@
|
||||||
class ConferenceController < ApplicationController
|
class ConferenceController < ApplicationController
|
||||||
before_filter :respond_to_options
|
before_filter :respond_to_options
|
||||||
load_and_authorize_resource find_by: :short_title
|
load_and_authorize_resource find_by: :short_title
|
||||||
|
skip_before_filter :verify_authenticity_token, if: :json_request?
|
||||||
|
|
||||||
|
def json_request?
|
||||||
|
return false if request.request_method != 'GET'
|
||||||
|
return false if !request.format.json?
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@current = Conference.where('end_date >= ?', Date.current).order('start_date ASC')
|
@current = Conference.where('end_date >= ?', Date.current).order('start_date ASC')
|
||||||
|
|
@ -19,6 +26,11 @@ class ConferenceController < ApplicationController
|
||||||
else
|
else
|
||||||
@today = @conference.start_date.strftime('%Y-%m-%d')
|
@today = @conference.start_date.strftime('%Y-%m-%d')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.json { render json: @conference.as_json, callback: params[:callback] }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def gallery_photos
|
def gallery_photos
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,73 @@ class Conference < ActiveRecord::Base
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Builds out the model for returning a json response
|
||||||
|
#
|
||||||
|
#
|
||||||
|
def as_json(_options={})
|
||||||
|
super(
|
||||||
|
only: [
|
||||||
|
:description,
|
||||||
|
:end_date,
|
||||||
|
:logo,
|
||||||
|
:short_title,
|
||||||
|
:start_date,
|
||||||
|
:title,
|
||||||
|
],
|
||||||
|
include: {
|
||||||
|
difficulty_levels: {
|
||||||
|
only: [
|
||||||
|
:description,
|
||||||
|
:id,
|
||||||
|
:title,
|
||||||
|
]
|
||||||
|
},
|
||||||
|
event_types: {
|
||||||
|
only: [
|
||||||
|
:description,
|
||||||
|
:id,
|
||||||
|
:length,
|
||||||
|
:title,
|
||||||
|
]
|
||||||
|
},
|
||||||
|
rooms: {
|
||||||
|
only: [
|
||||||
|
:name,
|
||||||
|
:size,
|
||||||
|
],
|
||||||
|
include: {
|
||||||
|
events: {
|
||||||
|
only: [
|
||||||
|
:abstract,
|
||||||
|
:description,
|
||||||
|
:difficulty_level_id,
|
||||||
|
:event_type_id,
|
||||||
|
:guid,
|
||||||
|
:is_highlight,
|
||||||
|
:require_registration,
|
||||||
|
:start_time,
|
||||||
|
:subtitle,
|
||||||
|
:title,
|
||||||
|
:track_id,
|
||||||
|
],
|
||||||
|
methods: [
|
||||||
|
:speaker_names,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tracks: {
|
||||||
|
only: [
|
||||||
|
:description,
|
||||||
|
:id,
|
||||||
|
:name,
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Checks if the user is registered to the conference
|
# Checks if the user is registered to the conference
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,9 @@ class ConferenceSerializer < ActiveModel::Serializer
|
||||||
# FIXME: adjusting the format the DIRTY way, for oSC13.
|
# FIXME: adjusting the format the DIRTY way, for oSC13.
|
||||||
# If you think this is ugly, don't look at the methods below
|
# If you think this is ugly, don't look at the methods below
|
||||||
def date_range
|
def date_range
|
||||||
object.date_range_string.try(:split, ',').try(:first)
|
if defined? object.date_range_string
|
||||||
|
object.date_range_string.try(:split, ',').try(:first)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: just giving suseconferenceclient something to play with
|
# FIXME: just giving suseconferenceclient something to play with
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue