change from personal honor

This commit is contained in:
chiu 2021-02-07 22:56:22 +08:00
parent e1b52466fb
commit a5fe422e33
66 changed files with 551 additions and 656 deletions

View File

@ -1,6 +1,6 @@
source "https://rubygems.org"
# Declare your gem's dependencies in personal_honor.gemspec.
# Declare your gem's dependencies in academic_advising.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

View File

@ -1,104 +0,0 @@
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!

View File

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

View File

@ -8,7 +8,7 @@ require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'PersonalHonor'
rdoc.title = 'AcademicAdvising'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')

View File

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

View File

@ -0,0 +1,124 @@
class AcademicAdvisingsController < ApplicationController
def index
params = OrbitHelper.params
filter_value = params[:academic_advisings_filter_value]
academic_advisings = nil
if filter_value.nil? || filter_value == t("academic_advising.academic_advising_types_all") || filter_value.empty?
academic_advisings = Advising.where(:award_name.ne => nil).or(:award_name.ne => "").sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
else
academic_advising_type_id = AdvisingType.or({ 'title.en' => filter_value }, { 'title.zh_tw' => filter_value }).first.id
academic_advisings = Advising.where(academic_advising_type_id: academic_advising_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 = [
"academic_advising_type",
"year",
"award_name",
"authors",
"awarding_unit",
"advising_students"
]
end
academic_advising_list = []
academic_advisings.each do |academic_advising|
t = []
fields_to_show.each do |fs|
case fs
when "award_name"
t << {"value" => "<a href='#{OrbitHelper.url_to_show(academic_advising.to_param)}'>" + (academic_advising.send(fs) rescue "") + "</a>"}
when "academic_advising_type"
t << {"value" => (academic_advising.send("academic_advising_type").title rescue "")}
when "authors"
member_profile = academic_advising.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 "award_date"
t << {"value" => (academic_advising.send(fs).strftime("%Y/%m") rescue "")}
when "advising_students"
t << {"value" => academic_advising.advising_students_front_data}
else
t << {"value" => (academic_advising.send(fs) rescue "")}
end
end
academic_advising_list << {"academic_advisings" => t}
end
headers = []
fields_to_show.each do |fs|
col = 2
col = 3 if fs == "award_name"
header = fs == "authors" ? t("academic_advising.academic_advisingee") : t("academic_advising.#{fs}")
headers << {
"head-title" => header,
"col" => col
}
end
current_locale = I18n.locale
academic_advising_types = AdvisingType.all.pluck(:title).map { |title| { 'academic_advising_type' => title.to_h[current_locale] } }
academic_advising_types.unshift({ 'academic_advising_type' => t("academic_advising.academic_advising_types_all") })
{
"advisings" => academic_advising_list,
"academic_advising_types" => academic_advising_types,
"extras" => { "widget-title" => t("module_name.academic_advising"),
"url" => '/' + current_locale.to_s + params[:url] },
"headers" => headers,
"total_pages" => academic_advisings.total_pages
}
end
def show
params = OrbitHelper.params
plugin = Advising.where(:is_hidden=>false).find_by(uid: params[:uid])
fields_to_show = [
"year",
"academic_advising_type",
"award_name",
"award_date",
"requirement",
"academic_advisingee",
"awarding_unit",
"advising_students"
]
{"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",
"award_name",
"awarding_unit",
"academic_advising_type",
"award_date",
"requirement",
"authors",
"award_winner"
]
@fields_to_show = @fields_to_show.map{|fs| [(fs == "authors" ? t("users.name") : t("academic_advising.#{fs}")), fs]}
@default_fields_to_show = [
"academic_advising_type",
"year",
"award_name",
"authors",
"awarding_unit",
"advising_students"
]
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

View File

@ -0,0 +1,52 @@
class Admin::AcademicAdvisingTypesController < OrbitMemberController
before_action :allow_admin_only
def new
@academic_advising_type = AdvisingType.new
@url = admin_academic_advising_types_path(@academic_advising_type)
render :layout=>false
end
def create
@academic_advising_type = AdvisingType.new(academic_advising_type_params)
@academic_advising_type.save
@academic_advising_types = AdvisingType.all
render :partial=>'list', :layout=>false
end
def update_order
orders = params["order"]
AdvisingType.each do |ht|
ht.sort_position = orders["#{ht.id}"]
ht.save
end
render :json => {"success" => true}.to_json
end
def edit
@academic_advising_type = AdvisingType.find(params[:id])
@url = admin_academic_advising_type_path(@academic_advising_type)
render :layout=>false
end
def update
@academic_advising_type = AdvisingType.find(params[:id])
@academic_advising_type.update_attributes(academic_advising_type_params)
@academic_advising_type.save
@academic_advising_types = AdvisingType.all
render :partial=>'list', :layout=>false
end
def destroy
academic_advising_type = AdvisingType.find(params[:id])
academic_advising_type.destroy
@academic_advising_types = AdvisingType.all
render :partial=>'list', :layout=>false
end
private
def academic_advising_type_params
params.require(:advising_type).permit! rescue nil
end
end

View File

@ -1,8 +1,8 @@
class Admin::HonorsController < OrbitMemberController
class Admin::AcademicAdvisingsController < OrbitMemberController
layout "member_plugin"
include Admin::PersonalHonorsHelper
include Admin::AcademicAdvisingsHelper
before_action :set_honor, only: [:show, :edit , :update, :destroy]
before_action :set_academic_advising, only: [:show, :edit , :update, :destroy]
before_action :set_plugin
before_action :get_settings,:only => [:new, :edit, :setting]
@ -10,12 +10,12 @@ class Admin::HonorsController < OrbitMemberController
before_action :allow_admin_only, :only => [:index, :setting]
def index
@honors = Honor.order_by(:year=>'desc').page(params[:page]).per(10)
@academic_advisings = Advising.order_by(:year=>'desc').page(params[:page]).per(10)
end
def new
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
@honor = Honor.new
@academic_advising = Advising.new
if params[:desktop]
render :layout => false
@ -39,18 +39,18 @@ class Admin::HonorsController < OrbitMemberController
@data = get_data_for_excel(year_start,year_end)
respond_to do |format|
format.xlsx {
response.headers['Content-Disposition'] = 'attachment; filename="honors.xlsx"'
response.headers['Content-Disposition'] = 'attachment; filename="academic_advisings.xlsx"'
}
end
end
def create
if !honor_params['member_profile_id'].blank?
if !academic_advising_params['member_profile_id'].blank?
@member = MemberProfile.find(honor_params['member_profile_id']) rescue nil
@honor = Honor.new(honor_params)
@honor.save
@member = MemberProfile.find(academic_advising_params['member_profile_id']) rescue nil
@academic_advising = Advising.new(academic_advising_params)
@academic_advising.save
if params[:desktop] == "true"
render json: {"data" => get_paper_list}.to_json
@ -62,9 +62,9 @@ class Admin::HonorsController < OrbitMemberController
params[:author_members].each do |author_member|
honor_params['member_profile_id'] = author_member
@honor = Honor.new(honor_params)
@honor.save
academic_advising_params['member_profile_id'] = author_member
@academic_advising = Advising.new(academic_advising_params)
@academic_advising.save
if params[:desktop] == "true"
render json: {"data" => get_paper_list}.to_json
@ -76,10 +76,10 @@ class Admin::HonorsController < OrbitMemberController
else
honor_params['member_profile_id'] = User.find(current_user.id).member_profile_id
academic_advising_params['member_profile_id'] = User.find(current_user.id).member_profile_id
@honor = Honor.new(honor_params)
@honor.save
@academic_advising = Advising.new(academic_advising_params)
@academic_advising.save
if params[:desktop] == "true"
render json: {"data" => get_paper_list}.to_json
@ -92,16 +92,16 @@ class Admin::HonorsController < OrbitMemberController
end
def edit
@member = @honor.member_profile rescue nil
@member = @academic_advising.member_profile rescue nil
if params[:desktop]
render :layout => false
end
end
def update
@member = @honor.member_profile rescue nil
@honor.update_attributes(honor_params)
@honor.save
@member = @academic_advising.member_profile rescue nil
@academic_advising.update_attributes(academic_advising_params)
@academic_advising.save
if params[:desktop] == "true"
render json: {"data" => get_paper_list}.to_json
else
@ -110,9 +110,9 @@ class Admin::HonorsController < OrbitMemberController
end
def destroy
@honor.destroy
@academic_advising.destroy
respond_to do |format|
format.html { redirect_to(admin_honor_url) }
format.html { redirect_to(admin_academic_advising_url) }
# format.xml { head :ok }
format.js
format.json {render json: {"success" => true}}
@ -121,11 +121,11 @@ class Admin::HonorsController < OrbitMemberController
def toggle_hide
if params[:ids]
@honors = Honor.any_in(_id: params[:ids])
@academic_advisings = Advising.any_in(_id: params[:ids])
@honors.each do |honor|
honor.is_hidden = params[:disable]
honor.save
@academic_advisings.each do |academic_advising|
academic_advising.is_hidden = params[:disable]
academic_advising.save
end
end
@ -135,7 +135,7 @@ class Admin::HonorsController < OrbitMemberController
def excel_format
respond_to do |format|
format.xlsx {
response.headers['Content-Disposition'] = 'attachment; filename="honor_format.xlsx"'
response.headers['Content-Disposition'] = 'attachment; filename="academic_advising_format.xlsx"'
}
end
end
@ -149,12 +149,12 @@ class Admin::HonorsController < OrbitMemberController
user = User.where(:user_name => row.cells[0].value).first rescue nil
if !user.nil?
mp = user.member_profile
import_this_honor(row,mp)
import_this_academic_advising(row,mp)
end
end
redirect_to admin_honors_url
redirect_to admin_academic_advisings_url
else
redirect_to admin_honors_url(:error => "1")
redirect_to admin_academic_advisings_url(:error => "1")
end
end
@ -163,30 +163,30 @@ class Admin::HonorsController < OrbitMemberController
def frontend_setting
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
@intro = HonorIntro.find_by(:member_profile_id=>@member.id) rescue nil
@intro = @intro.nil? ? HonorIntro.new({:member_profile_id=>@member.id}) : @intro
@intro = AdvisingIntro.find_by(:member_profile_id=>@member.id) rescue nil
@intro = @intro.nil? ? AdvisingIntro.new({:member_profile_id=>@member.id}) : @intro
end
def update_frontend_setting
@member = MemberProfile.find(intro_params['member_profile_id']) rescue nil
@intro = HonorIntro.find_by(:member_profile_id=>@member.id) rescue nil
@intro = @intro.nil? ? HonorIntro.new({:member_profile_id=>@member.id}) : @intro
@intro = AdvisingIntro.find_by(:member_profile_id=>@member.id) rescue nil
@intro = @intro.nil? ? AdvisingIntro.new({:member_profile_id=>@member.id}) : @intro
@intro.update_attributes(intro_params)
@intro.save
redirect_to URI.encode('/admin/members/'+@member.to_param+'/Honor')
redirect_to URI.encode('/admin/members/'+@member.to_param+'/AcademicAdvising')
end
def get_settings
@honor_types = HonorType.all
@academic_advising_types = AdvisingType.all
end
def set_plugin
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Honor'}.first
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'AcademicAdvising'}.first
end
private
def set_honor
def set_academic_advising
path = request.path.split('/')
if path.last.include? '-'
uid = path[-1].split("-").last
@ -195,14 +195,14 @@ class Admin::HonorsController < OrbitMemberController
uid = path[-2].split("-").last
uid = uid.split("?").first
end
@honor = Honor.find_by(:uid => uid) rescue Honor.find(params[:id])
@academic_advising = Advising.find_by(:uid => uid) rescue Advising.find(params[:id])
end
def honor_params
params.require(:honor).permit! rescue nil
def academic_advising_params
params.require(:advising).permit! rescue nil
end
def intro_params
params.require(:honor_intro).permit! rescue nil
params.require(:advising_intro).permit! rescue nil
end
end

