diff --git a/app/models/activity.rb b/app/models/activity.rb
index 0f106c5..3c5ec0e 100644
--- a/app/models/activity.rb
+++ b/app/models/activity.rb
@@ -6,6 +6,7 @@ class Activity
include OrbitModel::Status
include MemberHelper
include Slug
+ belongs_to :member_profile
# Language
field :activity_name, as: :slug_title, type: String, localize: true
@@ -18,7 +19,14 @@ class Activity
field :activity_end_date, type: DateTime
field :note, type: String
- belongs_to :member_profile
+ # paginates_per 10
+
+ has_many :activity_files, :autosave => true, :dependent => :destroy
+ belongs_to :activity_category
+
+ accepts_nested_attributes_for :activity_files, :allow_destroy => true
+ before_validation :add_http
+ scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :publish_date => "desc") }
def get_plugin_data(fields_to_show)
plugin_datas = []
@@ -30,8 +38,59 @@ class Activity
plugin_datas
end
+ def self.get_plugin_datas_to_member(datas)
+ fields_to_show = [
+ "attendee",
+ "activity_name",
+ "activity_organizer",
+ "activity_area",
+ "activity_start_date",
+ "activity_end_date",
+ "year"
+ ]
+ fields_to_remove = []
+
+ pd_title = []
+
+ fields_to_show.each do |t|
+ if (self.fields[t].type.to_s == "String" || self.fields[t].type.to_s == "Object" rescue false)
+ fields_to_remove << t if (datas.where(t.to_sym.ne => nil, t.to_sym.ne => "").count == 0 rescue false)
+ else
+ fields_to_remove << t if (datas.where(t.to_sym.ne => nil).count == 0 rescue false)
+ end
+ pd_title << {
+ "plugin_data_title" => I18n.t("personal_activity.#{t}")
+ } if !fields_to_remove.include?(t)
+ end
+
+ fields_to_show = fields_to_show - fields_to_remove
+
+ plugin_datas = datas.sort_for_frontend.collect.with_index do |p, index|
+
+ pd_data = []
+ fields_to_show.collect do |t|
+ if t == "activity_title"
+ pd_data << { "data_title" => "#{p.send(t)}" }
+ elsif t == "activity_category"
+ pd_data << {"data_title" => (p.activity_category.title rescue "")}
+ else
+ pd_data << { "data_title" => p.send(t) }
+ end
+ end
+ {
+ "pd_datas" => pd_data,
+ "type-sort" => (p.activity_category.sort_position.to_i rescue -1),
+ "sort-index" => index
+ }
+ end
+ plugin_datas = plugin_datas.sort_by{|pd| [pd["type-sort"], pd["sort-index"]]}
+ return [pd_title,plugin_datas]
+ end
+
def get_plugin_field_data(field)
case field
+ when "language"
+ value = self.language.nil? ? "" : I18n.t(self.language) rescue ""
when 'attendee'
path = OrbitHelper.url_to_plugin_show(self.member_profile.to_param, 'member') rescue '#'
value = "#{self.member_profile.name}"
@@ -49,10 +108,20 @@ class Activity
value = self.year rescue ''
when 'note'
value = self.note rescue ''
+ when "file"
+ files = []
+ self.research_files.each do |research_file|
+ url = research_file.file.url
+ title = (research_file.title.blank? ? File.basename(research_file.file.path) : research_file.title)
+ files << "
#{title}"
+ end
+ value = files.join("")
else
value = self.send(field) rescue ''
end
+ value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "#{value}" : value
+
{
'key' => field,
'title_class' => "activity-#{field.gsub('_','-')}-field",
@@ -61,4 +130,12 @@ class Activity
'value' => value
}
end
+
+ protected
+ def add_http
+ unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
+ self.url = 'http://' + self.url
+ end
+ end
+
end
diff --git a/app/views/admin/activities/index.html.erb b/app/views/admin/activities/index.html.erb
index b2dae40..1ee9b57 100644
--- a/app/views/admin/activities/index.html.erb
+++ b/app/views/admin/activities/index.html.erb
@@ -4,8 +4,8 @@
<%= t("personal_activity.participant") %> |
<%= t("personal_activity.year") %> |
- <%= t("personal_plugins.activity_name") %> |
- <%= t("personal_plugins.activity_organizer") %> |
+ <%= t("personal_activity.activity_name") %> |
+ <%= t("personal_activity.activity_organizer") %> |
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 95b837c..7a8150b 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -13,3 +13,28 @@ en:
activity_end_date: "End Date"
note: "Note"
graph_by: "Graphy By"
+ file : "File"
+ file_name : "File name"
+ upload: "upload"
+ description : "File Description"
+ frontend:
+ researchs: "Activity Front-end"
+
+ create_success : "Successfully Create"
+ update_success : "Successfully Update"
+ delete_success : "Successfully Delete"
+ add: "Add"
+ back: "Back"
+ delete: "Delete"
+ edit: "Edit"
+ nothing: "Nothing"
+ show: "Show"
+ sure?: "Are you sure?"
+ update: "Update"
+ yes_: "Yes"
+ no_: "No"
+ cancel : "Cancel"
+ save: "save"
+ hintText: "Type in a search term"
+ noResultsText: "No results"
+ searchingText: "Searching…"
\ No newline at end of file
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index 3a2807d..2468422 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -2,3 +2,39 @@ zh_tw:
module_name:
activity: "教師參與展演活動"
personal_activity: "教師參與展演活動"
+ personal_activity:
+ attendee: "主辦人"
+ participant: "參與人"
+ year: "年度"
+ activity_name: "活動名稱"
+ activity_organizer: "活動組織"
+ activity_area: "地點"
+ activity_start_date: "開始時間"
+ activity_end_date: "結束時間"
+ note: "備註"
+ graph_by: "Graphy By"
+ file : "檔案"
+ file_name : "檔案名稱"
+ description : "描述"
+ upload: "上傳"
+ frontend:
+ writings: "活動前台"
+
+ create_success : "新增完成!!"
+ update_success : "更新完成!!"
+ delete_success : "刪除成功!!"
+ add: "新增"
+ back: "返回"
+ delete: "刪除"
+ edit: "編輯"
+ nothing: "無"
+ show: "顯示"
+ sure?: "您肯定嗎?"
+ update: "更新"
+ yes_: "是"
+ no_: "否"
+ cancel : "取消"
+ save: "儲存"
+ hintText: "請輸入搜尋關鍵字"
+ noResultsText: "沒有相關的比對結果"
+ searchingText: "搜尋中…"
diff --git a/lib/personal_activity/engine.rb b/lib/personal_activity/engine.rb
index d185e3b..5313702 100644
--- a/lib/personal_activity/engine.rb
+++ b/lib/personal_activity/engine.rb
@@ -4,7 +4,7 @@ module PersonalActivity
OrbitApp.registration "PersonalActivity",:type=> 'ModuleApp' do
module_label 'module_name.personal_activity'
base_url File.expand_path File.dirname(__FILE__)
- personal_plugin :enable => true, :sort_number => '6', :app_name=>"Activity", :intro_app_name=>"PersonalActivityIntro",:path=>"/plugin/personal_activity/profile",:front_path=>"/profile",:admin_path=>"/admin/activities",:i18n=>'module_name.personal_activity', :module_app_name=>'PersonalActivity', :one_line_title => true, :field_modifiable => true, :analysis => true, :analysis_path => "/admin/activities/analysis"
+ personal_plugin :enable => true, :sort_number => '20', :app_name=>"Activity", :intro_app_name=>"PersonalActivityIntro",:path=>"/plugin/personal_activity/profile",:front_path=>"/profile",:admin_path=>"/admin/activities",:i18n=>'module_name.personal_activity', :module_app_name=>'PersonalActivity', :one_line_title => true, :field_modifiable => true, :analysis => true, :analysis_path => "/admin/activities/analysis"
version "0.1"
desktop_enabled true