From 57776d67c570e4328e186589cb8544a2873147c3 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 16 Oct 2014 11:09:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 24 +++++++++---------- app/controllers/application_controller.rb | 2 +- app/controllers/bids_controller.rb | 4 ++-- app/controllers/contests_controller.rb | 2 +- app/controllers/courses_controller.rb | 2 +- app/controllers/homework_attach_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/controllers/welcome_controller.rb | 14 +++-------- app/helpers/application_helper.rb | 2 +- app/views/layouts/base_courses.html.erb | 2 +- lib/redmine.rb | 2 +- 11 files changed, 25 insertions(+), 33 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 369bb8ec7..7b4e326ad 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -144,9 +144,9 @@ class AdminController < ApplicationController #首页定制 def first_page_made if request.get? - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') elsif request.post? - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') @first_page.web_title = params[:web_title] @first_page.description = params[:first_page][:description] #@first_page.title = params[:title] @@ -179,11 +179,11 @@ class AdminController < ApplicationController def course_page_made if request.get? - @course_page = FirstPage.where("page_type = 'course'").first - @first_page = FirstPage.where("page_type = 'project'").first + @course_page = FirstPage.find_by_page_type('course') + @first_page = FirstPage.find_by_page_type('project') elsif request.post? - @first_page = FirstPage.where("page_type = 'project'").first - @course_page = FirstPage.where("page_type = 'course'").first + @first_page = FirstPage.find_by_page_type('project') + @course_page = FirstPage.find_by_page_type('course') @first_page.web_title = params[:web_title] @course_page.web_title = params[:web_title] @course_page.title = params[:course_title] @@ -215,12 +215,12 @@ class AdminController < ApplicationController def contest_page_made if request.get? - @contest_page = FirstPage.where("page_type = 'contest'").first - @first_page = FirstPage.where("page_type = 'project'").first + @contest_page = FirstPage.find_by_page_type('contest') + @first_page = FirstPage.find_by_page_type('project') @notification = ContestNotification.first; elsif request.post? - @first_page = FirstPage.where("page_type = 'project'").first - @contest_page = FirstPage.where("page_type = 'contest'").first + @first_page = FirstPage.find_by_page_type('project') + @contest_page = FirstPage.find_by_page_type('contest') @notification = ContestNotification.first; @first_page.web_title = params[:web_title] @contest_page.web_title = params[:web_title] @@ -255,10 +255,10 @@ class AdminController < ApplicationController def web_footer_made if request.get? @organizer = WebFooterOranizer.first - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') #@notification = ContestNotification.all.first; elsif request.post? - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') @first_page.web_title = params[:web_title] @organizer = WebFooterOranizer.first if @organizer.nil? diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ef6bd7582..7f3dc0203 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -754,7 +754,7 @@ class ApplicationController < ActionController::Base #查找首页相关信息 def find_first_page - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') if @first_page.nil? @first_page = FirstPage.new @first_page.page_type = 'project' diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index cce93d86a..a050eb7f2 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -1011,7 +1011,7 @@ class BidsController < ApplicationController #验证是否显示课程 def can_show_course - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') if @first_page.show_course == 2 render_404 end @@ -1019,7 +1019,7 @@ class BidsController < ApplicationController #验证是否显示竞赛 def can_show_contest - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') if @first_page.show_contest == 2 render_404 end diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index f3b471a6a..204dcc201 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -707,7 +707,7 @@ class ContestsController < ApplicationController #验证是否显示竞赛 def can_show_contest - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') if @first_page.show_contest == 2 render_404 end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 01945358d..766967e38 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -696,7 +696,7 @@ class CoursesController < ApplicationController #验证是否显示课程 def can_show_course - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') if @first_page.show_course == 2 render_404 end diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 030c8d1b1..27a221266 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -356,7 +356,7 @@ class HomeworkAttachController < ApplicationController #验证是否显示课程 def can_show_course - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') if @first_page.show_course == 2 render_404 end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d05447d06..9d1bb1472 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -821,7 +821,7 @@ class UsersController < ApplicationController #验证是否显示课程 def can_show_course - @first_page = FirstPage.where("page_type = 'project'").first + @first_page = FirstPage.find_by_page_type('project') if @first_page.show_course == 2 render_404 end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 2e1d5349f..2a5792e36 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -25,8 +25,6 @@ class WelcomeController < ApplicationController before_filter :entry_select, :only => [:index] def index - #@first_page = FirstPage.where("page_type = 'project'").first - #@show_course = @first_page.show_course if @first_page.nil? || @first_page.sort_type.nil? @projects = find_miracle_project(10, 3,"score desc") else @@ -61,12 +59,7 @@ class WelcomeController < ApplicationController end def course - @course_page = FirstPage.where("page_type = 'course'").first - #if params[:school_id] - # @school_id = params[:school_id] - #elsif User.current.logged? && User.current.user_extensions.try(:school) - # @school_id = User.current.user_extensions.school.try(:id) - #end + @course_page = FirstPage.find_by_page_type('course') @school_id = params[:school_id] || User.current.user_extensions.school.try(:id) @logoLink ||= logolink() end @@ -74,7 +67,7 @@ class WelcomeController < ApplicationController def logolink() - @course_page = FirstPage.where("page_type = 'course'").first + @course_page = FirstPage.find_by_page_type('course') logo = get_avatar?(@course_page) id = params[:school_id] logo_link = "" @@ -110,7 +103,7 @@ class WelcomeController < ApplicationController def contest - @contest_page = FirstPage.where("page_type = 'contest'").first + @contest_page = FirstPage.find_by_page_type('contest') @contest_notifications = Contestnotification.order("created_at desc").limit(5) end @@ -150,7 +143,6 @@ class WelcomeController < ApplicationController private # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 def entry_select - #@first_page = FirstPage.where("page_type = 'project'").first url = request.original_url.gsub('/','') if url.include?(Setting.host_course.gsub('/','')) if @first_page.show_course == 1 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cdb71170d..bcba064ec 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -652,7 +652,7 @@ module ApplicationHelper if(args == ["/"]) args = [] end - first_page = FirstPage.where("page_type = 'project'").first + first_page = FirstPage.find_by_page_type('project') if args.empty? title = @html_title || [] title << @project.name if @project diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 91ab68fdf..1c1e6dbd2 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -189,7 +189,7 @@
- <% if @course.description && @course.description.lstrip.rstrip.size>0 %> + <% if @course.description && !@course.description.blank? %>
<%= textilizable @course.description %> diff --git a/lib/redmine.rb b/lib/redmine.rb index 708d25829..db91d7a54 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -415,7 +415,7 @@ Redmine::MenuManager.map :course_menu do |menu| end Redmine::MenuManager.map :user_menu do |menu| menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.user_domain } - menu.push :user_course, {:controller => 'users', :action => 'user_courses'},:if => Proc.new {|c| FirstPage.where("page_type = 'project'").first.show_course != 2} + menu.push :user_course, {:controller => 'users', :action => 'user_courses'},:if => Proc.new {|c| FirstPage.find_by_page_type('project').show_course != 2} #menu.push :user_homework, {:controller => 'users', :action => 'user_homeworks'} by huang menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.project_domain} # menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids'} by huang From 258967263e6721a14b83d3b2b61ddac05cdb5fcb Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 16 Oct 2014 15:07:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E3=80=822=E3=80=81=E5=BE=88=E5=A4=9A=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=A0=87=E9=A2=98=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 4 +++- app/views/contests/new_contest.html.erb | 3 ++- app/views/contests/show_attendingcontest.html.erb | 2 +- app/views/contests/show_contest.html.erb | 2 +- app/views/courses/feedback.html.erb | 3 ++- app/views/courses/homework.html.erb | 1 + app/views/courses/show.html.erb | 2 +- app/views/files/_course_file.html.erb | 3 +-- app/views/layouts/base_homework.html.erb | 2 +- app/views/users/show.html.erb | 1 + app/views/users/user_courses.html.erb | 3 ++- app/views/users/user_newfeedback.html.erb | 2 +- app/views/users/user_projects.html.erb | 1 + config/routes.rb | 2 +- 14 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index a050eb7f2..d9b28c08a 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -225,7 +225,8 @@ class BidsController < ApplicationController respond_to do |format| layout_file = '' case @bid.reward_type - when 3 + when 3 + html_title(l(:label_question_student)) layout_file = 'base_homework' when 1 layout_file = 'base_bids' @@ -523,6 +524,7 @@ class BidsController < ApplicationController respond_to do |format| if @bid.reward_type == 3 format.html { + html_title(l(:label_homework_info)) render :layout => 'base_homework' } elsif @bid.reward_type == 1 diff --git a/app/views/contests/new_contest.html.erb b/app/views/contests/new_contest.html.erb index 019c8c1db..9aa70d370 100644 --- a/app/views/contests/new_contest.html.erb +++ b/app/views/contests/new_contest.html.erb @@ -9,4 +9,5 @@ <%= submit_tag l(:button_create) %> <%= javascript_tag "$('#bid_name').focus();" %> <% end %> -
\ No newline at end of file +
+<% html_title(l(:label_newtype_contest)) -%> \ No newline at end of file diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index 9d5b08ea9..053630a8e 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -312,4 +312,4 @@ - +<% html_title(l(:label_contest_joincontest)) -%> diff --git a/app/views/contests/show_contest.html.erb b/app/views/contests/show_contest.html.erb index cc1210751..3654fa6a1 100644 --- a/app/views/contests/show_contest.html.erb +++ b/app/views/contests/show_contest.html.erb @@ -44,4 +44,4 @@ <%= pagination_links_full @feedback_pages %> - +<% html_title(l(:label_user_response)) -%> diff --git a/app/views/courses/feedback.html.erb b/app/views/courses/feedback.html.erb index a5d7326e0..574061034 100644 --- a/app/views/courses/feedback.html.erb +++ b/app/views/courses/feedback.html.erb @@ -102,4 +102,5 @@ function checkMaxLength() { - \ No newline at end of file + +<% html_title(l(:label_course_feedback)) -%> \ No newline at end of file diff --git a/app/views/courses/homework.html.erb b/app/views/courses/homework.html.erb index acbbaeb4b..52d97cfbf 100644 --- a/app/views/courses/homework.html.erb +++ b/app/views/courses/homework.html.erb @@ -57,3 +57,4 @@ function showSubH(/* ... */){ } +<% html_title(l(:label_homework)) -%> \ No newline at end of file diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index a6575784d..6ea67c7cd 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -119,6 +119,6 @@ <%= pagination_links_full @events_pages %> - +<% html_title(l(:label_course_overview)) -%> diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 55a36e125..cb0084b25 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -69,5 +69,4 @@
<%= render :partial => 'course_show_all_attachment' %>
- -<% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file +<% html_title(l(:label_course_file)) -%> \ No newline at end of file diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 87893e5c4..01813bf52 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -8,7 +8,7 @@ - <%=h l(:label_active_homework) << " - Trustie" %> + <%=h html_title %> <%= csrf_meta_tag %> <%= favicon %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index bc485325c..3d2b7b0f0 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -480,3 +480,4 @@ }); }); +<% html_title(l(:label_activity)) -%> \ No newline at end of file diff --git a/app/views/users/user_courses.html.erb b/app/views/users/user_courses.html.erb index 6a4d7afdd..16f6414d9 100644 --- a/app/views/users/user_courses.html.erb +++ b/app/views/users/user_courses.html.erb @@ -30,4 +30,5 @@ $(document).ready(function() { }) }); }); - \ No newline at end of file + +<% html_title(l(:label_user_course)) -%> \ No newline at end of file diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb index d6337e1d0..6086c0242 100644 --- a/app/views/users/user_newfeedback.html.erb +++ b/app/views/users/user_newfeedback.html.erb @@ -15,4 +15,4 @@ - \ No newline at end of file +<% html_title(l(:label_responses)) -%> \ No newline at end of file diff --git a/app/views/users/user_projects.html.erb b/app/views/users/user_projects.html.erb index b312ed0d4..1129af514 100644 --- a/app/views/users/user_projects.html.erb +++ b/app/views/users/user_projects.html.erb @@ -63,3 +63,4 @@ $('[mode=watched]').click(function(event) {window.location.href='<%=watch_projects_user_url(type: 1)%>'; }); }); +<% html_title(l(:label_user_project)) -%> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index dedf15dfe..04b3cd1fc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -580,7 +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 :web_footer_companies, :except => :show resources :enumerations, :except => :show match 'enumerations/:type', :to => 'enumerations#index', :via => :get