Sha256: 418666d2aa367bf5cd53216d377152b82ed21806c0ea03577c61440e6bfcfa2f

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

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

  before_filter :profile_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 { redirect_to polymorphic_path([ @event.post_activity.receiver_subject, Event.new ], :at => @event.start_at.to_i) }
    end
  end

  private

  def collection
    @activities =
      (profile_subject || current_subject).wall(:profile,
                           :for => current_subject,
                           :object_type => :Event)
  end

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

    @activities =
      collection.
      joins(:activity_objects => :event).
      merge(Event.between(@start_time, @end_time))

    @events = @activities.map(&:direct_object)
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
social_stream-0.27.2 events/app/controllers/events_controller.rb
social_stream-0.27.1 events/app/controllers/events_controller.rb
social_stream-events-0.13.1 app/controllers/events_controller.rb
social_stream-0.27.0 events/app/controllers/events_controller.rb
social_stream-events-0.13.0 app/controllers/events_controller.rb
social_stream-0.26.2 events/app/controllers/events_controller.rb
social_stream-0.26.1 events/app/controllers/events_controller.rb
social_stream-events-0.12.1 app/controllers/events_controller.rb