From af59cef90b53a5d0ebd439d714a28d7bd33b20e2 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 13 Oct 2014 17:38:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=AB=99=E9=A1=B5=E8=84=9A=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 35 +++++++++++++++++++ app/controllers/application_controller.rb | 6 ++++ app/views/admin/contest_page_made.html.erb | 1 + app/views/admin/course_page_made.html.erb | 1 + app/views/admin/first_page_made.html.erb | 1 + app/views/admin/web_footer_made.html.erb | 35 +++++++++++++++++++ app/views/layouts/_base_footer.html.erb | 16 +++------ app/views/web_footer_companies/edit.html.erb | 18 ++++++++++ app/views/web_footer_companies/index.html.erb | 11 ++++++ app/views/web_footer_companies/new.html.erb | 13 +++++++ config/locales/en.yml | 12 +++++++ config/locales/zh.yml | 9 +++++ config/routes.rb | 2 ++ db/schema.rb | 17 ++++++++- 14 files changed, 164 insertions(+), 13 deletions(-) create mode 100644 app/views/admin/web_footer_made.html.erb create mode 100644 app/views/web_footer_companies/edit.html.erb create mode 100644 app/views/web_footer_companies/index.html.erb create mode 100644 app/views/web_footer_companies/new.html.erb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index c75b9f9bf..22538d86c 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -252,4 +252,39 @@ class AdminController < ApplicationController end end + def web_footer_made + if request.get? + @organizer = WebFooterOranizer.all.first + @first_page = FirstPage.where("page_type = 'project'").first + #@notification = ContestNotification.all.first; + elsif request.post? + @first_page = FirstPage.where("page_type = 'project'").first + @first_page.web_title = params[:web_title] + @organizer = WebFooterOranizer.all.first + if @organizer.nil? + @organizer = WebFooterOranizer.new + end + @organizer.name = params[:organizer_name] + @organizer.description = params[:web_footer_oranizer][:description] + if @first_page.save && @organizer.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to admin_web_footer_made_path + } + format.api { render_api_ok } + end + else + respond_to do |format| + flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}\n\t#{@organizer.errors.full_messages[0]}}" + format.html { + render :action => 'web_footer_made' + } + format.api { render_validation_errors(@first_page) } + format.api { render_validation_errors(@contest_page) } + end + end + end + end + end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0d9fe62a8..380baab0c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -42,6 +42,7 @@ class ApplicationController < ActionController::Base end before_filter :find_first_page + before_filter :find_web_footer before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization before_filter :user_agent @@ -758,4 +759,9 @@ class ApplicationController < ActionController::Base @show_course = @first_page.show_course @show_contest = @first_page.show_contest end + + def find_web_footer + @organize = WebFooterOranizer.all.first + @companys = WebFooterCompany.all + end end diff --git a/app/views/admin/contest_page_made.html.erb b/app/views/admin/contest_page_made.html.erb index c1bccb122..dab3b6885 100644 --- a/app/views/admin/contest_page_made.html.erb +++ b/app/views/admin/contest_page_made.html.erb @@ -10,6 +10,7 @@
  • <%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %>
  • <%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %>
  • <%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} , :class => 'selected'%>
  • +
  • <%= link_to l(:label_web_footer_page),{:action => 'web_footer_made'} %>
  • diff --git a/app/views/admin/course_page_made.html.erb b/app/views/admin/course_page_made.html.erb index 15a99bc6a..aa99dc7cd 100644 --- a/app/views/admin/course_page_made.html.erb +++ b/app/views/admin/course_page_made.html.erb @@ -10,6 +10,7 @@
  • <%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %>
  • <%= link_to l(:label_course_first_page), {:action => 'course_page_made'}, :class => 'selected' %>
  • <%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %>
  • +
  • <%= link_to l(:label_web_footer_page),{:action => 'web_footer_made'} %>
  • <%=l(:label_course_first_page)%>

    diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb index 8cb5b3716..e4403457c 100644 --- a/app/views/admin/first_page_made.html.erb +++ b/app/views/admin/first_page_made.html.erb @@ -10,6 +10,7 @@
  • <%= link_to l(:label_project_first_page), {:action => 'first_page_made'}, :class => 'selected' %>
  • <%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %>
  • <%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %>
  • +
  • <%= link_to l(:label_web_footer_page),{:action => 'web_footer_made'} %>
  • <%=l(:label_project_first_page)%>

    diff --git a/app/views/admin/web_footer_made.html.erb b/app/views/admin/web_footer_made.html.erb new file mode 100644 index 000000000..52f7cd5eb --- /dev/null +++ b/app/views/admin/web_footer_made.html.erb @@ -0,0 +1,35 @@ +

    <%=l(:label_first_page_made)%>

    + +<%= form_tag(:controller => 'admin', :action => 'web_footer_made') do%> +

    + + <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

    +
    + +
    +
    <%= link_to l(:label_cooperation_compnay), web_footer_companies_path %>
    +

    <%=l(:label_web_footer_page)%>

    + +

    + + <%= text_field_tag 'organizer_name', params[:label_organizer_name], :value => @organizer.nil? ? "":@organizer.name,:size => 30,:style => "font-size:small;width:497px;margin-left:80px;" %> +

    +

    + + + <%= text_area 'web_footer_oranizer', 'description', :value => @organizer.nil? ? "" : @organizer.description,:cols => 80, :rows => 15, :class => 'wiki-edit' %> + <%= wikitoolbar_for 'web_footer_oranizer_description' %> +

    + <%= submit_tag l(:button_save), :class => "small", :name => nil %> +<% end %> +
    + + + +
    \ No newline at end of file diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb index 46fc0debd..0a5fe6909 100644 --- a/app/views/layouts/_base_footer.html.erb +++ b/app/views/layouts/_base_footer.html.erb @@ -7,20 +7,12 @@

    - <%=l(:label_organizers)%> - <%= link_to l(:label_organizers_information),"http://www.nudt.edu.cn/ArticleShow.asp?ID=47",:target=>"_blank"%> - <%= link_to l(:label_organizers_information_institute), "http://www.nudt.edu.cn/ArticleShow.asp?ID=41", :target => "_blank" %> - <%=l(:label_copyright)%>©2007~2014 - <%= link_to l(:label_contact_us),"http://" + Setting.host_name + "/projects/2/member", :target=>"_blank" %> - <%= link_to l(:label_record),"http://www.miibeian.gov.cn/", :target => "_blank" %> - + <%= @organize.description.html_safe%>

    diff --git a/app/views/web_footer_companies/edit.html.erb b/app/views/web_footer_companies/edit.html.erb new file mode 100644 index 000000000..b84d3e064 --- /dev/null +++ b/app/views/web_footer_companies/edit.html.erb @@ -0,0 +1,18 @@ +

    <%= link_to l(:label_cooperation_compnay), web_footer_companies_path %> » <%=l(:label_edit_company)%>

    +<%= labelled_form_for @company do |f| %> + <%= error_messages_for 'tracker' %> + +
    +
    +

    <%= f.text_field :name, :required => true %>

    +

    <%= f.text_field :url, :required => true %>

    +

    + +

    +
    + <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@company} %> +
    +
    + <%= submit_tag l(:button_save) %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/web_footer_companies/index.html.erb b/app/views/web_footer_companies/index.html.erb new file mode 100644 index 000000000..e2f5bc111 --- /dev/null +++ b/app/views/web_footer_companies/index.html.erb @@ -0,0 +1,11 @@ +
    <%= link_to l(:label_new_company), new_web_footer_company_path,:class => "icon icon-add" %>
    +

    <%=l(:label_web_footer_cooperation_compnay)%>

    + + \ No newline at end of file diff --git a/app/views/web_footer_companies/new.html.erb b/app/views/web_footer_companies/new.html.erb new file mode 100644 index 000000000..0afd3009c --- /dev/null +++ b/app/views/web_footer_companies/new.html.erb @@ -0,0 +1,13 @@ +

    <%= link_to l(:label_cooperation_compnay), web_footer_companies_path %> » <%=l(:label_new_company)%>

    +<%= labelled_form_for @company do |f| %> + <%= error_messages_for 'tracker' %> + +
    +
    +

    <%= f.text_field :name, :required => true %>

    +

    <%= f.text_field :url, :required => true %>

    + +
    + <%= submit_tag l(:button_create) %> +
    +<% end %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index d7b7f5421..1f8224485 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -295,6 +295,7 @@ en: field_hide_mail: Hide my email address field_comments: Comment field_url: URL + field_logo_size: Logo Size field_start_page: Start page field_subproject: Subproject field_hours: Hours @@ -520,6 +521,17 @@ en: label_project_new: New project label_project_plural: Projects label_project_deposit: Projects + label_first_page_made: Homepage customization + label_project_first_page: Project hosting platform page + label_course_first_page: Practice teaching platform of home page + label_contest_first_page: The competition of combat platform page + label_web_footer_page: Site footer configuration + label_organizer_name: Organizer name + label_web_footer_description: The footer content + label_cooperation_compnay: The cooperation unit + label_web_footer_cooperation_compnay: Site footer cooperation unit + label_new_company: Add the cooperation unit + label_upload_logo: Upload logo label_x_projects: zero: no projects one: 1 project diff --git a/config/locales/zh.yml b/config/locales/zh.yml index ce0222e52..5d40bfc34 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -315,6 +315,7 @@ zh: field_hide_mail: 隐藏我的邮件地址 field_comments: 注释 field_url: 路径 + field_logo_size: logo大小 field_start_page: 起始页 field_subproject: 子项目 field_hours: 小时 @@ -525,6 +526,14 @@ zh: label_project_first_page: 项目托管平台首页 label_course_first_page: 课程实践平台首页 label_contest_first_page: 竞赛实战平台首页 + label_web_footer_page: 网站页脚配置 + label_organizer_name: 主办单位名称 + label_web_footer_description: 页脚内容 + label_cooperation_compnay: 合作单位 + label_web_footer_cooperation_compnay: 网站页脚合作单位 + label_new_company: 添加合作单位 + label_edit_company: 编辑合作单位 + label_upload_logo: 上传logo label_x_projects: zero: 无项目 one: 1 个项目 diff --git a/config/routes.rb b/config/routes.rb index f4f858a9f..f61e61f9d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -573,6 +573,7 @@ RedmineApp::Application.routes.draw do match 'permissions', :via => [:get, :post] end end + resources :web_footer_companies, :only => [:index, :new, :edit, :create,:update,:destroy] resources :enumerations, :except => :show match 'enumerations/:type', :to => 'enumerations#index', :via => :get @@ -588,6 +589,7 @@ RedmineApp::Application.routes.draw do match 'admin/first_page_made', :via => [:get,:post] match 'admin/course_page_made', :via => [:get,:post] match 'admin/contest_page_made', :via => [:get,:post] + match 'admin/web_footer_made', :via => [:get,:post] match 'admin/search', :via => [:get, :post] match 'admin/plugins', :via => :get match 'admin/info', :via => :get diff --git a/db/schema.rb b/db/schema.rb index ea5c2107d..b380c013c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20141009055029) do +ActiveRecord::Schema.define(:version => 20141013023400) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1209,6 +1209,21 @@ ActiveRecord::Schema.define(:version => 20141009055029) do add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" + create_table "web_footer_companies", :force => true do |t| + t.string "name" + t.string "logo_size" + t.string "url" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "web_footer_oranizers", :force => true do |t| + t.string "name" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "wiki_content_versions", :force => true do |t| t.integer "wiki_content_id", :null => false t.integer "page_id", :null => false