From b4dd8409eb57b17bce852226dcabaeceb8361a38 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 10 Jul 2014 17:38:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=89=98?= =?UTF-8?q?=E7=AE=A1=E5=B9=B3=E5=8F=B0=E9=A6=96=E9=A1=B5=E5=AE=9A=E5=88=B6?= =?UTF-8?q?=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 | 30 +++++++++++++++++++ app/controllers/welcome_controller.rb | 2 +- app/helpers/application_helper.rb | 7 ++++- app/models/first_page.rb | 3 ++ app/views/admin/first_page_made.html.erb | 28 +++++++++++++++++ app/views/users/_score_new_index.html.erb | 6 ++-- app/views/users/_show_new_score.html.erb | 12 ++++---- app/views/users/_user_score.html.erb | 2 +- app/views/users/show_new_score.html.erb | 12 ++++---- app/views/welcome/index.html.erb | 12 ++++++-- config/locales/zh.yml | 5 ++++ config/routes.rb | 1 + .../20140710071720_create_first_pages.rb | 17 +++++++++++ db/schema.rb | 10 ++++++- lib/redmine.rb | 1 + test/fixtures/first_pages.yml | 11 +++++++ test/unit/first_page_test.rb | 7 +++++ 17 files changed, 144 insertions(+), 22 deletions(-) create mode 100644 app/models/first_page.rb create mode 100644 app/views/admin/first_page_made.html.erb create mode 100644 db/migrate/20140710071720_create_first_pages.rb create mode 100644 test/fixtures/first_pages.yml create mode 100644 test/unit/first_page_test.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 2a3ce15d8..152fb059e 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -234,4 +234,34 @@ class AdminController < ApplicationController format.api end end + + #首页定制 + def first_page_made + if request.get? + @first_page = FirstPage.all.first + elsif request.post? + @first_page = FirstPage.all.first + @first_page.web_title = params[:web_title] + @first_page.description = params[:description] + @first_page.title = params[:title] + if @first_page.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to admin_first_page_made_path + } + format.api { render_api_ok } + end + else + respond_to do |format| + format.html { + first_page_made + render :action => 'first_page_made' + } + format.api { render_validation_errors(@first_page) } + end + end + end + + end end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index bf18332df..0920d2e42 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -21,7 +21,7 @@ class WelcomeController < ApplicationController before_filter :entry_select, :only => [:index] def index - + @first_page = FirstPage.all.first end def robots diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c9dc4fa26..3f873a64d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -625,10 +625,15 @@ module ApplicationHelper end def html_title(*args) + first_page = FirstPage.all.first if args.empty? title = @html_title || [] title << @project.name if @project - title << Setting.app_title unless Setting.app_title == title.last + if first_page.nil? || first_page.web_title.nil? + title << Setting.app_title unless Setting.app_title == title.last + else + title << first_page.web_title unless first_page.web_title == title.last + end title.select {|t| !t.blank? }.join(' - ') else @html_title ||= [] diff --git a/app/models/first_page.rb b/app/models/first_page.rb new file mode 100644 index 000000000..8d8bbcff6 --- /dev/null +++ b/app/models/first_page.rb @@ -0,0 +1,3 @@ +class FirstPage < ActiveRecord::Base + attr_accessible :description, :title, :web_title +end diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb new file mode 100644 index 000000000..9e863d813 --- /dev/null +++ b/app/views/admin/first_page_made.html.erb @@ -0,0 +1,28 @@ +

<%=l(:label_first_page_made)%>

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

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %> +
+

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

+

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

+

+ + <%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ <%= submit_tag l(:button_save), :class => "small", :name => nil %> +<% end %> +
+ + + +
\ No newline at end of file diff --git a/app/views/users/_score_new_index.html.erb b/app/views/users/_score_new_index.html.erb index 43687aa78..0f5d96a45 100644 --- a/app/views/users/_score_new_index.html.erb +++ b/app/views/users/_score_new_index.html.erb @@ -28,7 +28,7 @@
= <%= l(:label_user_score_of_collaboration) %> + <%= l(:label_user_score_of_influence) %> + <%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %>
-
= <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_f %> - + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %>
-
= <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_f %>
+
= <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_i %> + + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
+
= <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_i %>
diff --git a/app/views/users/_show_new_score.html.erb b/app/views/users/_show_new_score.html.erb index c5f15694e..fddca46ac 100644 --- a/app/views/users/_show_new_score.html.erb +++ b/app/views/users/_show_new_score.html.erb @@ -38,7 +38,7 @@ - +
<%= l(:label_user_score) %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
@@ -49,23 +49,23 @@ <%= link_to l(:label_user_score) , {:controller => 'users', :action => 'score_new_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.total_score).to_f %> + <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= link_to l(:label_user_score_of_collaboration), {:controller => 'users',:action => 'topic_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %>
<%= link_to l(:label_user_score_of_influence), {:controller => 'users',:action => 'project_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_i %>
<%= link_to l(:label_user_score_of_skill), {:controller => 'users',:action => 'activity_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %>
<%= link_to l(:label_user_score_of_active), {:controller => 'users',:action => 'influence_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
diff --git a/app/views/users/_user_score.html.erb b/app/views/users/_user_score.html.erb index d047c11d0..53f05a2dd 100644 --- a/app/views/users/_user_score.html.erb +++ b/app/views/users/_user_score.html.erb @@ -1,5 +1,5 @@ <%= l(:label_user_grade)%>: -<%= link_to(format("%.2f" , user.user_score_attr.total_score).to_f, {:controller => 'users', +<%= link_to(format("%.2f" , user.user_score_attr.total_score).to_i, {:controller => 'users', :action => 'show_new_score', :remote => true, :id => user.id diff --git a/app/views/users/show_new_score.html.erb b/app/views/users/show_new_score.html.erb index 07e82fd5f..0efae940c 100644 --- a/app/views/users/show_new_score.html.erb +++ b/app/views/users/show_new_score.html.erb @@ -53,7 +53,7 @@ - +
<%= l(:label_user_score) %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
@@ -64,23 +64,23 @@ <%= l(:label_user_score) %> : - <%= format("%.2f" , @user.user_score_attr.total_score).to_f %> + <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= l(:label_user_score_of_collaboration) %> : - <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %>
<%= l(:label_user_score_of_influence) %> : - <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_i %>
<%= l(:label_user_score_of_skill) %> : - <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %>
<%= l(:label_user_score_of_active) %> : - <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 345f47739..ffc9706e9 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -30,13 +30,19 @@ +
- <%= image_tag '/images/transparent.png', size: "75x75" %> + + <% if get_avatar?(@first_page) %> + <%= image_tag(url_to_avatar(@first_page), size: "75x75") %> + <% else %> + <%= image_tag '/images/transparent.png', size: "75x75" %> + <% end %> +
- <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_project) %> , <%= l(:label_welcome_trustie_project_description) %> + <%= @first_page.title %> , <%= @first_page.description %>