add locales(tw) and plugin datas to member
This commit is contained in:
parent
e9e471cf9c
commit
6137eeb8b6
|
@ -6,6 +6,7 @@ class Activity
|
||||||
include OrbitModel::Status
|
include OrbitModel::Status
|
||||||
include MemberHelper
|
include MemberHelper
|
||||||
include Slug
|
include Slug
|
||||||
|
belongs_to :member_profile
|
||||||
|
|
||||||
# Language
|
# Language
|
||||||
field :activity_name, as: :slug_title, type: String, localize: true
|
field :activity_name, as: :slug_title, type: String, localize: true
|
||||||
|
@ -18,7 +19,14 @@ class Activity
|
||||||
field :activity_end_date, type: DateTime
|
field :activity_end_date, type: DateTime
|
||||||
field :note, type: String
|
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)
|
def get_plugin_data(fields_to_show)
|
||||||
plugin_datas = []
|
plugin_datas = []
|
||||||
|
@ -30,8 +38,59 @@ class Activity
|
||||||
plugin_datas
|
plugin_datas
|
||||||
end
|
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" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_activity')}' title='#{p.send(t)}'>#{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)
|
def get_plugin_field_data(field)
|
||||||
case field
|
case field
|
||||||
|
when "language"
|
||||||
|
value = self.language.nil? ? "" : I18n.t(self.language) rescue ""
|
||||||
when 'attendee'
|
when 'attendee'
|
||||||
path = OrbitHelper.url_to_plugin_show(self.member_profile.to_param, 'member') rescue '#'
|
path = OrbitHelper.url_to_plugin_show(self.member_profile.to_param, 'member') rescue '#'
|
||||||
value = "<a href='#{path}'>#{self.member_profile.name}</a>"
|
value = "<a href='#{path}'>#{self.member_profile.name}</a>"
|
||||||
|
@ -49,10 +108,20 @@ class Activity
|
||||||
value = self.year rescue ''
|
value = self.year rescue ''
|
||||||
when 'note'
|
when 'note'
|
||||||
value = self.note rescue ''
|
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 << "<li><a href='#{url}' target='_blank'>#{title}</li>"
|
||||||
|
end
|
||||||
|
value = files.join("")
|
||||||
else
|
else
|
||||||
value = self.send(field) rescue ''
|
value = self.send(field) rescue ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value
|
||||||
|
|
||||||
{
|
{
|
||||||
'key' => field,
|
'key' => field,
|
||||||
'title_class' => "activity-#{field.gsub('_','-')}-field",
|
'title_class' => "activity-#{field.gsub('_','-')}-field",
|
||||||
|
@ -61,4 +130,12 @@ class Activity
|
||||||
'value' => value
|
'value' => value
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
def add_http
|
||||||
|
unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
|
||||||
|
self.url = 'http://' + self.url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th class="span1"><%= t("personal_activity.participant") %></th>
|
<th class="span1"><%= t("personal_activity.participant") %></th>
|
||||||
<th class="span1"><%= t("personal_activity.year") %></th>
|
<th class="span1"><%= t("personal_activity.year") %></th>
|
||||||
<th class="span5"><%= t("personal_plugins.activity_name") %></th>
|
<th class="span5"><%= t("personal_activity.activity_name") %></th>
|
||||||
<th class="span1"><%= t("personal_plugins.activity_organizer") %></th>
|
<th class="span1"><%= t("personal_activity.activity_organizer") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="tbody_activity" class="sort-holder">
|
<tbody id="tbody_activity" class="sort-holder">
|
||||||
|
|
|
@ -13,3 +13,28 @@ en:
|
||||||
activity_end_date: "End Date"
|
activity_end_date: "End Date"
|
||||||
note: "Note"
|
note: "Note"
|
||||||
graph_by: "Graphy By"
|
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…"
|
|
@ -2,3 +2,39 @@ zh_tw:
|
||||||
module_name:
|
module_name:
|
||||||
activity: "教師參與展演活動"
|
activity: "教師參與展演活動"
|
||||||
personal_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: "搜尋中…"
|
||||||
|
|
|
@ -4,7 +4,7 @@ module PersonalActivity
|
||||||
OrbitApp.registration "PersonalActivity",:type=> 'ModuleApp' do
|
OrbitApp.registration "PersonalActivity",:type=> 'ModuleApp' do
|
||||||
module_label 'module_name.personal_activity'
|
module_label 'module_name.personal_activity'
|
||||||
base_url File.expand_path File.dirname(__FILE__)
|
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"
|
version "0.1"
|
||||||
desktop_enabled true
|
desktop_enabled true
|
||||||
|
|
Loading…
Reference in New Issue