Merge branch 'master' into 'master'

Master



See merge request !1
This commit is contained in:
chiu 2021-03-08 14:28:57 +08:00
commit 9da8f60a6a
15 changed files with 476 additions and 24 deletions

104
Gemfile.lock Normal file
View File

@ -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!

View File

@ -2,44 +2,82 @@ 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)
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
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
@ -51,6 +89,7 @@ class Admin::ActivitiesController < OrbitMemberController
end
end
def analysis
end
@ -102,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
@ -119,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

View File

@ -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

View File

@ -4,8 +4,10 @@ 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
field :activity_name, as: :slug_title, type: String, localize: true
@ -17,8 +19,16 @@ class Activity
field :activity_start_date, type: DateTime
field :activity_end_date, type: DateTime
field :note, type: String
field :url
field :rss2_id
# paginates_per 10
belongs_to :member_profile
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 +40,55 @@ 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"
]
fields_to_remove = []
pd_title = []
fields_to_show.each do |t|
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)
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 do |p|
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.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
end
{
"pd_datas" => pd_data
}
end
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 = "<a href='#{path}'>#{self.member_profile.name}</a>"
@ -42,17 +99,27 @@ 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'
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
value = self.send(field) rescue ''
end
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value
{
'key' => field,
'title_class' => "activity-#{field.gsub('_','-')}-field",
@ -61,4 +128,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

View File

@ -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

View File

@ -0,0 +1,2 @@
class ActivityIntro < PersonalPluginIntro
end

View File

@ -4,8 +4,8 @@
<tr>
<th class="span1"><%= t("personal_activity.participant") %></th>
<th class="span1"><%= t("personal_activity.year") %></th>
<th class="span5"><%= t("personal_plugins.activity_name") %></th>
<th class="span1"><%= t("personal_plugins.activity_organizer") %></th>
<th class="span5"><%= t("personal_activity.activity_name") %></th>
<th class="span1"><%= t("personal_activity.activity_organizer") %></th>
</tr>
</thead>
<tbody id="tbody_activity" class="sort-holder">

View File

@ -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 Frontend"
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…"

View File

@ -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:
activities: "活動前台"
create_success : "新增完成!!"
update_success : "更新完成!!"
delete_success : "刪除成功!!"
add: "新增"
back: "返回"
delete: "刪除"
edit: "編輯"
nothing: "無"
show: "顯示"
sure?: "您肯定嗎?"
update: "更新"
yes_: "是"
no_: "否"
cancel : "取消"
save: "儲存"
hintText: "請輸入搜尋關鍵字"
noResultsText: "沒有相關的比對結果"
searchingText: "搜尋中…"

View File

@ -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
@ -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

View File

@ -0,0 +1,35 @@
<table class="table table-hover table-striped projects-index activities-index dt-responsive nowrap">
<caption><h3>{{widget-title}}</h3></caption>
<thead>
<tr>
<th class="col-md-1">{{year}}</th>
<th class="col-md-2">{{activity_name}}</th>
<th class="col-md-1">{{activity_organizer}}</th>
<th class="col-md-2 min-tablet">{{activity_area}}</th>
<th class="col-md-2 min-tablet-l">{{activity_start_date}}</th>
<th class="col-md-2 min-tablet-l">{{activity_end_date}}</th>
<th class="col-md-2 min-tablet-l">{{note}}</th>
</tr>
</thead>
<tbody data-level="0" data-list="activities">
<tr>
<td>{{year}}</td>
<td><a href="{{link_to_show}}">{{activity_name}}</a></td>
<td>{{activity_organizer}}</td>
<td>{{activity_area}}</td>
<td date-format="%Y-%m-%d">{{activity_start_date}}</td>
<td date-format="%Y-%m-%d">{{activity_end_date}}</td>
<td>{{note}}</td>
</tr>
</tbody>
</table>
{{pagination_goes_here}}
<script>
$('table.activities-index').DataTable({
searching: false,
paging: false,
ordering: false,
info: false
});
</script>

View File

@ -0,0 +1,62 @@
<script type="text/javascript">
$( ".selectbox" ).ready(function() {
var option_len = $(".search-widget option").length
for (var i=0;i<option_len;i++){
if($(".search-widget option").eq(i).data('selected')=="selected"){
$(".search-widget option").eq(i).attr('selected','selected')
}
}
});
</script>
<div class="search-widget personal-activities">
<h3>{{widget-title}}</h3>
<form action="{{url}}" method="get">
<label for="selectbox">{{select_text}}</label>
<select class="selectbox" name="selectbox" data-level="0" data-list="choice">
<option value={{choice_value}} data-selected='{{choice_select}}' >
{{choice_show}}</option>
</select>
<label for="keywords">{{search_text}}</label>
<input name="keywords" id="keywords" placeholder="Keywords" type="text" value="{{search_value}}" title="keywords">
<button>Go</button>
<a id="filter" style="" href="{{url}}">Clear</a>
</form>
</div>
<table class="table table-hover table-striped projects-index activities-index dt-responsive nowrap">
<caption><h3>{{widget-title}}</h3></caption>
<thead>
<tr>
<th class="col-md-1">{{year}}</th>
<th class="col-md-2">{{activity_name}}</th>
<th class="col-md-1">{{activity_organizer}}</th>
<th class="col-md-2 min-tablet">{{activity_area}}</th>
<th class="col-md-2 min-tablet-l" date-format="%Y-%m-%d">{{activity_start_date}}</th>
<th class="col-md-2 min-tablet-l" date-format="%Y-%m-%d">{{activity_end_date}}</th>
<th class="col-md-2 min-tablet-l">{{note}}</th>
</tr>
</thead>
<tbody data-level="0" data-list="activities">
<tr>
<td>{{year}}</td>
<td><a href="{{link_to_show}}">{{activity_name}}</a></td>
<td>{{activity_organizer}}</td>
<td>{{activity_area}}</td>
<td>{{activity_start_date}}</td>
<td>{{activity_end_date}}</td>
<td>{{note}}</td>
</tr>
</tbody>
</table>
{{pagination_goes_here}}
<script>
$('table.activities-index').DataTable({
searching: false,
paging: false,
ordering: false,
info: false
});
</script>

View File

@ -0,0 +1,12 @@
{
"frontend": [
{
"filename" : "index",
"name" : {
"zh_tw" : "1. 列表",
"en" : "1. List"
},
"thumbnail" : "thumb.png"
}
]
}

View File

@ -0,0 +1,8 @@
<table class="table table-striped plugin-show-table">
<tbody data-list="plugin_datas" data-level="0">
<tr>
<th class="{{title_class}}">{{title}}</th>
<td class="{{value_class}}">{{value}}</td>
</tr>
</tbody>
</table>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB