diff --git a/app/controllers/admin/calendars_controller.rb b/app/controllers/admin/calendars_controller.rb index c41adb3..3792799 100644 --- a/app/controllers/admin/calendars_controller.rb +++ b/app/controllers/admin/calendars_controller.rb @@ -60,7 +60,7 @@ class Admin::CalendarsController < OrbitAdminController # GET /events/new # GET /events/new.json def new - @event = Event.new + @event = Event.new(start: params[:startDate],end: params[:endDate]) categories = user_authenticated_categories rescue [] if categories.first == "all" @categories = CalendarType.all @@ -130,13 +130,13 @@ class Admin::CalendarsController < OrbitAdminController # PUT /events/1.json def update @event = Event.find(params[:id]) - p = event_page_params - p["update_user_id"] = current_user.id + p1 = event_page_params + p1["update_user_id"] = current_user.id bulletin = @event.bulletin if !bulletin.nil? - bulletin.update_attributes(calendar_start_date: p[:start],calendar_end_date: p[:end],calendar_all_day: p[:all_day],calendar_type_id: p[:calendar_type_id]) + bulletin.update_attributes(calendar_start_date: p1[:start],calendar_end_date: p1[:end],calendar_all_day: p1[:all_day],calendar_type_id: p1[:calendar_type_id]) end - if @event.update_attributes!(p) + if @event.update_attributes(p1) e = @event.to_json e = JSON.parse(e) e["can_edit"] = true diff --git a/app/models/event.rb b/app/models/event.rb index 7d6d0a5..15d70bd 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -44,6 +44,7 @@ class Event if !m.nil? if self.key.nil? m.event_id = nil + m.add_to_calendar = false else m.calendar_dict.delete(self.key) if !m['calendar_data'].nil? @@ -56,11 +57,15 @@ class Event end end end + before_save do + self['title_translations'] = self['title_translations'].merge({I18n.locale.to_s =>self['title']}) + self['note_translations'] = self['title_translations'].merge({I18n.locale.to_s =>self['note']}) + end ######################################## validates_presence_of :title, :message => "Please fill the title of the Event", :if => lambda { self['title_translations'].blank? } validates_presence_of :title_translations, :message => "Please fill the title of the Event", :if => lambda { self['title'].blank? } def title - tp = self['title_translations'][I18n.locale] + tp = self['title_translations'][I18n.locale] rescue nil tp.blank? ? self['title'] : tp end def note @@ -76,7 +81,7 @@ class Event end end def bulletin - Bulletin.find(self.bulletin_id) rescue nil + model_class=='Bulletin' ? (Bulletin.find(self.model_id) rescue nil) : nil end def self.format_date(date_time) Time.at(date_time.to_i).to_formatted_s(:db) diff --git a/app/views/admin/calendars/_form.html.erb b/app/views/admin/calendars/_form.html.erb index eb92edb..8c05c6f 100644 --- a/app/views/admin/calendars/_form.html.erb +++ b/app/views/admin/calendars/_form.html.erb @@ -1,3 +1,4 @@ +<%= javascript_include_tag 'jquery.base64' %> <% if @event.errors.any? %>