View File

@ -1,52 +0,0 @@
class Admin::HonorTypesController < OrbitMemberController
before_action :allow_admin_only
def new
@honor_type = HonorType.new
@url = admin_honor_types_path(@honor_type)
render :layout=>false
end
def create
@honor_type = HonorType.new(honor_type_params)
@honor_type.save
@honor_types = HonorType.all
render :partial=>'list', :layout=>false
end
def update_order
orders = params["order"]
HonorType.each do |ht|
ht.sort_position = orders["#{ht.id}"]
ht.save
end
render :json => {"success" => true}.to_json
end
def edit
@honor_type = HonorType.find(params[:id])
@url = admin_honor_type_path(@honor_type)
render :layout=>false
end
def update
@honor_type = HonorType.find(params[:id])
@honor_type.update_attributes(honor_type_params)
@honor_type.save
@honor_types = HonorType.all
render :partial=>'list', :layout=>false
end
def destroy
honor_type = HonorType.find(params[:id])
honor_type.destroy
@honor_types = HonorType.all
render :partial=>'list', :layout=>false
end
private
def honor_type_params
params.require(:honor_type).permit! rescue nil
end
end

View File

@ -1,23 +0,0 @@
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

@ -1,125 +0,0 @@
class PersonalHonorsController < ApplicationController
def index
params = OrbitHelper.params
filter_value = params[:honors_filter_value]
honors = nil
if filter_value.nil? || filter_value == t("personal_honor.honor_types_all") || filter_value.empty?
honors = Honor.where(:award_name.ne => nil).or(:award_name.ne => "").sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
else
honor_type_id = HonorType.or({ 'title.en' => filter_value }, { 'title.zh_tw' => filter_value }).first.id
honors = Honor.where(honor_type_id: honor_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 = [
"honor_type",
"year",
"award_name",
"authors",
"awarding_unit"
]
end
honor_list = []
honors.each do |honor|
t = []
fields_to_show.each do |fs|
case fs
when "award_name"
t << {"value" => "<a href='#{OrbitHelper.url_to_show(honor.to_param)}'>" + (honor.send(fs) rescue "") + "</a>"}
when "honor_type"
t << {"value" => (honor.send("honor_type").title rescue "")}
when "authors"
member_profile = honor.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 "award_date"
t << {"value" => (honor.send(fs).strftime("%Y/%m") rescue "")}
else
t << {"value" => (honor.send(fs) rescue "")}
end
end
honor_list << {"personal_honors" => 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_honor.#{fs}")
headers << {
"head-title" => header,
"col" => col
}
end
current_locale = I18n.locale
honor_types = HonorType.all.pluck(:title).map { |title| { 'honor_type' => title.to_h[current_locale] } }
honor_types.unshift({ 'honor_type' => t("personal_honor.honor_types_all") })
{
"honors" => honor_list,
"honor_types" => honor_types,
"extras" => { "widget-title" => t("module_name.personal_honor"),
"url" => '/' + current_locale.to_s + params[:url] },
"headers" => headers,
"total_pages" => honors.total_pages
}
end
def show
params = OrbitHelper.params
plugin = Honor.where(:is_hidden=>false).find_by(uid: params[:uid])
fields_to_show = [
"year",
"honor_type",
"award_name",
"award_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",
"award_name",
"awarding_unit",
"honor_type",
"award_date",
"country",
"keywords",
"url",
"note",
"authors",
"award_winner"
]
@fields_to_show = @fields_to_show.map{|fs| [(fs == "authors" ? t("users.name") : t("personal_honor.#{fs}")), fs]}
@default_fields_to_show = [
"honor_type",
"year",
"award_name",
"authors",
"awarding_unit"
]
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

View File

@ -1,25 +1,25 @@
module Admin::PersonalHonorsHelper
module Admin::AcademicAdvisingsHelper
def get_paper_list
user = current_user.nil? ? OrbitHelper.current_user : current_user
user_profile = user.member_profile
honors = Honor.where(:member_profile_id => user_profile.id)
honors = honors.collect do |h|
academic_advisings = Advising.where(:member_profile_id => user_profile.id)
academic_advisings = academic_advisings.collect do |h|
{
"id" => h.id.to_s,
"edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/honors/#{h.to_param}/edit",
"delete_url" => "/#{I18n.locale.to_s}/admin/honors/#{h.id.to_s}",
"edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/academic_advisings/#{h.to_param}/edit",
"delete_url" => "/#{I18n.locale.to_s}/admin/academic_advisings/#{h.id.to_s}",
"paper_title" => h.award_name,
"keywords" => h.keywords,
"files" => []
}
end
honors
academic_advisings
end
def import_this_honor(row,mp)
def import_this_academic_advising(row,mp)
value = nil
honor = Honor.new
academic_advising = Advising.new
row.cells.each_with_index do |cell,index|
next if index < 2
next if cell.nil?
@ -34,7 +34,7 @@ module Admin::PersonalHonorsHelper
rescue
value = {"zh_tw" => val}
end
honor.award_name_translations = value
academic_advising.award_name_translations = value
when 4
value = {"en" => val}
when 5
@ -43,24 +43,24 @@ module Admin::PersonalHonorsHelper
rescue
value = {"zh_tw" => val}
end
honor.awarding_unit_translations = value
academic_advising.awarding_unit_translations = value
when 6
honor.year = val
academic_advising.year = val
when 7
honor.language = val
academic_advising.language = val
when 8
hts = HonorType.asc(:created_at).all.to_a
honor.honor_type = hts[val.to_i] if val.to_s.is_i? && val.to_i < hts.count
hts = AdvisingType.asc(:created_at).all.to_a
academic_advising.academic_advising_type = hts[val.to_i] if val.to_s.is_i? && val.to_i < hts.count
when 9
honor.url = val
academic_advising.url = val
when 10
honor.keywords = val
academic_advising.keywords = val
when 11
honor.note = val
academic_advising.note = val
end
end
honor.member_profile = mp
honor.save
academic_advising.member_profile = mp
academic_advising.save
end
def get_data_for_excel(year_start,year_end)
@ -72,7 +72,7 @@ module Admin::PersonalHonorsHelper
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"] = Honor.where(:year.gte => year_start, :year.lte => year_end, :member_profile_id.in => mps) rescue []
d["data"] = Advising.where(:year.gte => year_start, :year.lte => year_end, :member_profile_id.in => mps) rescue []
data << d
end
return data
@ -81,7 +81,7 @@ module Admin::PersonalHonorsHelper
def get_chart_data(year_start,year_end,role,type)
case type
when "category"
jls = HonorType.all
jls = AdvisingType.all
end
finaldata = []
@ -97,7 +97,7 @@ module Admin::PersonalHonorsHelper
(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.honors.where(:year => year.to_s, :member_profile_id.in => mps).count rescue 0
t = jl.academic_advisings.where(:year => year.to_s, :member_profile_id.in => mps).count rescue 0
data["data"][year.to_s] = t
end
finaldata << data
@ -108,7 +108,7 @@ module Admin::PersonalHonorsHelper
# d2 = DateTime.new(year,12,31,23,59)
case type
when "category"
t = Honor.where(:year => year, :member_profile_id.in => mps, :honor_type_id => nil).count rescue 0
t = Advising.where(:year => year, :member_profile_id.in => mps, :academic_advising_type_id => nil).count rescue 0
end
data["data"][year.to_s] = t

View File

@ -1,10 +1,10 @@
class Honor
class Advising
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include Slug
belongs_to :honor_type
belongs_to :academic_advising_type
belongs_to :member_profile
field :year, type: Integer
@ -16,10 +16,10 @@ class Honor
field :url
field :note
field :rss2_id
field :country, localize: true
field :requirement, localize: true
field :create_user_id, :type => BSON::ObjectId
field :update_user_id, :type => BSON::ObjectId
field :advising_student_ids, :type => Array, default: []
# paginates_per 10
before_validation :add_http
@ -29,7 +29,9 @@ class Honor
def slug_title
self.award_name+' '+self.awarding_unit rescue ""
end
def advising_students
MemberProfile.where(:id.in => self.advising_student_ids)
end
def get_plugin_data(fields_to_show)
plugin_datas = []
fields_to_show.each do |field|
@ -39,33 +41,38 @@ class Honor
end
plugin_datas
end
def advising_students_front_data
self.advising_students.collect{|member| "<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member.name}'>#{member.name}</a>"}.join('、')
end
def self.get_plugin_datas_to_member(datas)
page = Page.where(:module => "personal_honor").first rescue nil
page = Page.where(:module => "academic_advising").first rescue nil
if !page.nil? && !page.custom_array_field.blank?
fields_to_show = page.custom_array_field
else
fields_to_show = [
"honor_type",
"academic_advising_type",
"year",
"award_name",
"awarding_unit"
"awarding_unit",
"advising_students"
]
end
fields_to_remove = []
pd_title = []
puts fields_to_show
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)
elsif t=='advising_students'
fields_to_remove << t if (datas.where(:advising_student_ids.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_honor.#{t}")
"plugin_data_title" => I18n.t("academic_advising.#{t}")
} if !fields_to_remove.include?(t)
end
@ -75,18 +82,20 @@ class Honor
pd_data = []
fields_to_show.collect do |t|
if t == "award_name"
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'personal_honor')}' title='#{p.send(t)}' target='_blank'>#{p.send(t)}</a>" }
elsif t == "honor_type"
pd_data << {"data_title" => (p.honor_type.title rescue "")}
pd_data << { "data_title" => "<a href='#{OrbitHelper.url_to_plugin_show(p.to_param,'academic_advising')}' title='#{p.send(t)}' target='_blank'>#{p.send(t)}</a>" }
elsif t == "academic_advising_type"
pd_data << {"data_title" => (p.academic_advising_type.title rescue "")}
elsif t == "award_date"
pd_data << {"data_title" => (p.send(t).strftime("%Y/%m/%d") rescue "")}
pd_data << {"data_title" => (p.send(t).strftime("%Y/%m/%d") rescue "")}
elsif t == "advising_students"
pd_data << {"data_title" => p.advising_students_front_data}
else
pd_data << { "data_title" => p.send(t) }
end
end
{
"pd_datas" => pd_data,
"type-sort" => (p.honor_type.sort_position.to_i rescue 1000),
"type-sort" => (p.academic_advising_type.sort_position.to_i rescue 1000),
"sort-index" => index
}
@ -98,15 +107,17 @@ class Honor
def get_plugin_field_data(field)
case field
when "honoree"
when "academic_advisingee"
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 "honor_type"
value = self.honor_type.title rescue ""
when "academic_advising_type"
value = self.academic_advising_type.title rescue ""
when "award_date"
value = self.award_date.strftime("%Y/%m/%d") rescue ""
when "advising_students"
value = self.advising_students_front_data
else
value = self.send(field) rescue ""
end
@ -115,9 +126,9 @@ class Honor
{
"key"=>field,
"title_class"=>"honor-#{field.gsub('_','-')}-field",
"value_class"=>"honor-#{field.gsub('_','-')}-value",
"title"=>I18n.t('personal_honor.'+field),
"title_class"=>"academic_advising-#{field.gsub('_','-')}-field",
"value_class"=>"academic_advising-#{field.gsub('_','-')}-value",
"title"=>I18n.t('academic_advising.'+field),
"value"=>value
}
end

View File

@ -0,0 +1,4 @@
class AdvisingIntro < PersonalPluginIntro
end

View File

@ -1,9 +1,9 @@
class HonorType
class AdvisingType
include Mongoid::Document
include Mongoid::Timestamps
field :title, localize: true
field :sort_position, :type => Integer, :default => 0
has_many :honors
has_many :academic_advisings
end

View File

@ -1,4 +0,0 @@
class HonorIntro < PersonalPluginIntro
end

View File

@ -4,11 +4,11 @@
<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_honor.#{fs}") %></span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>
<li data-attrib-key="<%= fs %>" class="clearfix"><span class="field-value"><%= fs == "authors" ? t("users.name") : t("academic_advising.#{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_honor.#{fs}") %></span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>
<li data-attrib-key="<%= fs %>" class="clearfix"><span class="field-value"><%= fs == "authors" ? t("users.name") : t("academic_advising.#{fs}") %></span><span class="remove-field"><i class="icon-remove-sign"></i></span></li>
<% end %>
<% end %>
</ul>

View File

@ -1,7 +1,7 @@
<%= form_for(@honor_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %>
<%= form_for(@academic_advising_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_honor.honor_category") %></h3>
<h3 id="myModalLabel"><%= t("academic_advising.academic_advising_category") %></h3>
</div>
<div class="modal-body">
@ -10,7 +10,7 @@
<div class="control-group">
<%= label_tag t(locale), t(locale), :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :value => (@honor_type.title_translations[locale] rescue nil) %>
<%= f.text_field locale, :value => (@academic_advising_type.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>

View File

@ -0,0 +1,2 @@
$('#academic_advising_types tbody').html("<%= j render :partial => '/admin/academic_advisings/list_academic_advising_type', :collection => @academic_advising_types %>");
$('#academic_advising_type_modal').modal('hide');

View File

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

View File

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

View File

@ -0,0 +1,16 @@
<% @academic_advisings.each do |academic_advising| %>
<tr id="<%= dom_id academic_advising %>" class="<%= academic_advising.is_hidden ? "checkHide" : "" %>">
<td><%= academic_advising.year %></td>
<td>
<%= link_to academic_advising.award_name, OrbitHelper.url_to_plugin_show(academic_advising.to_param,'academic_advising'), target: "blank"%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('edit'), edit_admin_academic_advising_path(academic_advising) %></li>
<li><%= link_to t(:delete_), admin_academic_advising_path(id: academic_advising.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
</ul>
</div>
</td>
<td><%= academic_advising.awarding_unit %></td>
<td><%= academic_advising.member_profile.name rescue "" %></td>
</tr>
<% end %>

View File

@ -33,29 +33,29 @@
<!-- awarding_name -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_honor.award_name") %></label>
<label class="control-label muted"><%= t("academic_advising.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_honor.award_name"), value: (@honor.award_name_translations[locale] rescue nil) %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("academic_advising.award_name"), value: (@academic_advising.award_name_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- awarding_unit-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_honor.awarding_unit") %></label>
<label class="control-label muted"><%= t("academic_advising.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_honor.awarding_unit"), value: (@honor.awarding_unit_translations[locale] rescue nil) %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("academic_advising.awarding_unit"), value: (@academic_advising.awarding_unit_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_honor.country") %></label>
<label class="control-label muted"><%= t("academic_advising.requirement") %></label>
<div class="controls">
<%= f.fields_for :country_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_honor.country"), value: (@honor.country_translations[locale] rescue nil) %>
<%= f.fields_for :requirement_translations do |f| %>
<%= f.text_area locale, class: "input-block-level ckeditor", placeholder: t("academic_advising.requirement"), value: (@academic_advising.requirement_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
@ -84,87 +84,52 @@
<!-- 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>
<label class="control-label muted">
<%= t("academic_advising.academic_advisingee") %>
</label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id %>
<% if !@member.nil? %>
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id %>
<% else %>
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'author_members[]', email_members: Array(@member),index: 'academic_advisingee',select_name: 'author_members'} %>
<% end %>
</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_honor -->
<!-- academic_advising -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_honor.year") %></label>
<label class="control-label muted"><%= t("academic_advising.year") %></label>
<div class="controls">
<%= select_year(@honor.year, {:start_year => (DateTime.now.year+5), :end_year => 1930, :prompt => "Choose year"}, {:name => 'honor[year]', :class => "span1"} ) %>
<%= select_year(@academic_advising.year, {:start_year => (DateTime.now.year+5), :end_year => 1930, :prompt => "Choose year"}, {:name => 'advising[year]'} ) %>
</div>
</div>
<!-- award_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_honor.award_date") %></label>
<label class="control-label muted"><%= t("academic_advising.award_date") %></label>
<div class="controls">
<%= f.datetime_picker :award_date, :no_label => true, :format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD", :value => @honor.award_date, :new_record => @honor.new_record? %>
<%= f.datetime_picker :award_date, :no_label => true, :format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD", :value => @academic_advising.award_date, :new_record => @academic_advising.new_record? %>
</div>
</div>
<!-- language -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_honor.language") %></label>
<div class="controls">
<select id="honor_language" name="honor[language]">
<% @site_in_use_locales.each do |locale| %>
<option value="<%= locale %>" <%= @honor.language.eql?(locale.to_s) ? "selected" : ""%>><%= t(locale) %></option>
<% end %>
</select>
</div>
</div>
<!-- honor_type -->
<!-- academic_advising_type -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_honor.honor_category") %></label>
<label class="control-label muted"><%= t("academic_advising.academic_advising_category") %></label>
<div class="controls">
<%= f.select :honor_type_id, @honor_types.collect {|t| [ t.title, t.id ]} %>
<%= f.select :academic_advising_type_id, @academic_advising_types.collect {|t| [ t.title, t.id ]} %>
</div>
</div>
<!-- url -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_honor.url") %></label>
<div class="controls">
<%= f.text_field :url , :class => "span6" %>
</div>
</div>
</div>
<!-- keywords -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_honor.keywords") %></label>
<div class="controls">
<%= f.text_field :keywords %>
</div>
<!-- advising_students -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("academic_advising.advising_students") %></label>
<div class="controls">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'advising[advising_student_ids][]', email_members: Array(@academic_advising.advising_students),index: 'advising_students',select_name: "advising_advising_student_ids"} %>
</div>
<!-- note -->
<div class="control-group big-group">
<label class="control-label muted"><%= t("personal_honor.note") %></label>
<div class="controls">
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
</div>
</div>
</div>
<!-- Status Module -->
@ -172,7 +137,7 @@
<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 @honor.is_hidden? %>">
<label class="checkbox inline btn <%= 'active' if @academic_advising.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>

View File

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

View File

@ -38,7 +38,7 @@
<form id="analysis-form" action="/admin/journal_papers/analysis_report" class="form-horizontal main-forms">
<div class="input-area">
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_honor.year") %> : </label>
<label class="control-label muted"><%= t("academic_advising.year") %> : </label>
<div class="controls">
<%= select_year(DateTime.now.year - 5, {:start_year => DateTime.now.year, :end_year => 1950}, {:name => 'start_year', :class => "span1"} ) %>
-
@ -46,9 +46,9 @@
</div>
</div>
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_honor.graph_by") %> : </label>
<label class="control-label muted"><%= t("academic_advising.graph_by") %> : </label>
<div class="controls">
<%= t("personal_honor.honor_category") %> <input data-fv-validation="required;" data-fv-messages="Please select atleast one.;" type="radio" name="graph_by" class="graph-type" value="category" checked="checked">
<%= t("academic_advising.academic_advising_category") %> <input data-fv-validation="required;" data-fv-messages="Please select atleast one.;" type="radio" name="graph_by" class="graph-type" value="category" checked="checked">
</div>
</div>
</div>
@ -76,7 +76,7 @@
form.form.on("submit",function(){return false;})
$("#generate_excel").on("click",function(){
window.location.href = "/admin/honors/download_excel.xlsx?" + "year_start=" + form.form.find("select[name=start_year]").val() + "&year_end=" + form.form.find("select[name=end_year]").val();
window.location.href = "/admin/academic_advisings/download_excel.xlsx?" + "year_start=" + form.form.find("select[name=start_year]").val() + "&year_end=" + form.form.find("select[name=end_year]").val();
return false;
})
@ -91,7 +91,7 @@
var generateCharts = function(index){
var role = roleArea.find(".role").eq(index);
$.ajax({
url : "/admin/honors/analysis_report",
url : "/admin/academic_advisings/analysis_report",
data : {"role_id" : role.data("role-id"), "year_start" : form.form.find("select[name=start_year]").val(), "year_end" : form.form.find("select[name=end_year]").val(), "graph_by" : form.form.find("input[name=graph_by]:checked").val()},
type : "get",
dataType : "html"

View File

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

View File

@ -9,23 +9,23 @@ wb = xlsx_package.workbook
row = ["Name"]
@site_in_use_locales.each do |locale|
row << t("personal_honor.award_name") + " - " + t(locale.to_s)
row << t("academic_advising.award_name") + " - " + t(locale.to_s)
end
@site_in_use_locales.each do |locale|
row << t("personal_honor.awarding_unit") + " - " + t(locale.to_s)
row << t("academic_advising.awarding_unit") + " - " + t(locale.to_s)
end
row << t("personal_honor.year")
row << t("academic_advising.year")
row << t("personal_honor.language")
row << t("academic_advising.language")
row << t("personal_honor.honor_category")
row << t("academic_advising.academic_advising_category")
row << t("personal_honor.url")
row << t("academic_advising.url")
row << t("personal_honor.keywords")
row << t("academic_advising.keywords")
row << t("personal_honor.note")
row << t("academic_advising.note")
sheet.add_row row, :style => heading
@ -39,7 +39,7 @@ wb = xlsx_package.workbook
end
row << hon.year
row << hon.language
row << hon.honor_type.title rescue ""
row << hon.academic_advising_type.title rescue ""
row << hon.url
row << hon.keywords
row << hon.note

View File

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

View File

@ -1,7 +1,7 @@
# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: "Honor") do |sheet|
wb.add_worksheet(name: "AcademicAdvising") do |sheet|
heading = sheet.styles.add_style(:b => true, :locked => true)
example = sheet.styles.add_style(:i => true)
@ -13,53 +13,53 @@ wb.add_worksheet(name: "Honor") do |sheet|
row1 << ""
row2 << ""
row << t("personal_honor.award_name") + " - " + t("en")
row << t("academic_advising.award_name") + " - " + t("en")
row1 << "textfield"
row2 << ""
row << t("personal_honor.award_name") + " - " + t("zh_tw")
row << t("academic_advising.award_name") + " - " + t("zh_tw")
row1 << "textfield"
row2 << ""
row << t("personal_honor.awarding_unit") + " - " + t("en")
row << t("academic_advising.awarding_unit") + " - " + t("en")
row1 << "textfield"
row2 << ""
row << t("personal_honor.awarding_unit") + " - " + t("zh_tw")
row << t("academic_advising.awarding_unit") + " - " + t("zh_tw")
row1 << "textfield"
row2 << ""
row << t("personal_honor.year")
row << t("academic_advising.year")
row1 << "number"
row2 << "Example : 2015 or 2014 or 1987"
row << t("personal_honor.language")
row << t("academic_advising.language")
row1 << "select"
row2 << "en -> English, zh_tw -> Chinese"
row << t("personal_honor.honor_category")
row << t("academic_advising.academic_advising_category")
row1 << "select"
t = ""
HonorType.asc(:created_at).each_with_index do |jl,i|
AdvisingType.asc(:created_at).each_with_index do |jl,i|
t = t + "#{i}" + " -> " + jl.title + ", "
end
if HonorType.count > 0
if AdvisingType.count > 0
t = t + " Example : 0"
else
t = "Leave this field blank"
end
row2 << t
row << t("personal_honor.url")
row << t("academic_advising.url")
row1 << "textfield"
row2 << "http://domain.com/path"
row << t("personal_honor.keywords")
row << t("academic_advising.keywords")
row1 << "textfield"
row2 << "Example: keyword1,keyword2"
row << t("personal_honor.note")
row << t("academic_advising.note")
row1 << "textarea"
row2 << ""

View File

@ -3,13 +3,13 @@
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<%= form_for(:honor_intro, :url => update_frontend_setting_admin_honors_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %>
<%= form_for(:academic_advising_intro, :url => update_frontend_setting_admin_academic_advisings_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_honor") %></strong></div>
<div class="nav-name"><strong><%= t("module_name.academic_advising") %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">

View File

@ -1,14 +1,14 @@
<table class="table main-list">
<thead>
<tr>
<th class="span3"><%= t('personal_honor.year') %></th>
<th class="span3"><%= t('personal_honor.award_name') %></th>
<th class="span3"><%= t('personal_honor.awarding_unit') %></th>
<th class="span3"><%= t('personal_honor.award_winner') %></th>
<th class="span3"><%= t('academic_advising.year') %></th>
<th class="span3"><%= t('academic_advising.award_name') %></th>
<th class="span3"><%= t('academic_advising.awarding_unit') %></th>
<th class="span3"><%= t('academic_advising.academic_advisingee') %></th>
</tr>
</thead>
<tbody id="tbody_experiences" class="sort-holder">
<%= render 'honor' %>
<%= render 'academic_advising' %>
</tbody>
</table>
@ -20,24 +20,24 @@
<span class="caret"></span>
</button>
<div class="dropdown-menu upload-box">
<form action="/admin/honors/import_from_excel" method="post" enctype="multipart/form-data">
<form action="/admin/academic_advisings/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/honors/download_excel_format.xlsx">Download excel format</a>
<a class="" href="/admin/academic_advisings/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_honor_path, :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_honor_setting_path, :class => 'btn btn-primary pull-right' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_academic_advising_path, :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_academic_advising_setting_path, :class => 'btn btn-primary pull-right' %>
</div>
<div class="pagination pagination-centered">
<%= content_tag :div, paginate(@honors), class: "pagination pagination-centered" %>
<%= content_tag :div, paginate(@academic_advisings), 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_honors_url %>"
window.location.href = "<%= admin_academic_advisings_url %>"
</script>
<% end %>

View File

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

View File

@ -24,8 +24,8 @@
<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_honor_type_path %>#honor_type_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
<span><%= t("personal_honor.honor_category") %></span>
<a class="btn btn-small btn-primary pull-right" href="<%= new_admin_academic_advising_type_path %>#academic_advising_type_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
<span><%= t("academic_advising.academic_advising_category") %></span>
</p>
<div class="detal-list my_scroll">
<div class="scrollbar">
@ -37,9 +37,9 @@
</div>
<div class="viewport">
<div class="overview">
<table id="honor_types" class="table table-striped">
<table id="academic_advising_types" class="table table-striped">
<tbody>
<%= render :partial => 'list_honor_type', :collection => @honor_types.asc(:sort_position) %>
<%= render :partial => 'list_academic_advising_type', :collection => @academic_advising_types.asc(:sort_position) %>
</tbody>
</table>
</div>
@ -49,19 +49,19 @@
</div>
</div>
<div id="honor_type_qe">
<div style="display:none;" class="modal" id="honor_type_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div id="academic_advising_type_qe">
<div style="display:none;" class="modal" id="academic_advising_type_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</div>
</div>
<script type="text/javascript">
$("#honor_types tbody").sortable({
$("#academic_advising_types tbody").sortable({
update : function(){
var data = {};
$("#honor_types tbody tr").each(function(i){
$("#academic_advising_types tbody tr").each(function(i){
data[$(this).data("type-id")] = i;
})
$.ajax({
url : "/admin/honor_types/update_order",
url : "/admin/academic_advising_types/update_order",
type : "post",
data : {"order" : data}
})

View File

@ -1,2 +0,0 @@
$('#honor_types tbody').html("<%= j render :partial => '/admin/honors/list_honor_type', :collection => @honor_types %>");
$('#honor_type_modal').modal('hide');

View File

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

View File

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

View File

@ -1,16 +0,0 @@
<% @honors.each do |honor| %>
<tr id="<%= dom_id honor %>" class="<%= honor.is_hidden ? "checkHide" : "" %>">
<td><%= honor.year %></td>
<td>
<%= link_to honor.award_name, OrbitHelper.url_to_plugin_show(honor.to_param,'personal_honor'), target: "blank"%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('edit'), edit_admin_honor_path(honor) %></li>
<li><%= link_to t(:delete_), admin_honor_path(id: honor.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
</ul>
</div>
</td>
<td><%= honor.awarding_unit %></td>
<td><%= honor.member_profile.name rescue "" %></td>
</tr>
<% end %>

View File

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

View File

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

View File

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

View File

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

View File

@ -7,17 +7,17 @@
<%
if has_access?
@honors = Honor.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
@academic_advisings = Advising.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
else
@honors = Honor.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
@academic_advisings = Advising.where(is_hidden: false, member_profile_id: @member.id).desc(:year).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_honors_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_honors_path(member_profile_id: @member.id.to_s, disable: 'false') ) %>
<%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_academic_advisings_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_academic_advisings_path(member_profile_id: @member.id.to_s, disable: 'false') ) %>
</div>
</div>
<% end -%>
@ -28,34 +28,34 @@
<% if has_access? %>
<th><input type="checkbox" /></th>
<% end -%>
<th class="span3"><%= t('personal_honor.year') %></th>
<th class="span3"><%= t('personal_honor.award_name') %></th>
<th class="span3"><%= t('personal_honor.awarding_unit') %></th>
<th class="span3"><%= t('personal_honor.award_winner') %></th>
<th class="span3"><%= t('academic_advising.year') %></th>
<th class="span3"><%= t('academic_advising.award_name') %></th>
<th class="span3"><%= t('academic_advising.awarding_unit') %></th>
<th class="span3"><%= t('academic_advising.award_winner') %></th>
</tr>
</thead>
<tbody>
<% @honors.each do |honor| %>
<tr id="<%= dom_id honor %>" class="<%= honor.is_hidden ? "checkHide" : "" %>">
<% @academic_advisings.each do |academic_advising| %>
<tr id="<%= dom_id academic_advising %>" class="<%= academic_advising.is_hidden ? "checkHide" : "" %>">
<% if has_access? %>
<td>
<%= check_box_tag 'to_change[]', honor.id.to_s, false, :class => "list-check" %>
<%= check_box_tag 'to_change[]', academic_advising.id.to_s, false, :class => "list-check" %>
</td>
<% end %>
<td><%= honor.year %></td>
<td><%= academic_advising.year %></td>
<td>
<%= link_to honor.award_name, OrbitHelper.url_to_plugin_show(honor.to_param,'personal_honor'), target: "blank"%>
<%= link_to academic_advising.award_name, OrbitHelper.url_to_plugin_show(academic_advising.to_param,'academic_advising'), 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+'/honors/'+honor.id+'/edit' %></li>
<li><%= link_to t(:delete_), admin_honor_path(id: honor.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
<li><%= link_to t('edit'), '/admin/members/'+@member.to_param+'/academic_advisings/'+academic_advising.id+'/edit' %></li>
<li><%= link_to t(:delete_), admin_academic_advising_path(id: academic_advising.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
<% end %>
</ul>
</div>
</td>
<td><%= honor.awarding_unit %></td>
<td><%= honor.member_profile.name %></td>
<td><%= academic_advising.awarding_unit %></td>
<td><%= academic_advising.member_profile.name %></td>
</tr>
<% end %>
</tbody>
@ -65,13 +65,13 @@
<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+'/honors/frontend_setting', :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/academic_advisings/frontend_setting', :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'),
'/admin/members/'+@member.to_param+'/honors/new', :class => 'btn btn-primary' %>
'/admin/members/'+@member.to_param+'/academic_advisings/new', :class => 'btn btn-primary' %>
</div>
<% end %>
<div class="pagination pagination-centered">
<%= paginate @honors, :params => {:direction => params[:direction], :sort => params[:sort] } %>
<%= paginate @academic_advisings, :params => {:direction => params[:direction], :sort => params[:sort] } %>
</div>
</div>

View File

@ -2,7 +2,7 @@
# 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__)
ENGINE_PATH = File.expand_path('../../lib/academic_advising/engine', __FILE__)
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

View File

@ -1,18 +1,18 @@
en:
module_name:
personal_honor: Honor
personal_honor:
academic_advising: AcademicAdvising
academic_advising:
award_winner : "Award winner"
paper_title : "Paper Title"
book_title : "Book Title"
award_name : "Award Name"
awarding_unit : "Awarding Unit"
honor_category : "Honor Category"
honor_type: "Honor Category"
honor_types_all: "All Honor Types"
award_name : "Open Quota"
awarding_unit : "Actual Student Number"
academic_advising_category : "AcademicAdvising Category"
academic_advising_type: "AcademicAdvising Category"
academic_advising_types_all: "All AcademicAdvising Types"
extracted_chapters : "Extracted Chapters"
publishers : "Publishers"
honoree: "Honoree"
academic_advisingee: "Advisor"
authors : "Authors"
tags : "Tags"
year : "Year"
@ -22,8 +22,8 @@ en:
issue_no : "Issue.No"
form_to_start : "From"
form_to_end : "To"
country: "Country"
award_date: "Award Date"
requirement: "Requirements"
award_date: "Closing Date"
total_pages : "Total Pages"
keywords : "Keywords"
abstract : "Abstract"
@ -40,8 +40,9 @@ en:
pages : "Pages"
book_paper_type : "Book Paper Type"
graph_by : "Graph By"
advising_students: "Advising Students"
frontend:
honors: "Honor Frontend"
academic_advisings: "AcademicAdvising Frontend"
create_success : "Successfully Create"
update_success : "Successfully Update"

View File

@ -1,16 +1,16 @@
zh_tw:
module_name:
personal_honor: 榮譽
personal_honor:
academic_advising: 指導學生
academic_advising:
award_winner : "得獎人"
paper_title : "論文名稱"
book_title : "期刊名稱"
award_name : "獎項名稱"
awarding_unit : "頒獎單位"
honor_category : "類別"
honor_type: "類別"
honor_types_all: "所有榮譽項目"
honoree: "受獎人"
award_name : "收授學生名額"
awarding_unit : "目前己收名額"
academic_advising_category : "類別"
academic_advising_type: "類別"
academic_advising_types_all: "所有指導學生項目"
academic_advisingee: "指導教授"
authors : "作者"
tags : "領域"
year : "年度"
@ -24,8 +24,8 @@ zh_tw:
keywords : "關鍵字"
abstract : "摘要"
publication_date : "發表日期"
award_date: "獲獎日期"
country: "國別"
award_date: "截止日期"
requirement: "招收條件"
url : "參考連結"
note : "記事"
level_type : "期刊類別"
@ -36,8 +36,9 @@ zh_tw:
file_name : "檔案名稱"
description : "描述"
graph_by : "Graph By"
advising_students: "已收受學生"
frontend:
honors: "榮譽前台"
academic_advisings: "指導學生前台"
create_success : "新增完成!!"
update_success : "更新完成!!"

View File

@ -2,13 +2,13 @@ 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 'honor_setting' => "honors#setting"
get 'honors/download_excel_format' => 'honors#excel_format'
post 'honors/import_from_excel' => 'honors#import_from_excel'
get 'academic_advising_setting' => "academic_advisings#setting"
get 'academic_advisings/download_excel_format' => 'academic_advisings#excel_format'
post 'academic_advisings/import_from_excel' => 'academic_advisings#import_from_excel'
resources :honors do
resources :academic_advisings do
collection do
get 'toggle_hide' => 'honors#toggle_hide'
get 'toggle_hide' => 'academic_advisings#toggle_hide'
get 'analysis'
get 'analysis_report'
get "download_excel"
@ -18,20 +18,20 @@ Rails.application.routes.draw do
resources :members do
collection do
scope '(:name-:uid)' do
resources :honors do
resources :academic_advisings do
collection do
get 'frontend_setting' => 'honors#frontend_setting'
post 'update_frontend_setting' => 'honors#update_frontend_setting'
get 'frontend_setting' => 'academic_advisings#frontend_setting'
post 'update_frontend_setting' => 'academic_advisings#update_frontend_setting'
end
end
end
end
end
resources :honor_types
post "honor_types/update_order" => "honor_types#update_order"
resources :academic_advising_types
post "academic_advising_types/update_order" => "academic_advising_types#update_order"
end
get "/xhr/personal_honor/get_fields_for_index" => "personal_honors#get_fields_for_index"
post "/xhr/personal_honor/save_index_fields" => "personal_honors#save_index_fields"
get "/xhr/academic_advising/get_fields_for_index" => "academic_advisings#get_fields_for_index"
post "/xhr/academic_advising/save_index_fields" => "academic_advisings#save_index_fields"
end
end

4
lib/academic_advising.rb Normal file
View File

@ -0,0 +1,4 @@
require "academic_advising/engine"
module AcademicAdvising
end

View File

@ -0,0 +1,22 @@
module AcademicAdvising
class Engine < ::Rails::Engine
initializer "academic_advising" do
OrbitApp.registration "AcademicAdvising",:type=> 'ModuleApp' do
module_label 'module_name.academic_advising'
base_url File.expand_path File.dirname(__FILE__)
personal_plugin :enable => true, :sort_number => '50', :app_name=>"Advising", :intro_app_name=>"AdvisingIntro",:path=>"/plugin/academic_advising/profile",:front_path=>"/profile",:admin_path=>"/admin/academic_advisings",:i18n=>'module_name.academic_advising', :module_app_name=>'AcademicAdvising', :field_modifiable => true, :analysis => true, :analysis_path => "/admin/academic_advisings/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

@ -1,3 +1,3 @@
module PersonalHonor
module AcademicAdvising
VERSION = "0.0.1"
end

View File

@ -1,4 +0,0 @@
require "personal_honor/engine"
module PersonalHonor
end

View File

@ -1,22 +0,0 @@
module PersonalHonor
class Engine < ::Rails::Engine
initializer "personal_honor" do
OrbitApp.registration "PersonalHonor",:type=> 'ModuleApp' do
module_label 'module_name.personal_honor'
base_url File.expand_path File.dirname(__FILE__)
personal_plugin :enable => true, :sort_number => '50', :app_name=>"Honor", :intro_app_name=>"PersonalHonorIntro",:path=>"/plugin/personal_honor/profile",:front_path=>"/profile",:admin_path=>"/admin/honors",:i18n=>'module_name.personal_honor', :module_app_name=>'PersonalHonor', :field_modifiable => true, :analysis => true, :analysis_path => "/admin/honors/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

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

View File

@ -0,0 +1,25 @@
<table class="table table-hover table-striped projects-index academic-advising dt-responsive nowrap">
<caption><h3>{{widget-title}}</h3></caption>
<thead>
<tr data-level="0" data-list="headers">
<th class="col-md-{{col}}">{{head-title}}</th>
</tr>
</thead>
<tbody data-level="0" data-list="advisings">
<tr data-level="1" data-list="academic_advisings">
<td>{{value}}</td>
</tr>
</tbody>
</table>
{{pagination_goes_here}}
<script>
$('thead th.col-md-2:nth-child(2)').addClass('min-tablet-l');
$('thead th.col-md-2:nth-child(5)').addClass('min-tablet');
$('table.academic-advising').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

View File

@ -0,0 +1,7 @@
require 'test_helper'
class AcademicAdvisingTest < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, PersonalAcademicAdvising
end
end

View File

@ -9,7 +9,7 @@ require "sprockets/railtie"
require "rails/test_unit/railtie"
Bundler.require(*Rails.groups)
require "personal_honor"
require "academic_advising"
module Dummy
class Application < Rails::Application

View File

@ -1,7 +0,0 @@
require 'test_helper'
class PersonalHonorTest < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, PersonalHonor
end
end