finish help pages

This commit is contained in:
BOHUNG 2020-01-31 22:56:46 +08:00
parent 4d47fac457
commit ba7713b761
13 changed files with 77 additions and 63 deletions

Binary file not shown.

View File

@ -7,15 +7,29 @@ class OlympiamanagementsController < ApplicationController
uid = OrbitHelper.params[:uid] rescue "" uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || [] categories = OrbitHelper.widget_categories || []
case OrbitHelper.params[:layout_type]
when "olympia_managements_instructions_index"
@sign_up_setting = SignUpSetting.last @sign_up_setting = SignUpSetting.last
@olympiamanagement_instruction = @sign_up_setting.registration_instructions[I18n.locale.to_s].to_s @olympiamanagement_instruction = @sign_up_setting.registration_instructions[I18n.locale.to_s].to_s
@sign_up_setting.attributes.to_h.each do |key,value| @sign_up_setting.attributes.to_h.each do |key,value|
@olympiamanagement_instruction = @olympiamanagement_instruction.gsub("{{#{key}}}",value.to_s) @olympiamanagement_instruction = @olympiamanagement_instruction.gsub("{{#{key}}}",value.to_s)
end end
@edit_link = '/admin/olympiamanagements/sign_up_setting#registration_instructions'
@edit_text = (I18n.locale.to_s == "zh_tw") ? "編輯" : "Edit"
if !OrbitHelper.current_user.nil?
@olympiamanagement_instruction += '<p class="admin-edit text-right"><a class="btn btn-primary" href="'+@edit_link+'" title="'+@edit_text+'"><i class="icon-edit"></i> '+@edit_text+'</a></p>'
end
#sign_up_hint
{ {
"olympiamanagement" => [], "olympiamanagement" => [],
"extras"=>{"instructions"=> @olympiamanagement_instruction} "extras"=>{"instructions"=> @olympiamanagement_instruction}
} }
when "olympia_managements_index"
{
"olympiamanagement" => [],
"extras"=>{"instructions"=> '<h3 style="margin: 20px 0px 10px; padding: 0px; color: rgb(0, 153, 153); font-variant-numeric: normal; font-variant-east-asian: normal; font-weight: bold; font-stretch: normal; font-size: 0.9375em; line-height: 20px; font-family: 微軟正黑體, sans-serif;">'+t('olympiamanagement.sign_up_hint')+'</h3>'}
}
end
end end
def widget def widget
uid = OrbitHelper.params[:uid] rescue "" uid = OrbitHelper.params[:uid] rescue ""
@ -31,6 +45,20 @@ class OlympiamanagementsController < ApplicationController
"extras"=>{"instructions"=> @olympiamanagement_instruction} "extras"=>{"instructions"=> @olympiamanagement_instruction}
} }
end end
def download_school_code
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:school_code)
dir_path = 'tmp/olypiamanagement/'
#FileUtils.rm_r(dir_path, :force => true) if Dir.exist?(dir_path)
FileUtils.mkdir dir_path if !Dir.exist?(dir_path) #create dir for storing tmp_file if dir doesn't exist
@filename = 'download_school_code.xlsx'
Dir.chdir(dir_path) do
File.open(@filename, 'w') do |f|
f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'school_code.xlsx',:locals=> {:@OlympiaSchoolDataFields=>@OlympiaSchoolDataFields} )
end
end
tmp_filename_data = File.read(dir_path +@filename)
send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: "#{Time.now.year}#{Time.now.month}#{Time.now.day}_download_school_code.xlsx")
end
def updata_school_data def updata_school_data
#render :html => '123' #render :html => '123'
end end

View File

@ -47,7 +47,7 @@
<%=render :partial=>'checkbox',:locals=>{:name=>t('olympiamanagement.sign_up_setting_hint'),:params_name=>'[sign_up_setting][set_default_password]',:id=>'set_default_password',:extra_class=>'lleft',:is_checked=>nil}%> <%=render :partial=>'checkbox',:locals=>{:name=>t('olympiamanagement.sign_up_setting_hint'),:params_name=>'[sign_up_setting][set_default_password]',:id=>'set_default_password',:extra_class=>'lleft',:is_checked=>nil}%>
</div> </div>
<div style="clear:both;"></div> <div style="clear:both;"></div>
<h4><%= t('olympiamanagement.remark')+"(#{t('olympiamanagement.print_registration_form')})" %></h4> <h4 id="remark"><%= t('olympiamanagement.remark')+"(#{t('olympiamanagement.print_registration_form')})" %></h4>
<ul class="nav nav-pills language-nav"> <ul class="nav nav-pills language-nav">
<% @site_locales.each_with_index do |locale,i|%> <% @site_locales.each_with_index do |locale,i|%>
<li <%= (i == 0) ? "class=active" : "" %>> <li <%= (i == 0) ? "class=active" : "" %>>
@ -66,7 +66,7 @@
</div> </div>
<% end %> <% end %>
</div> </div>
<h4><%= t('olympiamanagement.registration_instructions') %></h4> <h4 id="registration_instructions"><%= t('olympiamanagement.registration_instructions') %></h4>
<ul class="nav nav-pills language-nav"> <ul class="nav nav-pills language-nav">
<% @site_locales.each_with_index do |locale,i|%> <% @site_locales.each_with_index do |locale,i|%>
<li <%= (i == 0) ? "class=active" : "" %>> <li <%= (i == 0) ? "class=active" : "" %>>

