Initial commit: personal_competition gem

This commit is contained in:
rulingcom 2026-05-20 17:50:28 +08:00
commit 5aa0bd0cad
48 changed files with 1786 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/db/*.sqlite3-journal
test/dummy/log/*.log
test/dummy/tmp/
test/dummy/.sass-cache

14
Gemfile Normal file
View File

@ -0,0 +1,14 @@
source "https://rubygems.org"
# Declare your gem's dependencies in personal_honor.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
# To use debugger
# gem 'debugger'

104
Gemfile.lock Normal file
View File

@ -0,0 +1,104 @@
PATH
remote: .
specs:
personal_honor (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_honor!

20
MIT-LICENSE Normal file
View File

@ -0,0 +1,20 @@
Copyright 2014 YOURNAME
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3
README.rdoc Normal file
View File

@ -0,0 +1,3 @@
= PersonalHonor
This project rocks and uses MIT-LICENSE.

32
Rakefile Normal file
View File

@ -0,0 +1,32 @@
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'PersonalHonor'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task default: :test

0
app/controllers/.keep Normal file
View File

View File

@ -0,0 +1,52 @@
class Admin::CompetitionTypesController < OrbitMemberController
before_action :allow_admin_only
def new
@competition_type = CompetitionType.new
@url = admin_competition_types_path(@competition_type)
render :layout=>false
end
def create
@competition_type = CompetitionType.new(competition_type_params)
@competition_type.save
@competition_types = CompetitionType.all
render :partial=>'list', :layout=>false
end
def update_order
orders = params["order"]
CompetitionType.each do |ct|
ct.sort_position = orders["#{ct.id}"]
ct.save
end
render :json => {"success" => true}.to_json
end
def edit
@competition_type = CompetitionType.find(params[:id])
@url = admin_competition_type_path(@competition_type)
render :layout=>false
end
def update
@competition_type = CompetitionType.find(params[:id])
@competition_type.update_attributes(competition_type_params)
@competition_type.save
@competition_types = CompetitionType.all
render :partial=>'list', :layout=>false
end
def destroy
competition_type = CompetitionType.find(params[:id])
competition_type.destroy
@competition_types = CompetitionType.all
render :partial=>'list', :layout=>false
end
private
def competition_type_params
params.require(:competition_type).permit! rescue nil
end
end

View File

@ -0,0 +1,208 @@
class Admin::CompetitionsController < OrbitMemberController
layout "member_plugin"
include Admin::PersonalCompetitionsHelper
before_action :set_competition, 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]
def index
@competitions = Competition.sort_year_date.page(params[:page]).per(10)
end
def new
@member = MemberProfile.find_by(:uid=>params['uid'].to_s) rescue nil
@competition = Competition.new
if params[:desktop]
render :layout => false
end
end
def analysis_report
role = params[:role_id]
year_start = params[:year_start].to_i
year_end = params[:year_end].to_i
graph_by = params[:graph_by]
@data = get_chart_data(year_start,year_end,role,params[:graph_by])
render :layout => false
end
def download_excel
year_start = params[:year_start].to_i
year_end = params[:year_end].to_i
@data = get_data_for_excel(year_start,year_end)
respond_to do |format|
format.xlsx {
response.headers['Content-Disposition'] = 'attachment; filename="competitions.xlsx"'
}
end
end
def create
if !competition_params['member_profile_id'].blank?
@member = MemberProfile.find(competition_params['member_profile_id']) rescue nil
@competition = Competition.new(competition_params)
@competition.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?
params[:author_members].each do |author_member|
competition_params['member_profile_id'] = author_member
@competition = Competition.new(competition_params)
@competition.save
if params[:desktop] == "true"
render json: {"data" => get_paper_list}.to_json
end
end
redirect_to params['referer_url']
else
competition_params['member_profile_id'] = User.find(current_user.id).member_profile_id
@competition = Competition.new(competition_params)
@competition.save
if params[:desktop] == "true"
render json: {"data" => get_paper_list}.to_json
end
redirect_to params['referer_url']
end
end
def edit
@member = @competition.member_profile rescue nil
if params[:desktop]
render :layout => false
end
end
def update
@member = @competition.member_profile rescue nil
@competition.update_attributes(competition_params)
@competition.save
if params[:desktop] == "true"
render json: {"data" => get_paper_list}.to_json
else
redirect_to params['referer_url']
end
end
def destroy
@competition.destroy
respond_to do |format|
format.html { redirect_to(admin_competition_url) }
# format.xml { head :ok }
format.js
format.json {render json: {"success" => true}}
end
end
def toggle_hide
if params[:ids]
@competitions = Competition.any_in(_id: params[:ids])
@competitions.each do |competition|
competition.is_hidden = params[:disable]
competition.save
end
end
render json: {"success"=>true}
end
def excel_format
respond_to do |format|
format.xlsx {
response.headers['Content-Disposition'] = 'attachment; filename="competition_format.xlsx"'
}
end
end
def import_from_excel
workbook = RubyXL::Parser.parse(params["import_file"].tempfile)
sheet = workbook[0]
if sheet.count <= 503
sheet.each_with_index do |row, i|
next if i < 3
user = User.where(:user_name => row.cells[0].value).first rescue nil
if !user.nil?
mp = user.member_profile
import_this_competition(row,mp)
end
end
redirect_to admin_competitions_url
else
redirect_to admin_competitions_url(:error => "1")
end
end
def setting
end
def frontend_setting
@member = MemberProfile.find_by(:uid=>params['uid'].to_s) rescue nil
@intro = CompetitionIntro.find_by(:member_profile_id=>@member.id) rescue nil
@intro = @intro.nil? ? CompetitionIntro.new({:member_profile_id=>@member.id}) : @intro
end
def update_frontend_setting
@member = MemberProfile.find(intro_params['member_profile_id']) rescue nil
@intro = CompetitionIntro.find_by(:member_profile_id=>@member.id) rescue nil
@intro = @intro.nil? ? CompetitionIntro.new({:member_profile_id=>@member.id}) : @intro
@intro.update_attributes(intro_params)
@intro.save
redirect_to URI.encode('/admin/members/'+@member.to_param+'/Competition')
end
def get_settings
@competition_types = CompetitionType.all
end
def set_plugin
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Competition'}.first
end
private
def set_competition
path = request.path.split('/')
if path.last.include? '-'
uid = path[-1].split("-").last
uid = uid.split("?").first
else
uid = path[-2].split("-").last
uid = uid.split("?").first
end
@competition = Competition.find_by(:uid => uid) rescue Competition.find(params[:id])
end
def competition_params
params.require(:competition).permit! rescue nil
end
def intro_params
params.require(:competition_intro).permit! rescue nil
end
end

View File

@ -0,0 +1,23 @@
class Desktop::PersonalHonorsController < DesktopAdminController
include Admin::PersonalHonorsHelper
def menu
user = OrbitHelper.current_user
[
{
"title" => "List",
"layout" => "list"
},
{
"title" => "Add/Edit",
"layout" => "form",
"new_path" => "/admin/members/#{user.member_profile.to_param}/honors/new"
}
]
end
def list
get_paper_list
end
end

View File

@ -0,0 +1,136 @@
class PersonalCompetitionsController < ApplicationController
def index
params = OrbitHelper.params
filter_value = params[:competitions_filter_value]
competitions = nil
if filter_value.nil? || filter_value == t("personal_competition.competition_types_all") || filter_value.empty?
competitions = Competition.where(:competition_name.nin => [nil, ""]).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
else
competition_type_id = CompetitionType.any_of({ 'title.en' => filter_value }, { 'title.zh_tw' => filter_value }).first.id
competitions = Competition.where(competition_type_id: competition_type_id).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
end
fields_to_show = Page.where(:page_id => params[:page_id]).first.custom_array_field rescue []
if fields_to_show.blank?
fields_to_show = [
"year",
"award_name",
"awarding_unit",
"work_name",
"student_name",
"authors"
]
end
competition_list = []
competitions.each do |competition|
t = []
fields_to_show.each do |fs|
case fs
when "competition_name"
t << {"value" => "<a href='#{OrbitHelper.url_to_show(competition.to_param)}'>" + (competition.send(fs) rescue "") + "</a>"}
when "competition_type"
t << {"value" => (competition.send("competition_type").title rescue "")}
when "authors"
member_profile = competition.send(:member_profile)
role_status_id = member_profile.role_status_ids.first.to_s
path = OrbitHelper.url_to_plugin_show(member_profile.to_param, 'member') rescue '#'
t << {"value" => "<a href='#{path}'>" + (member_profile.name rescue "") + "</a>" }
when "competition_date"
t << {"value" => (competition.send(fs).strftime("%Y/%m") rescue "")}
else
t << {"value" => (competition.send(fs) rescue "")}
end
end
competition_list << {"personal_competitions" => t}
end
headers = []
fields_to_show.each do |fs|
col = 2
col = 3 if fs == "award_name"
header = fs == "authors" ? t("users.name") : t("personal_competition.#{fs}")
headers << {
"head-title" => header,
"col" => col
}
end
current_locale = I18n.locale
competition_types = CompetitionType.all.pluck(:title).map { |title| { 'competition_type' => title.to_h[current_locale] } }
competition_types.unshift({ 'competition_type' => t("personal_competition.competition_types_all") })
{
"competitions" => competition_list,
"competition_types" => competition_types,
"extras" => { "widget-title" => t("module_name.personal_competition"),
"url" => '/' + current_locale.to_s + params[:url] },
"headers" => headers,
"total_pages" => competitions.total_pages
}
end
def show
params = OrbitHelper.params
plugin = Competition.where(:is_hidden=>false).find_by(uid: params[:uid].to_s)
fields_to_show = [
"year",
"competition_type",
"competition_name",
"work_name",
"student_name",
"instructor_name",
"award_place",
"competition_date",
"country",
"honoree",
"awarding_unit",
"keywords",
"url",
"note"
]
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
end
def get_fields_for_index
@page = Page.find(params[:page_id]) rescue nil
@fields_to_show = [
"year",
"competition_name",
"award_name",
"work_name",
"student_name",
"instructor_name",
"award_place",
"awarding_unit",
"competition_type",
"competition_date",
"country",
"keywords",
"url",
"note",
"authors",
"award_winner"
]
@fields_to_show = @fields_to_show.map{|fs| [(fs == "authors" ? t("users.name") : t("personal_competition.#{fs}")), fs]}
@default_fields_to_show = [
"year",
"award_name",
"awarding_unit",
"work_name",
"student_name",
"authors"
]
render :layout => false
end
def save_index_fields
page = Page.find(params[:page_id]) rescue nil
page.custom_array_field = params[:keys]
page.save
render :json => {"success" => true}.to_json
end
end

0
app/helpers/.keep Normal file
View File

View File

@ -0,0 +1,119 @@
module Admin::PersonalCompetitionsHelper
def get_paper_list
user = current_user.nil? ? OrbitHelper.current_user : current_user
user_profile = user.member_profile
competitions = Competition.where(:member_profile_id => user_profile.id)
competitions = competitions.collect do |c|
{
"id" => c.id.to_s,
"edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/competitions/#{c.to_param}/edit",
"delete_url" => "/#{I18n.locale.to_s}/admin/competitions/#{c.id.to_s}",
"paper_title" => c.competition_name,
"keywords" => c.keywords,
"files" => []
}
end
competitions
end
def import_this_competition(row,mp)
value = nil
competition = Competition.new
row.cells.each_with_index do |cell,index|
next if index < 2
next if cell.nil?
val = cell.value
next if val.nil? || val == ""
case index
when 2
value = {"en" => val}
when 3
begin
value["zh_tw"] = val
rescue
value = {"zh_tw" => val}
end
competition.competition_name_translations = value
when 4
value = {"en" => val}
when 5
begin
value["zh_tw"] = val
rescue
value = {"zh_tw" => val}
end
competition.awarding_unit_translations = value
when 6
competition.year = val
when 7
competition.language = val
when 8
cts = CompetitionType.asc(:created_at).all.to_a
competition.competition_type = cts[val.to_i] if val.to_s.is_i? && val.to_i < cts.count
when 9
competition.url = val
when 10
competition.keywords = val
when 11
competition.note = val
end
end
competition.member_profile = mp
competition.save
end
def get_data_for_excel(year_start,year_end)
data = []
roles = Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key)
roles.each do |role|
d = {}
d["name"] = role.title
mps = role.member_profile_ids
# d1 = DateTime.new(year_start,1,1,0,0)
# d2 = DateTime.new(year_end,12,31,23,59)
d["data"] = Competition.where(:year.gte => year_start, :year.lte => year_end, :member_profile_id.in => mps) rescue []
data << d
end
return data
end
def get_chart_data(year_start,year_end,role,type)
case type
when "category"
jls = CompetitionType.all
end
finaldata = []
role = Role.find(role) rescue nil
mps = []
if !role.nil?
mps = role.member_profile_ids
end
jls.each do |jl|
data = {}
data["name"] = jl.title
data["data"] = {}
(year_start..year_end).each do |year|
# d1 = DateTime.new(year,1,1,0,0)
# d2 = DateTime.new(year,12,31,23,59)
t = jl.competitions.where(:year => year.to_s, :member_profile_id.in => mps).count rescue 0
data["data"][year.to_s] = t
end
finaldata << data
end
data = {"name" => "N/A", "data" => {}}
(year_start..year_end).each do |year|
# d1 = DateTime.new(year,1,1,0,0)
# d2 = DateTime.new(year,12,31,23,59)
case type
when "category"
t = Competition.where(:year => year, :member_profile_id.in => mps, :competition_type_id => nil).count rescue 0
end
data["data"][year.to_s] = t
end
finaldata << data
finaldata
end
end

0
app/mailers/.keep Normal file
View File

0
app/models/.keep Normal file
View File

146
app/models/competition.rb Normal file
View File

@ -0,0 +1,146 @@
class Competition
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include Slug
belongs_to :competition_type
belongs_to :member_profile
field :year, type: Integer
field :award_name, localize: true
field :awarding_unit, localize: true
field :competition_name, localize: true
field :work_name, localize: true
field :student_name, localize: true
field :instructor_name, localize: true
field :award_place, localize: true
field :competition_date, type: DateTime
field :language
field :keywords
field :url
field :note
field :rss2_id
field :country, localize: true
field :create_user_id, :type => BSON::ObjectId
field :update_user_id, :type => BSON::ObjectId
# paginates_per 10
before_validation :add_http
index({year: -1, :competition_date => -1, _id: -1}, { unique: false, background: false })
scope :sort_year_date, ->{ order_by(:year => "desc",:competition_date => "desc", :id => "desc") }
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc",:competition_date => "desc", :id => "desc") }
def slug_title
self.award_name+' '+self.awarding_unit rescue ""
end
def get_plugin_data(fields_to_show)
plugin_datas = []
fields_to_show.each do |field|
plugin_data = self.get_plugin_field_data(field) rescue nil
next if plugin_data.blank? or plugin_data['value'].blank?
plugin_datas << plugin_data
end
plugin_datas
end
def self.get_plugin_datas_to_member(datas)
page = Page.where(:module => "personal_competition").first rescue nil
if !page.nil? && !page.custom_array_field.blank?
fields_to_show = page.custom_array_field
else
fields_to_show = [
"competition_type",
"year",
"competition_name",
"work_name",
"student_name",
"instructor_name",
"award_place"
]
end
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_competition.#{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,idx|
pd_data = []
fields_to_show.collect do |t|
if t == "competition_name"
link = OrbitHelper.url_to_plugin_show(p.to_param,'personal_competition')
url_to_plugin_show_blank = OrbitHelper.instance_variable_get(:@url_to_plugin_show_blank)
tmp_title = p.competition_name
pd_data << { "data_title" => (url_to_plugin_show_blank ? tmp_title : "<a title=\"#{tmp_title}\" href=\"#{link}\" target=\"_blank\">#{tmp_title}</a>") }
elsif t == "competition_type"
pd_data << {"data_title" => (p.competition_type.title rescue "")}
elsif t == "competition_date"
pd_data << {"data_title" => (p.send(t).strftime("%Y/%m/%d") rescue "")}
else
pd_data << { "data_title" => p.send(t) }
end
end
{
"pd_datas" => pd_data,
"type-sort" => (p.competition_type.sort_position.to_i rescue 1000),
"sort-index" => idx
}
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 "honoree"
path = OrbitHelper.url_to_plugin_show(self.member_profile.to_param, 'member') rescue '#'
value = "<a href='#{path}'>" + self.member_profile.name + "</a>"
when "language"
value = I18n.t(self.language) rescue ""
when "competition_type"
value = self.competition_type.title rescue ""
when "competition_date"
value = self.competition_date.strftime("%Y/%m/%d") rescue ""
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"=>"competition-#{field.gsub('_','-')}-field",
"value_class"=>"competition-#{field.gsub('_','-')}-value",
"title"=>I18n.t('personal_competition.'+field),
"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,4 @@
class CompetitionIntro < PersonalPluginIntro
end

View File

@ -0,0 +1,28 @@
class CompetitionType
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include Slug
field :title, localize: true
field :sort_position, type: Integer, default: 1
field :rss2_id
has_many :competitions, :dependent => :destroy
before_create :add_to_index
before_destroy :remove_from_index
scope :sort_position, ->{ order_by(:sort_position=>'asc') }
def add_to_index
if self.is_hidden == false
Rss2.create(:data => self, :title => self.title)
end
end
def remove_from_index
Rss2.nt_list.delete(@rss2_id) if !@rss2_id.blank?
end
end

0
app/views/.keep Normal file
View File

View File

@ -0,0 +1,24 @@
<%= form_for(@competition_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t("personal_competition.competition_category") %></h3>
</div>
<div class="modal-body">
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<%= label_tag t(locale), t(locale), :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :value => (@competition_type.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="modal-footer">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>

View File

@ -0,0 +1,2 @@
$('#competition_types tbody').html("<%= j render :partial => '/admin/competitions/list_competition_type', :collection => @competition_types %>");
$('#competition_type_modal').modal('hide');

View File

@ -0,0 +1 @@
$('#competition_type_modal').html("<%= j render 'form' %>");

View File

@ -0,0 +1 @@
$('#competition_type_modal').html("<%= j render 'form' %>");

View File

@ -0,0 +1,17 @@
<% @competitions.each do |competition| %>
<tr id="<%= dom_id competition %>" class="<%= competition.is_hidden ? "checkHide" : "" %>">
<td><%= competition.year %></td>
<td>
<%= link_to competition.competition_name, OrbitHelper.url_to_plugin_show(competition.to_param,'personal_competition'), target: "blank"%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('edit'), edit_admin_competition_path(competition) %></li>
<li><%= link_to t(:delete_), admin_competition_path(id: competition.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
</ul>
</div>
</td>
<td><%= competition.awarding_unit %></td>
<td><%= competition.work_name %></td>
<td><%= competition.student_name %></td>
</tr>
<% end %>

View File

@ -0,0 +1,242 @@
<% # encoding: utf-8 %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/main-list" %>
<%= stylesheet_link_tag "lib/main-form-col2" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
<li class="pull-right">
<%= copy_to_all_language_button(".language-nav", ".language-area") %>
</li>
</ul>
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- competition_name -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_competition.competition_name") %></label>
<div class="controls">
<%= f.fields_for :competition_name_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_competition.competition_name"), value: (@competition.competition_name_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- work_name -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_competition.work_name") %></label>
<div class="controls">
<%= f.fields_for :work_name_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_competition.work_name"), value: (@competition.work_name_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- student_name -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_competition.student_name") %></label>
<div class="controls">
<%= f.fields_for :student_name_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_competition.student_name"), value: (@competition.student_name_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- instructor_name -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_competition.instructor_name") %></label>
<div class="controls">
<%= f.fields_for :instructor_name_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_competition.instructor_name"), value: (@competition.instructor_name_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- award_place -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_competition.award_place") %></label>
<div class="controls">
<%= f.fields_for :award_place_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_competition.award_place"), value: (@competition.award_place_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- award_name -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_competition.award_name") %></label>
<div class="controls">
<%= f.fields_for :award_name_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_competition.award_name"), value: (@competition.award_name_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- awarding_unit-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_competition.awarding_unit") %></label>
<div class="controls">
<%= f.fields_for :awarding_unit_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_competition.awarding_unit"), value: (@competition.awarding_unit_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_competition.country") %></label>
<div class="controls">
<%= f.fields_for :country_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_competition.country"), value: (@competition.country_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<% if !@member.nil? %>
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id %>
</div>
</div>
<% else %>
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'author_members[]', email_members:[]} %>
</div>
</div>
<% end %>
<!-- personal_competition -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_competition.year") %></label>
<div class="controls">
<%= select_year(@competition.year, {:start_year => (DateTime.now.year+5), :end_year => 1930, :prompt => "Choose year"}, {:name => 'competition[year]', :class => "span1"} ) %>
</div>
</div>
<!-- competition_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_competition.competition_date") %></label>
<div class="controls">
<%= f.datetime_picker :competition_date, :no_label => true, :format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD", :value => @competition.competition_date, :new_record => @competition.new_record? %>
</div>
</div>
<!-- language -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_competition.language") %></label>
<div class="controls">
<select id="competition_language" name="competition[language]">
<% @site_in_use_locales.each do |locale| %>
<option value="<%= locale %>" <%= @competition.language.eql?(locale.to_s) ? "selected" : ""%>><%= t(locale) %></option>
<% end %>
</select>
</div>
</div>
<!-- competition_type -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_competition.competition_category") %></label>
<div class="controls">
<%= f.select :competition_type_id, @competition_types.collect {|t| [ t.title, t.id ]} %>
</div>
</div>
<!-- url -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_competition.url") %></label>
<div class="controls">
<%= f.text_field :url , :class => "span6" %>
</div>
</div>
<!-- keywords -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_competition.keywords") %></label>
<div class="controls">
<%= f.text_field :keywords %>
</div>
</div>
<!-- note -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_competition.note") %></label>
<div class="controls">
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @competition.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
<input type="hidden" name="referer_url" value="<%= request.referer %>">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>

View File

@ -0,0 +1,8 @@
<tr id="<%= dom_id list_competition_type %>" data-type-id="<%= list_competition_type.id.to_s %>">
<td><%= list_competition_type.title %></td>
<td class="span2">
<a href="<%= edit_admin_competition_type_path(list_competition_type) %>#competition_type_modal" data-toggle="modal" data-remote="true" class="action"><%= t(:edit) %></a>
<%= link_to t(:delete_), admin_competition_type_path(list_competition_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
</td>
</tr>

View File

@ -0,0 +1 @@
$('#competition_<%= @competition.id.to_s%>').remove();

View File

@ -0,0 +1,5 @@
<%= form_for @competition, url: admin_competition_path(@competition), html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,94 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<%= form_for(:competition_intro, :url => update_frontend_setting_admin_competitions_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %>
<fieldset>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t("module_name.personal_competition") %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<% if !@member.blank? %>
<div class="control-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id %>
</div>
</div>
<% end %>
<!-- frontend_page -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_plugins.frontend_page") %></label>
<div class="controls">
<%= f.check_box :brief_intro, :checked => @intro.brief_intro %> <%= t("personal_plugins.brief_intro") %>
<%= f.check_box :complete_list, :checked => @intro.complete_list %> <%= t("personal_plugins.complete_list") %>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Content -->
<div class="control-group input-content">
<label class="control-label muted"><%= t(:content) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :text_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@intro.text_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
<%= hidden_field_tag :member_profile_id, @member.id.to_s %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
</fieldset>
<% end %>

View File

@ -0,0 +1,44 @@
<table class="table main-list">
<thead>
<tr>
<th class="span3"><%= t('personal_competition.year') %></th>
<th class="span3"><%= t('personal_competition.competition_name') %></th>
<th class="span3"><%= t('personal_competition.awarding_unit') %></th>
<th class="span3"><%= t('personal_competition.work_name') %></th>
<th class="span3"><%= t('personal_competition.student_name') %></th>
</tr>
</thead>
<tbody id="tbody_experiences" class="sort-holder">
<%= render 'competition' %>
</tbody>
</table>
<div class="bottomnav clearfix">
<div class="action pull-right">
<div class="dropup upload-button">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
<i class="icon-upload-alt icon-white"></i>上傳
<span class="caret"></span>
</button>
<div class="dropdown-menu upload-box">
<form action="/admin/competitions/import_from_excel" method="post" enctype="multipart/form-data">
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<input type="file" name="import_file" >
<button class="btn btn-primary" type="submit"><%= t(:submit) %></button>
<a class="" href="/admin/competitions/download_excel_format.xlsx">Download excel format</a>
</form>
</div>
</div>
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_competition_path, :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_competition_setting_path, :class => 'btn btn-primary pull-right' %>
</div>
<div class="pagination pagination-centered">
<%= content_tag :div, paginate(@competitions), class: "pagination pagination-centered" %>
</div>
</div>
<% if params[:error] == "1" %>
<script type="text/javascript">
alert("File cannot be imported. File has more than 500 entries. Please seperate the entries in different files.");
window.location.href = "<%= admin_competitions_url %>"
</script>
<% end %>

View File

@ -0,0 +1,5 @@
<%= form_for @competition, url: admin_competitions_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,70 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/jquery-ui-sortable.min" %>
<% end %>
<style type="text/css">
.element{
background: #FFF;
margin-bottom: 10px;
border-radius: 5px;
border: 1px solid #DDD;
}
.detail{
padding: 10px;
min-height: 250px;
}
.totle{
margin-bottom: 25px;
}
.totle span{
font-size: 18px;
}
</style>
<div class="row">
<div class="element span4">
<div class="detail w-a h-a">
<p class="totle">
<a class="btn btn-small btn-primary pull-right" href="<%= new_admin_competition_type_path %>#competition_type_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
<span><%= t("personal_competition.competition_category") %></span>
</p>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table id="competition_types" class="table table-striped">
<tbody>
<%= render :partial => 'list_competition_type', :collection => @competition_types.asc(:sort_position) %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="competition_type_qe">
<div style="display:none;" class="modal" id="competition_type_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</div>
</div>
<script type="text/javascript">
$("#competition_types tbody").sortable({
update : function(){
var data = {};
$("#competition_types tbody tr").each(function(i){
data[$(this).data("type-id")] = i;
})
$.ajax({
url : "/admin/competition_types/update_order",
type : "post",
data : {"order" : data}
})
}
});
</script>

View File

@ -0,0 +1,48 @@
<% if !@page.nil? %>
<form id="form_for_plugin_fields" action="">
<div class="form-inline">
<ul class="current-fields">
<% if @page.custom_array_field.blank? %>
<% @default_fields_to_show.each do |fs| %>
<li data-attrib-key="<%= fs %>" class="clearfix"><span class="field-value"><%= fs == "authors" ? t("users.name") : t("personal_competition.#{fs}") %></span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>
<% end %>
<% else %>
<% @page.custom_array_field.each do |fs| %>
<li data-attrib-key="<%= fs %>" class="clearfix"><span class="field-value"><%= fs == "authors" ? t("users.name") : t("personal_competition.#{fs}") %></span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>
<% end %>
<% end %>
</ul>
</div>
<div class="form-horizontal controls-row">
<div class="attr-type-wrap control-group">
<label class="attr control-label">Fields: </label>
<div class="attr controls">
<%= select_tag "fields_to_show_for_pp", options_for_select(@fields_to_show), prompt: "---Select something---" %>
</div>
</div>
<a href="#" class="add-pp-field btn btn-info">Add Field</a>
<input type="hidden" name="plugin_key" value="<%= @page.module %>">
<input type="hidden" name="plugin_page_frontend_id" value="<%= @page.id.to_s %>">
</div>
</form>
<script type="text/javascript">
$(".current-fields").sortable();
var select = $("select#fields_to_show_for_pp");
$(".add-pp-field").on("click",function(){
var val = select.val(),
text = select.find("option:selected").text(),
li = null;
if(val != ""){
li = '<li class="clearfix" data-attrib-key="' + val + '"><span class="field-value">' + text + '</span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>';
}
$("#modify_plugin_fields ul.current-fields").append(li);
})
$(document).on("click",".remove-field",function(){
$(this).parent().remove();
})
</script>
<% else %>
<h3>Page not found.</h3>
<% end %>

View File

@ -0,0 +1 @@
<%= render_view %>

View File

@ -0,0 +1 @@
<%= render_view %>

View File

@ -0,0 +1,88 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/list-check" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/list-check" %>
<% end %>
<%
if has_access?
@competitions = Competition.where(member_profile_id: @member.id).sort_year_date.page(params[:page]).per(10)
else
@competitions = Competition.where(is_hidden: false, member_profile_id: @member.id).sort_year_date.page(params[:page]).per(10)
end
%>
<% if has_access? %>
<div class="list-active">
<div class="btn-group">
<%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_competitions_path(member_profile_id: @member.id.to_s, disable: 'true') ) %>
<%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_competitions_path(member_profile_id: @member.id.to_s, disable: 'false') ) %>
</div>
</div>
<% end -%>
<table class="table table-condensed table-striped main-list">
<thead>
<tr>
<% if has_access? %>
<th><input type="checkbox" /></th>
<% end -%>
<th class="span3"><%= t('personal_competition.year') %></th>
<th class="span3"><%= t('personal_competition.competition_name') %></th>
<th class="span3"><%= t('personal_competition.awarding_unit') %></th>
<th class="span3"><%= t('personal_competition.award_winner') %></th>
</tr>
</thead>
<tbody>
<% @competitions.each do |competition| %>
<tr id="<%= dom_id competition %>" class="<%= competition.is_hidden ? "checkHide" : "" %>">
<% if has_access? %>
<td>
<%= check_box_tag 'to_change[]', competition.id.to_s, false, :class => "list-check" %>
</td>
<% end %>
<td><%= competition.year %></td>
<td>
<% link = OrbitHelper.url_to_plugin_show(competition.to_param,'personal_competition') %>
<%= (link = (link == "#") ? competition.competition_name : link_to(competition.competition_name, link, target: "blank"))%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if has_access? %>
<li><%= link_to t('edit'), '/admin/members/'+@member.to_param+'/competitions/'+competition.id+'/edit' %></li>
<li><%= link_to t(:delete_), admin_competition_path(id: competition.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
<% end %>
</ul>
</div>
</td>
<td><%= competition.awarding_unit %></td>
<td><%= competition.member_profile.name %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="bottomnav clearfix">
<% if has_access? %>
<div class="action pull-right">
<%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/competitions/frontend_setting', :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'),
'/admin/members/'+@member.to_param+'/competitions/new', :class => 'btn btn-primary' %>
</div>
<% end %>
<div class="pagination pagination-centered">
<%= paginate @competitions, :params => {:direction => params[:direction], :sort => params[:sort] } %>
</div>
</div>
<div id="dialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Delete item" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3><%= t(:sure?) %></h3>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<button class="delete-item btn btn-danger"><%= t(:submit) %></button>
</div>
</div>

16
bin/rails Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/personal_honor/engine', __FILE__)
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
require "mongoid"
require 'rails/engine/commands'

68
config/locales/en.yml Normal file
View File

@ -0,0 +1,68 @@
en:
module_name:
personal_competition: Competition
personal_competition:
competition_name : "Competition Name"
work_name : "Work Name"
student_name : "Student Name"
instructor_name : "Instructor Name"
award_place : "Award Place"
award_winner : "Award winner"
paper_title : "Paper Title"
book_title : "Book Title"
award_name : "Award Name"
awarding_unit : "Awarding Unit"
competition_category : "Competition Category"
competition_type: "Competition Category"
competition_types_all: "All Competition Types"
extracted_chapters : "Extracted Chapters"
publishers : "Publishers"
honoree: "Honoree"
authors : "Authors"
tags : "Tags"
year : "Year"
language : "Language"
isbn : "ISSN(ISBN)"
vol_no : "Vol.No"
issue_no : "Issue.No"
form_to_start : "From"
form_to_end : "To"
country: "Country"
competition_date: "Competition Date"
total_pages : "Total Pages"
keywords : "Keywords"
abstract : "Abstract"
publication_date : "Date of Publication"
url : "Reference URL"
note : "Note"
level_type : "Level Type"
author_type : "Author Type"
from : "From"
to : "To"
file : "File"
file_name : "File name"
description : "File Description"
pages : "Pages"
book_paper_type : "Book Paper Type"
graph_by : "Graph By"
frontend:
competitions: "Competition 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…"

64
config/locales/zh_tw.yml Normal file
View File

@ -0,0 +1,64 @@
zh_tw:
module_name:
personal_competition: 競賽
personal_competition:
competition_name : "競賽名稱"
work_name : "作品名稱"
student_name : "參賽學生姓名"
instructor_name : "共同指導老師"
award_place : "獲獎名次"
award_winner : "得獎人"
paper_title : "論文名稱"
book_title : "期刊名稱"
award_name : "獎項名稱"
awarding_unit : "頒獎單位"
competition_category : "類別"
competition_type: "類別"
competition_types_all: "所有競賽項目"
honoree: "受獎人"
authors : "作者"
tags : "領域"
year : "年度"
language : "語言"
isbn : "ISSN(ISBN)"
vol_no : "卷數"
issue_no : "期數"
form_to_start : "起"
form_to_end : "迄"
total_pages : "總頁數"
keywords : "關鍵字"
abstract : "摘要"
publication_date : "發表日期"
competition_date: "比賽日期"
country: "國別"
url : "參考連結"
note : "記事"
level_type : "期刊類別"
author_type : "作者類別"
from : "起"
to : "迄"
file : "檔案"
file_name : "檔案名稱"
description : "描述"
graph_by : "Graph By"
frontend:
competitions: "競賽前台"
create_success : "新增完成!!"
update_success : "更新完成!!"
delete_success : "刪除成功!!"
add: "新增"
back: "返回"
delete: "刪除"
edit: "編輯"
nothing: "無"
show: "顯示"
sure?: "您肯定嗎?"
update: "更新"
yes_: "是"
no_: "否"
cancel : "取消"
save: "儲存"
hintText: "請輸入搜尋關鍵字"
noResultsText: "沒有相關的比對結果"
searchingText: "搜尋中…"

37
config/routes.rb Normal file
View File

@ -0,0 +1,37 @@
Rails.application.routes.draw do
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
get 'competition_setting' => "competitions#setting"
get 'competitions/download_excel_format' => 'competitions#excel_format'
post 'competitions/import_from_excel' => 'competitions#import_from_excel'
resources :competitions do
collection do
get 'toggle_hide' => 'competitions#toggle_hide'
get 'analysis'
get 'analysis_report'
get "download_excel"
end
end
resources :members do
collection do
scope '(:name-:uid)' do
resources :competitions do
collection do
get 'frontend_setting' => 'competitions#frontend_setting'
post 'update_frontend_setting' => 'competitions#update_frontend_setting'
end
end
end
end
end
resources :competition_types
post "competition_types/update_order" => "competition_types#update_order"
end
get "/xhr/personal_competition/get_fields_for_index" => "personal_competitions#get_fields_for_index"
post "/xhr/personal_competition/save_index_fields" => "personal_competitions#save_index_fields"
end
end

View File

@ -0,0 +1,4 @@
require "personal_competition/engine"
module PersonalCompetition
end

View File

@ -0,0 +1,22 @@
module PersonalCompetition
class Engine < ::Rails::Engine
initializer "personal_competition" do
OrbitApp.registration "PersonalCompetition",:type=> 'ModuleApp' do
module_label 'module_name.personal_competition'
base_url File.expand_path File.dirname(__FILE__)
personal_plugin :enable => true, :sort_number => '50', :app_name=>"Competition", :intro_app_name=>"PersonalCompetitionIntro",:path=>"/plugin/personal_competition/profile",:front_path=>"/profile",:admin_path=>"/admin/competitions",:i18n=>'module_name.personal_competition', :module_app_name=>'PersonalCompetition', :field_modifiable => true, :analysis => true, :analysis_path => "/admin/competitions/analysis"
version "0.1"
desktop_enabled true
organization "Rulingcom"
author "RD dep"
intro "I am intro"
update_info 'some update_info'
frontend_enabled
icon_class_no_sidebar "icons-user"
data_count 1..10
end
end
end
end

View File

@ -0,0 +1,3 @@
module PersonalCompetition
VERSION = "0.0.1"
end

View File

@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :personal_honor do
# # Task goes here
# end

View File

@ -0,0 +1,19 @@
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "personal_competition/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "personal_competition"
s.version = PersonalCompetition::VERSION
s.authors = ["Ruling Digital Inc."]
s.email = ["orbit@rulingcom.com"]
s.homepage = "http://www.rulingcom.com"
s.summary = "Summary of Personal Competition."
s.description = "Description of Personal Competition."
s.license = "MIT"
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
end