diff --git a/app/controllers/admin/calendars_controller.rb b/app/controllers/admin/calendars_controller.rb
index f8d26c5..ee5c2a6 100644
--- a/app/controllers/admin/calendars_controller.rb
+++ b/app/controllers/admin/calendars_controller.rb
@@ -118,6 +118,10 @@ class Admin::CalendarsController < OrbitAdminController
@event = Event.find(params[:id])
p = event_page_params
p["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])
+ end
if @event.update_attributes(p)
e = @event.to_json
e = JSON.parse(e)
@@ -136,6 +140,10 @@ class Admin::CalendarsController < OrbitAdminController
# DELETE /events/1.json
def destroy
@event = Event.find(params[:id])
+ bulletin = @event.bulletin
+ if !bulletin.nil?
+ bulletin.update_attributes(event_id: nil,add_to_calendar: '0')
+ end
@event.destroy
render :json => {"success"=>true}.to_json
# respond_to do |format|
diff --git a/app/models/event.rb b/app/models/event.rb
index 35b88e6..0d1e310 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -11,19 +11,21 @@ class Event
field :note
field :start, type: DateTime
field :end, type: DateTime
- field :all_day, type: Boolean
- field :recurring, type: Boolean
+ field :all_day, type: Boolean,default: false
+ field :recurring, type: Boolean,default: false
field :frequency
field :period
field :create_user_id
field :update_user_id
-
+ field :bulletin_id
belongs_to :calendar_type
attr_accessor :agenda_start, :agenda_end, :get_agenda_events
validates_presence_of :title, :message => "Please fill the title of the Event"
-
+ def bulletin
+ Bulletin.find(self.bulletin_id) rescue nil
+ end
def self.format_date(date_time)
Time.at(date_time.to_i).to_formatted_s(:db)
end
diff --git a/app/views/admin/calendars/_form.html.erb b/app/views/admin/calendars/_form.html.erb
index 4c1d496..43df93b 100644
--- a/app/views/admin/calendars/_form.html.erb
+++ b/app/views/admin/calendars/_form.html.erb
@@ -9,13 +9,13 @@
<% end %>
- <%= f.label :title, :class=>"control-label" %>
+ <%= f.label t("title"), :class=>"control-label" %>
<%= f.text_field :title %>
- <%= f.label :note, :class=>"control-label" %>
+ <%= f.label t("calendar.note"), :class=>"control-label" %>
<%= f.text_area :note, :rows => 3 %>
@@ -24,12 +24,12 @@
- <%= f.label :start, :class=>"control-label" %>
+ <%= f.label t("start_date"), :class=>"control-label" %>
<%#= f.datetime_select :start %>
- <%= f.label :end, :class=>"control-label" %>
+ <%= f.label t("end_date"), :class=>"control-label" %>
<%#= f.datetime_select :end %>
- <%= f.label "Calendar", :class=>"control-label" %>
+ <%= f.label t("calendar.calendar"), :class=>"control-label" %>
<%= f.select :calendar_type_id, @categories.collect{|t| [ t.title, t.id ]} %>
@@ -69,15 +69,15 @@
>
- <%=f.label :period, "Repeats",:class=>"control-label" %>
+ <%=f.label :period, t("calendar.repeats"),:class=>"control-label" %>
- <%=f.select :period, Event::REPEATS,{},:class=>"span5" %>
+ <%=f.select :period, Event::REPEATS.map{|v| [t("calendar.#{v.downcase}"),v]},{},:class=>"span5" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 52e9b16..1b3c11d 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -9,3 +9,11 @@ en:
select_calendar: "Select Calendar"
categories: Categories
new_category: New Category
+ all_day: All Day
+ note: Note
+ repeats: Repeats
+ recurring: Recurring
+ daily: Daily
+ weekly: Weekly
+ monthly: Monthly
+ yearly: Yearly
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index 7a4217e..01356cb 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -6,4 +6,12 @@ zh_tw:
name: 名稱
save: 儲存
select_calendar: 選取行事曆
- categories: 類別
\ No newline at end of file
+ categories: 類別
+ all_day: 全天
+ note: 註記
+ repeats: 重複
+ recurring: 週期性
+ daily: 每天
+ weekly: 每週
+ monthly: 每月
+ yearly: 每年
\ No newline at end of file