View File

@ -1,7 +0,0 @@
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/cancer_predict.js"></script>
{{table}}
<link href="/assets/cancer_predict.scss" media="screen" rel="stylesheet">
<link href="/assets/bootstrap.min.print.css" media="print" rel="stylesheet">
<link href="/assets/cancer_predict_print.scss" media="print" rel="stylesheet">

View File

@ -0,0 +1,27 @@
# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: "school_class") do |sheet|
row = []
title = sheet.styles.add_style(:bg_color => "FFFF00",:border=>{ :style => :thin, :color => "666666" },:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true})
column = sheet.styles.add_style(:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true},:border=>{ :style => :thin, :color => "666666" })
@fields = [ "school_code", "school_name" ,"school_address" ]
@fields.each do |field|
row << t('olympiamanagement.'+field)
end
#export data start
export_data_rows = []
@OlympiaSchoolDataFields.each do |school_data_field|
temp_row = []
@fields.each do |field_key|
temp_row << (school_data_field[field_key] rescue '')
end
export_data_rows << temp_row
end
#export data end
sheet.add_row row , :style=> title,:widths => row.map{|cell| (cell.length* 11/ 2).round}
export_data_rows.each do |infos_row|
sheet.add_row infos_row , :style=> column
end
end

View File

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

View File

@ -1,30 +0,0 @@
{
"frontend": [
{
"filename" : "olympia_managements_index",
"name" : {
"zh_tw" : "1. 初選線上報名",
"en" : "1. Primary online registration"
},
"thumbnail" : "thumb.png"
},
{
"filename" : "olympia_managements_instructions_index",
"name" : {
"zh_tw" : "2. 線上報名說明",
"en" : "1. Online registration instructions "
},
"thumbnail" : "thumb.png"
}
],
"widgets" : [
{
"filename" : "olympia_managements_widget",
"name" : {
"zh_tw" : "1. 初選線上報名",
"en" : "1. Primary online registration"
},
"thumbnail" : "thumb.png"
}
]
}

View File

@ -1,7 +0,0 @@
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/cancer_predict.js"></script>
{{table}}
<link href="/assets/cancer_predict.scss" media="screen" rel="stylesheet">
<link href="/assets/bootstrap.min.print.css" media="print" rel="stylesheet">
<link href="/assets/cancer_predict_print.scss" media="print" rel="stylesheet">

View File

@ -1,7 +0,0 @@
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/cancer_predict.js"></script>
{{table}}
<link href="/assets/cancer_predict.scss" media="screen" rel="stylesheet">
<link href="/assets/bootstrap.min.print.css" media="print" rel="stylesheet">
<link href="/assets/cancer_predict_print.scss" media="print" rel="stylesheet">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -57,3 +57,4 @@ en:
remark: Remarks remark: Remarks
registration_instructions: Online registration instructions registration_instructions: Online registration instructions
print_registration_form: Print registration form print_registration_form: Print registration form
sign_up_hint: Sign-up doesn't start yet or already close.

View File

@ -57,3 +57,4 @@ zh_tw:
remark: 注意事項 remark: 注意事項
registration_instructions: 線上報名說明 registration_instructions: 線上報名說明
print_registration_form: 列印報名表 print_registration_form: 列印報名表
sign_up_hint: 報名時間尚未開始或已經結束

7
extra_route.txt Normal file
View File

@ -0,0 +1,7 @@
get 'olympiamanagements/updata_school_data' , to: 'olympiamanagements#updata_school_data'
post 'olympiamanagements/updata_school_data' , to: 'olympiamanagements#updata_school_data'
patch 'olympiamanagements/updata_school_data' , to: 'olympiamanagements#updata_school_data'
get 'olympiamanagements/updata_student_data' , to: 'olympiamanagements#updata_student_data'
post 'olympiamanagements/updata_student_data' , to: 'olympiamanagements#updata_student_data'
patch 'olympiamanagements/updata_student_data' , to: 'olympiamanagements#updata_student_data'
get 'olympiamanagements/download_school_code' , to: 'olympiamanagements#download_school_code'