From 6137eeb8b610d74b8f93f840b728f73e06664ee1 Mon Sep 17 00:00:00 2001 From: bohung Date: Wed, 1 Apr 2020 16:02:23 +0800 Subject: [PATCH 1/8] add locales(tw) and plugin datas to member --- app/models/activity.rb | 79 ++++++++++++++++++++++- app/views/admin/activities/index.html.erb | 4 +- config/locales/en.yml | 25 +++++++ config/locales/zh_tw.yml | 36 +++++++++++ lib/personal_activity/engine.rb | 2 +- 5 files changed, 142 insertions(+), 4 deletions(-) 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 From b845b3c835813979f3bb9724c2762ce8e23cdd4d Mon Sep 17 00:00:00 2001 From: Chihyu Date: Mon, 6 Apr 2020 15:40:47 +0800 Subject: [PATCH 2/8] add index paginates --- app/controllers/admin/activities_controller.rb | 11 +++++++---- app/controllers/personal_activities_controller.rb | 3 ++- app/models/activity.rb | 3 +-- lib/personal_activity/engine.rb | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/activities_controller.rb b/app/controllers/admin/activities_controller.rb index d391a34..2c048fa 100644 --- a/app/controllers/admin/activities_controller.rb +++ b/app/controllers/admin/activities_controller.rb @@ -10,15 +10,18 @@ class Admin::ActivitiesController < OrbitMemberController def index @activities = Activity.order_by(:year => 'desc').page(params[:page]).per(10) - respond_to do |format| - format.html - format.xml { render :xml => @activities } - end + #respond_to do |format| + #format.html + #format.xml { render :xml => @activities } + #end end def new @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil @activity = Activity.new + if params[:desktop] + render :layout => false + end end def create diff --git a/app/controllers/personal_activities_controller.rb b/app/controllers/personal_activities_controller.rb index 252047a..378c0ec 100644 --- a/app/controllers/personal_activities_controller.rb +++ b/app/controllers/personal_activities_controller.rb @@ -34,7 +34,8 @@ class PersonalActivitiesController < ApplicationController 'activity_end_date' => t('personal_activity.activity_end_date'), 'year' => t('personal_activity.year'), 'note' => t('personal_activity.note') - } + }, + "total_pages" => activities.total_pages } end diff --git a/app/models/activity.rb b/app/models/activity.rb index 3c5ec0e..4e740e8 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -45,8 +45,7 @@ class Activity "activity_organizer", "activity_area", "activity_start_date", - "activity_end_date", - "year" + "activity_end_date" ] fields_to_remove = [] diff --git a/lib/personal_activity/engine.rb b/lib/personal_activity/engine.rb index 5313702..ef28981 100644 --- a/lib/personal_activity/engine.rb +++ b/lib/personal_activity/engine.rb @@ -14,7 +14,7 @@ module PersonalActivity update_info 'some update_info' frontend_enabled - data_count 1..10 + data_count 1..30 icon_class_no_sidebar "icons-user" end end From 5a4b3088f9b4c75d869a169d204109291df31fdc Mon Sep 17 00:00:00 2001 From: Chihyu Date: Mon, 6 Apr 2020 16:36:42 +0800 Subject: [PATCH 3/8] fix data_count error --- .../admin/activities_controller.rb | 99 +++++++++++++++++-- app/models/activity.rb | 17 ++-- app/models/activity_file.rb | 10 ++ app/models/activity_intro.rb | 2 + config/locales/zh_tw.yml | 2 +- 5 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 app/models/activity_file.rb create mode 100644 app/models/activity_intro.rb diff --git a/app/controllers/admin/activities_controller.rb b/app/controllers/admin/activities_controller.rb index 2c048fa..2bc59ea 100644 --- a/app/controllers/admin/activities_controller.rb +++ b/app/controllers/admin/activities_controller.rb @@ -2,11 +2,12 @@ class Admin::ActivitiesController < OrbitMemberController layout "member_plugin" include Admin::PersonalActivitiesHelper - before_action :set_activity, only: [:edit, :update, :destroy] - #before_action :set_plugin + before_action :set_activity, only: [:show, :edit, :update, :destroy] + before_action :set_plugin + before_action :get_settings,:only => [:new, :edit, :setting] - #before_action :need_access_right - #before_action :allow_admin_only, :only => [:index, :setting] + before_action :need_access_right + before_action :allow_admin_only, :only => [:index, :setting] def index @activities = Activity.order_by(:year => 'desc').page(params[:page]).per(10) @@ -27,22 +28,56 @@ class Admin::ActivitiesController < OrbitMemberController def create if !activity_params['member_profile_id'].blank? @member = MemberProfile.find(activity_params['member_profile_id']) rescue nil + @activity = Activity.new(activity_params) + @activity.save + + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + else + redirect_to params['referer_url'] + end + elsif !params[:author_members].blank? - activity_params['member_profile_id'] = params[:author_members] + + params[:author_members].each do |author_member| + activity_params['member_profile_id'] = author_member + @activity = Activity.new(activity_params) + @activity.save + + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + end + end + redirect_to params['referer_url'] else - activity_params['member_profile_id'] = current_user.member_profile_id + activity_params['member_profile_id'] = User.find(current_user.id).member_profile_id + @activity = Activity.new(activity_params) + @activity.save + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + end + redirect_to params['referer_url'] end - @activity = Activity.new(activity_params) - @activity.save - redirect_to params['referer_url'] + end + def edit + @member = @activity.member_profile rescue nil + if params[:desktop] + render :layout => false + end end def update + @member = @activity.member_profile rescue nil @activity.update_attributes(activity_params) - redirect_to params['referer_url'] + @activity.save + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + else + redirect_to params['referer_url'] + end end def destroy @@ -54,6 +89,7 @@ class Admin::ActivitiesController < OrbitMemberController end end + def analysis end @@ -105,6 +141,45 @@ class Admin::ActivitiesController < OrbitMemberController end end + def toggle_hide + if params[:ids] + @activities = Activity.any_in(_id: params[:ids]) + @activities.each do |activity| + activity.is_hidden = params[:disable] + activity.save + end + end + render json: {"success"=>true} + end + + def setting + end + + def frontend_setting + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @intro = ActivityIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? ActivityIntro.new({:member_profile_id=>@member.id}) : @intro + end + + def update_frontend_setting + @member = MemberProfile.find(intro_params['member_profile_id']) rescue nil + @intro = ActivityIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? ActivityIntro.new({:member_profile_id=>@member.id}) : @intro + @intro.update_attributes(intro_params) + @intro.save + redirect_to URI.encode('/admin/members/'+@member.to_param+'/activity') + end + + def get_settings + end + + def set_plugin + @plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Activity'}.first + @module_app = ModuleApp.where(:key=>'personal_activity').first + @module_app = ModuleApp.create(:key=>'personal_activity',:title=>'PersonalActivity','frontend_enable'=>true) if @module_app.nil? + @categories = @module_app.categories + end + private def set_activity @@ -122,4 +197,8 @@ class Admin::ActivitiesController < OrbitMemberController def activity_params params.require(:activity).permit! rescue nil end + + def intro_params + params.require(:activity_intro).permit! rescue nil + end end diff --git a/app/models/activity.rb b/app/models/activity.rb index 4e740e8..464af9e 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -4,8 +4,9 @@ class Activity #include Mongoid::Attributes::Dynamic #include Admin::PersonalActivitiesHelper include OrbitModel::Status - include MemberHelper + #include MemberHelper include Slug + include OrbitCategory::Categorizable belongs_to :member_profile # Language @@ -18,11 +19,12 @@ class Activity field :activity_start_date, type: DateTime field :activity_end_date, type: DateTime field :note, type: String + field :url # paginates_per 10 has_many :activity_files, :autosave => true, :dependent => :destroy - belongs_to :activity_category + #belongs_to :activity_category accepts_nested_attributes_for :activity_files, :allow_destroy => true before_validation :add_http @@ -52,7 +54,7 @@ class Activity 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) + if (self.fields[t].type.to_s == "String" 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) @@ -64,25 +66,20 @@ class Activity fields_to_show = fields_to_show - fields_to_remove - plugin_datas = datas.sort_for_frontend.collect.with_index do |p, index| + plugin_datas = datas.sort_for_frontend.collect do |p| 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 + "pd_datas" => pd_data } end - plugin_datas = plugin_datas.sort_by{|pd| [pd["type-sort"], pd["sort-index"]]} return [pd_title,plugin_datas] end diff --git a/app/models/activity_file.rb b/app/models/activity_file.rb new file mode 100644 index 0000000..1c827aa --- /dev/null +++ b/app/models/activity_file.rb @@ -0,0 +1,10 @@ +class ActivityFile + include Mongoid::Document + include Mongoid::Timestamps + mount_uploader :file, AssetUploader + field :description, localize: true + field :should_destroy, :type => Boolean + field :title, localize: true + + belongs_to :activity + end \ No newline at end of file diff --git a/app/models/activity_intro.rb b/app/models/activity_intro.rb new file mode 100644 index 0000000..32e4d80 --- /dev/null +++ b/app/models/activity_intro.rb @@ -0,0 +1,2 @@ +class ActivityIntro < PersonalPluginIntro +end \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 2468422..a31fc1c 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -18,7 +18,7 @@ zh_tw: description : "描述" upload: "上傳" frontend: - writings: "活動前台" + activities: "活動前台" create_success : "新增完成!!" update_success : "更新完成!!" From abb46c72b340502a766f6ea127b175ba95177ea7 Mon Sep 17 00:00:00 2001 From: bohung Date: Mon, 10 Aug 2020 18:48:55 +0800 Subject: [PATCH 4/8] Fix bug. --- Gemfile.lock | 104 ++++++++++++++++++++++++++++++++++++++ personal_activity.gemspec | 2 +- 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..3026279 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,104 @@ +PATH + remote: . + specs: + personal-activity (0.0.1) + mongoid (= 4.0.0.beta2) + rails (= 4.1.0.rc2) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.1.0.rc2) + actionpack (= 4.1.0.rc2) + actionview (= 4.1.0.rc2) + mail (~> 2.5.4) + actionpack (4.1.0.rc2) + actionview (= 4.1.0.rc2) + activesupport (= 4.1.0.rc2) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.0.rc2) + activesupport (= 4.1.0.rc2) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.0.rc2) + activesupport (= 4.1.0.rc2) + builder (~> 3.1) + activerecord (4.1.0.rc2) + activemodel (= 4.1.0.rc2) + activesupport (= 4.1.0.rc2) + arel (~> 5.0.0) + activesupport (4.1.0.rc2) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + arel (5.0.1.20140414130214) + bson (2.3.0) + builder (3.2.2) + connection_pool (2.0.0) + erubis (2.7.0) + hike (1.2.3) + i18n (0.6.9) + json (1.8.1) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.25.1) + minitest (5.3.4) + mongoid (4.0.0.beta2) + activemodel (>= 4.0.0) + moped (~> 2.0.beta6) + origin (~> 2.1) + tzinfo (>= 0.3.37) + moped (2.0.0.rc1) + bson (~> 2.2) + connection_pool (~> 2.0) + optionable (~> 0.2.0) + multi_json (1.10.1) + optionable (0.2.0) + origin (2.1.1) + polyglot (0.3.5) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.1.0.rc2) + actionmailer (= 4.1.0.rc2) + actionpack (= 4.1.0.rc2) + actionview (= 4.1.0.rc2) + activemodel (= 4.1.0.rc2) + activerecord (= 4.1.0.rc2) + activesupport (= 4.1.0.rc2) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.0.rc2) + sprockets-rails (~> 2.0.0) + railties (4.1.0.rc2) + actionpack (= 4.1.0.rc2) + activesupport (= 4.1.0.rc2) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.3.2) + sprockets (2.12.1) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.0.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + thor (0.19.1) + thread_safe (0.3.4) + tilt (1.4.1) + treetop (1.4.15) + polyglot + polyglot (>= 0.3.1) + tzinfo (1.2.1) + thread_safe (~> 0.1) + +PLATFORMS + ruby + +DEPENDENCIES + personal-activity! diff --git a/personal_activity.gemspec b/personal_activity.gemspec index e6c5c6f..603cf35 100644 --- a/personal_activity.gemspec +++ b/personal_activity.gemspec @@ -5,7 +5,7 @@ require "personal_activity/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "personal_activity" + s.name = "personal-activity" s.version = PersonalActivity::VERSION s.authors = ["Ruling Digital Inc."] s.email = ["orbit@rulingcom.com"] From 36476e5e7787dcb0f487ca0097d100066043201d Mon Sep 17 00:00:00 2001 From: bohung Date: Mon, 10 Aug 2020 21:49:12 +0800 Subject: [PATCH 5/8] Fix bug. --- Gemfile.lock | 4 ++-- personal_activity.gemspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3026279..41c7197 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - personal-activity (0.0.1) + personal_activity (0.0.1) mongoid (= 4.0.0.beta2) rails (= 4.1.0.rc2) @@ -101,4 +101,4 @@ PLATFORMS ruby DEPENDENCIES - personal-activity! + personal_activity! diff --git a/personal_activity.gemspec b/personal_activity.gemspec index 603cf35..e6c5c6f 100644 --- a/personal_activity.gemspec +++ b/personal_activity.gemspec @@ -5,7 +5,7 @@ require "personal_activity/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "personal-activity" + s.name = "personal_activity" s.version = PersonalActivity::VERSION s.authors = ["Ruling Digital Inc."] s.email = ["orbit@rulingcom.com"] From 6f2f5fbf348bb65787ce2aa8b3e5ab90c400e9dc Mon Sep 17 00:00:00 2001 From: bohung Date: Tue, 11 Aug 2020 00:08:52 +0800 Subject: [PATCH 6/8] Push template modules files and change date format to "%Y-%m-%d". --- app/models/activity.rb | 6 +- modules/personal_activity/index.html.erb | 35 ++++++++++ .../personal_activity/index_search1.html.erb | 62 ++++++++++++++++++ modules/personal_activity/info.json | 12 ++++ modules/personal_activity/show.html.erb | 8 +++ modules/personal_activity/thumbs/thumb.png | Bin 0 -> 4075 bytes 6 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 modules/personal_activity/index.html.erb create mode 100644 modules/personal_activity/index_search1.html.erb create mode 100644 modules/personal_activity/info.json create mode 100644 modules/personal_activity/show.html.erb create mode 100644 modules/personal_activity/thumbs/thumb.png diff --git a/app/models/activity.rb b/app/models/activity.rb index 464af9e..869ec68 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -72,6 +72,8 @@ class Activity fields_to_show.collect do |t| if t == "activity_title" pd_data << { "data_title" => "#{p.send(t)}" } + elsif t.include?("date") + pd_data << { "data_title" => (p.send(t).strftime('%Y-%m-%d') rescue p.send(t)) } else pd_data << { "data_title" => p.send(t) } end @@ -97,9 +99,9 @@ class Activity when 'activity_area' value = self.activity_area rescue '' when 'activity_start_date' - value = self.activity_start_date rescue '' + value = self.activity_start_date.strftime('%Y-%m-%d') rescue '' when 'activity_end_date' - value = self.activity_end_date rescue '' + value = self.activity_end_date.strftime('%Y-%m-%d') rescue '' when 'year' value = self.year rescue '' when 'note' diff --git a/modules/personal_activity/index.html.erb b/modules/personal_activity/index.html.erb new file mode 100644 index 0000000..6f6d760 --- /dev/null +++ b/modules/personal_activity/index.html.erb @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + +

    {{widget-title}}

    {{year}}{{activity_name}}{{activity_organizer}}{{activity_area}}{{activity_start_date}}{{activity_end_date}}{{note}}
    {{year}}{{activity_name}}{{activity_organizer}}{{activity_area}}{{activity_start_date}}{{activity_end_date}}{{note}}
    +{{pagination_goes_here}} + + diff --git a/modules/personal_activity/index_search1.html.erb b/modules/personal_activity/index_search1.html.erb new file mode 100644 index 0000000..fff8713 --- /dev/null +++ b/modules/personal_activity/index_search1.html.erb @@ -0,0 +1,62 @@ + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +

    {{widget-title}}

    {{year}}{{activity_name}}{{activity_organizer}}{{activity_area}}{{activity_start_date}}{{activity_end_date}}{{note}}
    {{year}}{{activity_name}}{{activity_organizer}}{{activity_area}}{{activity_start_date}}{{activity_end_date}}{{note}}
    +{{pagination_goes_here}} + + + diff --git a/modules/personal_activity/info.json b/modules/personal_activity/info.json new file mode 100644 index 0000000..cda3d13 --- /dev/null +++ b/modules/personal_activity/info.json @@ -0,0 +1,12 @@ +{ + "frontend": [ + { + "filename" : "index", + "name" : { + "zh_tw" : "1. 列表", + "en" : "1. List" + }, + "thumbnail" : "thumb.png" + } + ] +} \ No newline at end of file diff --git a/modules/personal_activity/show.html.erb b/modules/personal_activity/show.html.erb new file mode 100644 index 0000000..b183818 --- /dev/null +++ b/modules/personal_activity/show.html.erb @@ -0,0 +1,8 @@ + + + + + + + +
    {{title}}{{value}}
    diff --git a/modules/personal_activity/thumbs/thumb.png b/modules/personal_activity/thumbs/thumb.png new file mode 100644 index 0000000000000000000000000000000000000000..266af5606742714c262a949cd58aedc2b84b1959 GIT binary patch literal 4075 zcmcgvYdBPE`=8Q@or=MZk}-~jIXD}qFebzhVvsZ#jA2HMW=0OFFbKQkR5@2;7{)1- z&=wM+oMYofvU8{uIS&7&UHkuj*w_2v{qU~qTI;!=weH`2-_Lz|o)v3@JtZh0Apin_ z1kKIRw!l~h+!g!w0MC|jUMDb!Q%!MHJBk;Th7Tlwj65ms1cm?>ZoCb zunI6C_z=xP0tt2@SbL8Ul825b)X)H;M@Iny{0US%gzoQ04nooOq2J}A0DAj1918i) zLM7=#|1t_^Wdkvx1QH+`FocQ+LK6wmREHte5jyHR$`Dlq5&=i5!Vy|3NCZkl3xz;J zeq2yMTcD>G$`+0Jp$nMlLw%^!02CZfqtReAH5et(8;;b`(SajW;i{@C0EbEtgG|NK zRmedyKP8|EK^}p`04k9}hHOj3yHkRx`cS~qzn0)1U}g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jQ4iu-%6ZvY&d?S z(Yb!KKCBjcBfE4hloZ^UW{2r=yHy0PzyN)UnCjQ^&}bh?xwb$$BT+V%+b{b zq?WOa<=b6)e-`d$?21O2jFEohz$tKYMmUzXr zv!G#9d=mkj!$T|>;o(^`Q6(9fne#dcS*H7Knqnn^b1|?Q$ Date: Tue, 11 Aug 2020 00:24:50 +0800 Subject: [PATCH 7/8] Change date format to "%Y-%m-%d" in index search page. --- modules/personal_activity/index_search1.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/personal_activity/index_search1.html.erb b/modules/personal_activity/index_search1.html.erb index fff8713..f51c040 100644 --- a/modules/personal_activity/index_search1.html.erb +++ b/modules/personal_activity/index_search1.html.erb @@ -32,8 +32,8 @@ $( ".selectbox" ).ready(function() { {{activity_name}} {{activity_organizer}} {{activity_area}} - {{activity_start_date}} - {{activity_end_date}} + {{activity_start_date}} + {{activity_end_date}} {{note}} From 0a2c393e62956e96b0764856eb8f23f2e3c86c61 Mon Sep 17 00:00:00 2001 From: chiu Date: Mon, 8 Mar 2021 14:28:07 +0800 Subject: [PATCH 8/8] Add rss2_id. --- app/models/activity.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/activity.rb b/app/models/activity.rb index 869ec68..225182d 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -20,7 +20,7 @@ class Activity field :activity_end_date, type: DateTime field :note, type: String field :url - + field :rss2_id # paginates_per 10 has_many :activity_files, :autosave => true, :dependent => :destroy