From 54f778f17dec7cb64ba6f2faf476277434ca8310 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Mon, 4 Nov 2013 23:02:01 +0800 Subject: [PATCH] Updated Calendar frontend --- .../front_end/events_controller.rb | 45 +++++++++++++++++++ .../calendar_new/config/routes.rb | 8 ++-- vendor/built_in_modules/calendar_new/init.rb | 2 +- 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 vendor/built_in_modules/calendar_new/app/controllers/panel/calendar_new/front_end/events_controller.rb diff --git a/vendor/built_in_modules/calendar_new/app/controllers/panel/calendar_new/front_end/events_controller.rb b/vendor/built_in_modules/calendar_new/app/controllers/panel/calendar_new/front_end/events_controller.rb new file mode 100644 index 00000000..6e82688d --- /dev/null +++ b/vendor/built_in_modules/calendar_new/app/controllers/panel/calendar_new/front_end/events_controller.rb @@ -0,0 +1,45 @@ +class Panel::CalendarNew::FrontEnd::EventsController < OrbitWidgetController + # GET /events + # GET /events.json + def initialize + super + @app_title = 'calendar' + end + + def index + @item = Page.find(params[:page_id]) + @title = @item.title + if !@item.frontend_data_count.blank? + @page_num = @item.frontend_data_count + else + @page_num = 10 + end + + if params[:start].present? && params[:end].present? + sdt = Time.at(params[:start].to_i) + edt = Time.at(params[:end].to_i) + @monthly_events = Event.monthly_event(sdt,edt) + @re = Event.recurring_event(sdt,edt) + @events = @monthly_events.inject(@re, :<<) + end + respond_to do |format| + format.html # index.html.erb + format.json { render json: @events } + end + end + def show + @event = Event.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @event } + end + end + + def agenda + agenda_start = Date.parse(params[:agenda_start]) + agenda_end = Date.parse(params[:agenda_end]) + @events = Event.agenda_events(agenda_start,agenda_end) + render :json=>@events.to_json + end +end \ No newline at end of file diff --git a/vendor/built_in_modules/calendar_new/config/routes.rb b/vendor/built_in_modules/calendar_new/config/routes.rb index fd411537..d097d2c1 100644 --- a/vendor/built_in_modules/calendar_new/config/routes.rb +++ b/vendor/built_in_modules/calendar_new/config/routes.rb @@ -8,10 +8,10 @@ Rails.application.routes.draw do resources :events end - namespace :front_end do - match 'events/agenda' => 'events#agenda', :as => :agenda - resources :events - end + namespace :front_end do + match 'events/agenda' => 'events#agenda', :as => :agenda + resources :events, except: [:new, :edit, :update, :destroy] + end end end end diff --git a/vendor/built_in_modules/calendar_new/init.rb b/vendor/built_in_modules/calendar_new/init.rb index b95f9d45..486f10ec 100644 --- a/vendor/built_in_modules/calendar_new/init.rb +++ b/vendor/built_in_modules/calendar_new/init.rb @@ -16,7 +16,7 @@ module CalendarNew front_end do app_page 'events' do - frontend_i18n "calendar_new.frontend.events" + frontend_i18n "calendar_new.frontend.events" end end