Sha256: 1c53c159306fdfb189cb0829f73ac7c1615e7053d5f4a539a87dcf222ceec4d0

Contents?: true

Size: 1.3 KB

Versions: 18

Compression:

Stored size: 1.3 KB

Contents

class EventsController < ApplicationController
  include SocialStream::Controllers::Objects

  before_filter :profile_or_current_subject!, :only => :index

  def index
    index! do |format|
      format.js {
        events_with_start_and_end
      }

      format.json {
        events_with_start_and_end

        render :json =>
          @events.
            map{ |e| e.to_json(:start => @start_time, :end => @end_time) }.flatten.to_json
      }
    end
  end

  def show
    show! do |format|
      format.html { 
        if request.xhr?
          render partial: 'show_modal'
        else
          redirect_to polymorphic_path([ @event.post_activity.receiver_subject, Event.new ], :at => @event.start_at.to_i)
        end
      }
    end
  end

  private

  def allowed_params
    [
      :start_at, :end_at, :all_day,
      :frequency,
      # Weekly
      :week_days,
      # Monthly
      :week_day_order, :week_day, :interval,
      :room_id
    ]
  end

  def events_with_start_and_end
    @start_time = Time.at(params[:start].to_i)
    @end_time   = Time.at(params[:end].to_i)

    subject = profile_or_current_subject

    @events = Event.followed_by(subject)

    if subject != current_subject
      @events = @events.shared_with(current_subject)
    end

    @events = @events.between(@start_time, @end_time)
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
social_stream-2.2.2 events/app/controllers/events_controller.rb
social_stream-events-2.2.1 app/controllers/events_controller.rb
social_stream-2.2.1 events/app/controllers/events_controller.rb
social_stream-2.2.0 events/app/controllers/events_controller.rb
social_stream-events-2.2.0 app/controllers/events_controller.rb
social_stream-2.1.1 events/app/controllers/events_controller.rb
social_stream-2.1.0 events/app/controllers/events_controller.rb
social_stream-events-2.1.0 app/controllers/events_controller.rb
social_stream-2.0.4 events/app/controllers/events_controller.rb
social_stream-events-2.0.2 app/controllers/events_controller.rb
social_stream-2.0.3 events/app/controllers/events_controller.rb
social_stream-2.0.2 events/app/controllers/events_controller.rb
social_stream-events-2.0.1 app/controllers/events_controller.rb
social_stream-2.0.1 events/app/controllers/events_controller.rb
social_stream-2.0.0 events/app/controllers/events_controller.rb
social_stream-events-2.0.0 app/controllers/events_controller.rb
social_stream-2.0.0.beta3 events/app/controllers/events_controller.rb
social_stream-events-2.0.0.beta3 app/controllers/events_controller.rb