From 865f0265a2105e189ed7728901c9e480c577aa5a Mon Sep 17 00:00:00 2001 From: spen Date: Fri, 9 Jan 2015 15:42:05 +0800 Subject: [PATCH] something fix --- .../personal_diplomas_controller.rb | 4 +- app/models/diploma.rb | 46 ++++- app/views/admin/diplomas/_diploma.html.erb | 2 +- app/views/admin/diplomas/_form.html.erb | 195 +++++++++--------- app/views/admin/diplomas/index.html.erb | 2 +- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 6 +- 7 files changed, 150 insertions(+), 106 deletions(-) diff --git a/app/controllers/personal_diplomas_controller.rb b/app/controllers/personal_diplomas_controller.rb index 828cd61..146ec1d 100644 --- a/app/controllers/personal_diplomas_controller.rb +++ b/app/controllers/personal_diplomas_controller.rb @@ -35,9 +35,7 @@ class PersonalDiplomasController < ApplicationController "country", "department", "degree", - "url", - "keywords", - "note" + "url" ] {"plugin_datas"=>plugin.get_plugin_data(fields_to_show)} diff --git a/app/models/diploma.rb b/app/models/diploma.rb index 982150f..c144327 100644 --- a/app/models/diploma.rb +++ b/app/models/diploma.rb @@ -27,7 +27,7 @@ class Diploma def duration if !self.start_date.nil? or !self.end_date.nil? - (self.start_date.strftime('%Y.%m') rescue "")+' ~ '+(self.end_date.strftime('%Y.%m') rescue "") + (self.start_date.strftime('%Y.%m') rescue "")+' ~ '+(self.end_date.strftime('%Y.%m') rescue I18n.t('personal_diploma.up_to_today')) else "" end @@ -37,6 +37,50 @@ class Diploma [self.school_name,self.department,self.degree].join(' ') end + def self.get_plugin_datas_to_member(datas) + + fields_to_show = [ + "school_name", + "country", + "department", + "degree", + "duration" + ] + + pd_title = fields_to_show.collect do |t| + { + "plugin_data_title" => I18n.t("personal_diploma.#{t}") + } + end + + plugin_datas = datas.where(:is_hidden=>false).order_by(:end_date=>'desc', :start_date=>'desc').collect do |p| + + pd_data = [] + fields_to_show.collect do |t| + if t == "school_name" + pd_data << { "data_title" => "#{p.send(t)}" } + elsif t == "duration" + if !p.send('start_date').nil? or !p.send('end_date').nil? + date = (p.send('start_date').strftime('%Y.%m') rescue "")+' ~ '+(p.send('end_date').strftime('%Y.%m') rescue I18n.t('personal_diploma.up_to_today')) + else + date = "" + end + pd_data << { "data_title" => date } + else + pd_data << { "data_title" => p.send(t) } + end + end + + { + "pd_datas" => pd_data + } + + end + + return [pd_title,plugin_datas] + + end + def get_plugin_data(fields_to_show) plugin_datas = [] fields_to_show.each do |field| diff --git a/app/views/admin/diplomas/_diploma.html.erb b/app/views/admin/diplomas/_diploma.html.erb index d130797..db83dfc 100644 --- a/app/views/admin/diplomas/_diploma.html.erb +++ b/app/views/admin/diplomas/_diploma.html.erb @@ -1,6 +1,5 @@ <% @diplomas.each do |diploma| %> "> - <%= diploma.member_profile.name rescue "" %> <%= diploma.duration %> <%= link_to diploma.school_name, OrbitHelper.url_to_plugin_show(diploma.to_param,'personal_diploma'), target: "blank"%> @@ -13,5 +12,6 @@ <%= diploma.department %> <%= diploma.degree %> + <%= diploma.member_profile.name rescue "" %> <% end %> \ No newline at end of file diff --git a/app/views/admin/diplomas/_form.html.erb b/app/views/admin/diplomas/_form.html.erb index c6c44bd..d8ffc84 100644 --- a/app/views/admin/diplomas/_form.html.erb +++ b/app/views/admin/diplomas/_form.html.erb @@ -2,6 +2,7 @@ <% 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/bootstrap-datetimepicker" %> @@ -12,103 +13,6 @@
- - - - - -
- - -
- -
- -
- <%= @member.name rescue ''%> - <%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %> -
-
- - -
- -
- <%= f.datetime_picker :start_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM" %> -
-
- - -
- -
- <%= f.datetime_picker :end_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM" %> -
-
- - -
- -
- -
-
- - -
- -
- <%= f.text_field :url, :class => "span5" %> -
-
- - -
- -
- <%= f.text_field :keywords, :class => "span5" %> -
-
- - -
- -
- <%= f.text_area :note, rows: 2, class: "input-block-level" %> -
-
- -
- - -
- - -
- -
- -
-
- -
- -
-
+ + + + + +
+ + +
+ +
+ +
+ <%= @member.name rescue ''%> + <%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %> +
+
+ + +
+ +
+ <%= f.datetime_picker :start_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM" %> +
+
+ + +
+ +
+ <%= f.datetime_picker :end_date, :no_label => true, :format=>"yyyy/MM", :placeholder=>"YYYY/MM" %> +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ <%= f.text_field :url, :class => "span5" %> +
+
+ + +
+ +
+ <%= f.text_field :keywords, :class => "span5" %> +
+
+ + +
+ +
+ <%= f.text_area :note, rows: 2, class: "input-block-level" %> +
+
+ +
+ + +
+ + +
+ +
+ +
+
+ +
+ +
+ diff --git a/app/views/admin/diplomas/index.html.erb b/app/views/admin/diplomas/index.html.erb index 10c7d70..1f3fc04 100644 --- a/app/views/admin/diplomas/index.html.erb +++ b/app/views/admin/diplomas/index.html.erb @@ -1,11 +1,11 @@ - + diff --git a/config/locales/en.yml b/config/locales/en.yml index 4ef01a6..69761f8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -18,6 +18,7 @@ en: issue_no : "Issue.No" form_to_start : "From" form_to_end : "To" + up_to_today : "Up to today" total_pages : "Total Pages" keywords : "Keywords" abstract : "Abstract" diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index bfd7607..cd00072 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -19,7 +19,8 @@ zh_tw: vol_no : "卷數" issue_no : "期數" form_to_start : "起" - form_to_end : "訖" + form_to_end : "迄" + up_to_today : "迄今" total_pages : "總頁數" keywords : "關鍵字" abstract : "摘要" @@ -29,12 +30,11 @@ zh_tw: level_type : "期刊類別" author_type : "作者類別" from : "起" - to : "訖" + to : "迄" file : "檔案" file_name : "檔案名稱" description : "描述" pages : "Pages" - country : "國家" department : "系所" degree : "學位"
<%= t('users.name') %> <%= t('personal_diploma.duration') %> <%= t('personal_diploma.school_name') %> <%= t('personal_diploma.department') %> <%= t('personal_diploma.degree') %><%= t('users.name') %>