diff --git a/app/assets/javascripts/web_footer_company.js.coffee b/app/assets/javascripts/web_footer_company.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/web_footer_company.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/web_footer_company.css.scss b/app/assets/stylesheets/web_footer_company.css.scss new file mode 100644 index 000000000..e68badbc2 --- /dev/null +++ b/app/assets/stylesheets/web_footer_company.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the WebFooterCompany controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ 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 50196f21e..69a3b5e8b 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 @@ -760,4 +761,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/controllers/web_footer_companies_controller.rb b/app/controllers/web_footer_companies_controller.rb new file mode 100644 index 000000000..499e6288d --- /dev/null +++ b/app/controllers/web_footer_companies_controller.rb @@ -0,0 +1,50 @@ +class WebFooterCompaniesController < ApplicationController + layout 'admin' + menu_item :projects, :only => :projects + menu_item :plugins, :only => :plugins + menu_item :info, :only => :info + before_filter :require_admin + + def index + @companys = WebFooterCompany.all + end + + def new + @company = WebFooterCompany.new + end + + def create + @company = WebFooterCompany.new(params[:web_footer_company]) + if @company.save + flash[:notice] = l(:notice_successful_create) + redirect_to web_footer_companies_path + else + flash[:error] = "#{l :web_footer_company_create_fail}: #{@company.errors.full_messages[0]}" + new + render :action => 'new' + end + end + + def destroy + @company = WebFooterCompany.find(params[:id]) + @company.destroy + redirect_to web_footer_companies_path + end + + def edit + @company = WebFooterCompany.find(params[:id]) + end + + def update + @company = WebFooterCompany.find(params[:id]) + if @company.update_attributes(params[:web_footer_company]) + flash[:notice] = l(:notice_successful_update) + redirect_to web_footer_companies_path + else + flash[:error] = "#{l :web_footer_company_update_fail}: #{@company.errors.full_messages[0]}" + edit + render :action => 'edit' + end + end + +end diff --git a/app/helpers/web_footer_companies_helper.rb b/app/helpers/web_footer_companies_helper.rb new file mode 100644 index 000000000..ac4b7da09 --- /dev/null +++ b/app/helpers/web_footer_companies_helper.rb @@ -0,0 +1,2 @@ +module WebFooterCompaniesHelper +end diff --git a/app/models/web_footer_company.rb b/app/models/web_footer_company.rb new file mode 100644 index 000000000..0e5f37976 --- /dev/null +++ b/app/models/web_footer_company.rb @@ -0,0 +1,6 @@ +class WebFooterCompany < ActiveRecord::Base + attr_accessible :logo_size, :name, :url + validates_presence_of :name,:url + validates_length_of :name,:url, :maximum => 255 + validates_format_of :url,:with => /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/,:message => l(:is_not_url_error) +end diff --git a/app/models/web_footer_oranizer.rb b/app/models/web_footer_oranizer.rb new file mode 100644 index 000000000..f47d4131f --- /dev/null +++ b/app/models/web_footer_oranizer.rb @@ -0,0 +1,3 @@ +class WebFooterOranizer < ActiveRecord::Base + attr_accessible :description, :name +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/files/_project_file.html.erb b/app/views/files/_project_file.html.erb index 84a86d209..532cf0e6c 100644 --- a/app/views/files/_project_file.html.erb +++ b/app/views/files/_project_file.html.erb @@ -72,4 +72,4 @@ <%= render :partial => 'show_all_attachment' %> -<% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file +<% html_title(l(:project_module_files)) -%> \ 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..3509276c7 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 unless @organize.nil?%>

    diff --git a/app/views/projects/_member_list.html.erb b/app/views/projects/_member_list.html.erb index 670519bc0..09173b835 100644 --- a/app/views/projects/_member_list.html.erb +++ b/app/views/projects/_member_list.html.erb @@ -37,4 +37,5 @@

    <%= l(:label_no_data) %>

    -<% end %> \ No newline at end of file +<% end %> +<% html_title(l(:label_member)) -%> \ No newline at end of file diff --git a/app/views/projects/feedback.html.erb b/app/views/projects/feedback.html.erb index f9182c544..85bd27c78 100644 --- a/app/views/projects/feedback.html.erb +++ b/app/views/projects/feedback.html.erb @@ -110,4 +110,5 @@ function checkMaxLength() { <%= pagination_links_full @feedback_pages %> - \ No newline at end of file + +<% html_title(l(:label_project_tool_response)) -%> \ No newline at end of file diff --git a/app/views/projects/new.html.erb b/app/views/projects/new.html.erb index 184a67e3d..f08d8618f 100644 --- a/app/views/projects/new.html.erb +++ b/app/views/projects/new.html.erb @@ -13,3 +13,5 @@ <%#= submit_tag l(:button_create_and_continue), :name => 'continue' %> <%= javascript_tag "$('#project_name').focus();" %> <% end %> + +<% html_title(l(:label_project_new)) -%> \ No newline at end of file diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index a08577c80..7a06c57cd 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -100,5 +100,5 @@ <%= pagination_links_full @events_pages %> - +<% html_title(l(:label_overview)) -%> diff --git a/app/views/projects/watcherlist.html.erb b/app/views/projects/watcherlist.html.erb index 790eae70c..6a44a4d86 100644 --- a/app/views/projects/watcherlist.html.erb +++ b/app/views/projects/watcherlist.html.erb @@ -30,4 +30,5 @@ <% end %> - \ No newline at end of file + +<% html_title(l(:label_followers)) -%> \ No newline at end of file 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..033a97c30 --- /dev/null +++ b/app/views/web_footer_companies/edit.html.erb @@ -0,0 +1,19 @@ +

    <%= 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 %>

    +

    <%= l(:label_url_prompt) %>

    +

    + +

    +
    + <%= 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..19a6aea48 --- /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..86af4ffe3 --- /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 %>

    +

    <%= l(:label_url_prompt) %>

    +
    + <%= 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..0f1e03ee0 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,22 @@ 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_url_prompt: Web site needs to http or https at the beginning, for example 'http://forge.trustie.net' + web_footer_company_create_fail: The cooperation unit creation failed + web_footer_company_update_fail: The cooperation unit update failed + is_not_url_error: Is not a valid URL + label_x_projects: zero: no projects one: 1 project diff --git a/config/locales/zh.yml b/config/locales/zh.yml index ce0222e52..c0cb5f3d8 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,18 @@ 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_url_prompt: 网址需以"http://"或"https://"开头,例:http://forge.trustie.net + web_footer_company_create_fail: 合作单位创建失败 + web_footer_company_update_fail: 合作单位更新失败 + is_not_url_error: 不是正确的url label_x_projects: zero: 无项目 one: 1 个项目 diff --git a/config/routes.rb b/config/routes.rb index 339d3a853..dedf15dfe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -580,6 +580,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 @@ -595,6 +596,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/migrate/20141013014908_create_web_footer_oranizers.rb b/db/migrate/20141013014908_create_web_footer_oranizers.rb new file mode 100644 index 000000000..13a84ef82 --- /dev/null +++ b/db/migrate/20141013014908_create_web_footer_oranizers.rb @@ -0,0 +1,10 @@ +class CreateWebFooterOranizers < ActiveRecord::Migration + def change + create_table :web_footer_oranizers do |t| + t.string :name + t.text :description + + t.timestamps + end + end +end diff --git a/db/migrate/20141013023400_create_web_footer_companies.rb b/db/migrate/20141013023400_create_web_footer_companies.rb new file mode 100644 index 000000000..9310e5920 --- /dev/null +++ b/db/migrate/20141013023400_create_web_footer_companies.rb @@ -0,0 +1,11 @@ +class CreateWebFooterCompanies < ActiveRecord::Migration + def change + create_table :web_footer_companies do |t| + t.string :name + t.string :logo_size + t.string :url + + t.timestamps + end + end +end 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 diff --git a/plugins/redmine_code_review/app/views/code_review/index.html.erb b/plugins/redmine_code_review/app/views/code_review/index.html.erb index e342d9b3e..8282a7d1c 100644 --- a/plugins/redmine_code_review/app/views/code_review/index.html.erb +++ b/plugins/redmine_code_review/app/views/code_review/index.html.erb @@ -108,3 +108,4 @@ function change_option(flag) { <%= stylesheet_link_tag "code_review.css", :plugin => "redmine_code_review", :media => "screen" %> <% end %> +<% html_title(l(:code_reviews)) -%> \ No newline at end of file diff --git a/test/fixtures/web_footer_companies.yml b/test/fixtures/web_footer_companies.yml new file mode 100644 index 000000000..64ef47d9e --- /dev/null +++ b/test/fixtures/web_footer_companies.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + name: MyString + logo_size: MyString + url: MyString + +two: + name: MyString + logo_size: MyString + url: MyString diff --git a/test/fixtures/web_footer_oranizers.yml b/test/fixtures/web_footer_oranizers.yml new file mode 100644 index 000000000..53b2c6af5 --- /dev/null +++ b/test/fixtures/web_footer_oranizers.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + name: MyString + description: MyText + +two: + name: MyString + description: MyText diff --git a/test/functional/web_footer_companies_controller_test.rb b/test/functional/web_footer_companies_controller_test.rb new file mode 100644 index 000000000..d225b6110 --- /dev/null +++ b/test/functional/web_footer_companies_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WebFooterCompaniesControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/helpers/web_footer_companies_helper_test.rb b/test/unit/helpers/web_footer_companies_helper_test.rb new file mode 100644 index 000000000..aea13fc78 --- /dev/null +++ b/test/unit/helpers/web_footer_companies_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class WebFooterCompaniesHelperTest < ActionView::TestCase +end diff --git a/test/unit/web_footer_company_test.rb b/test/unit/web_footer_company_test.rb new file mode 100644 index 000000000..7b97d1107 --- /dev/null +++ b/test/unit/web_footer_company_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WebFooterCompanyTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/unit/web_footer_oranizer_test.rb b/test/unit/web_footer_oranizer_test.rb new file mode 100644 index 000000000..dabe0f562 --- /dev/null +++ b/test/unit/web_footer_oranizer_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WebFooterOranizerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end