From 2b6a376d315091fa2df31bbe4084ca8b9c45dbeb Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 15 Aug 2014 14:30:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E4=B8=BA=E5=88=9D=E5=A7=8B=E7=8A=B6=E6=80=81=E6=97=B6=E4=BC=9A?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=9A=84=E9=83=A8=E5=88=86bug=E3=80=81?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=83=A8=E5=88=86=E8=BF=9E=E6=8E=A5=E7=9A=84?= =?UTF-8?q?=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 6 ++ app/controllers/welcome_controller.rb | 9 +-- app/views/layouts/_base_header.html.erb | 4 +- app/views/welcome/contest.html.erb | 4 +- app/views/welcome/course.html.erb | 4 +- db/schema.rb | 82 +++++------------------ lib/redmine.rb | 2 +- 7 files changed, 34 insertions(+), 77 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f47ba446e..178a82d17 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -725,6 +725,12 @@ class ApplicationController < ActionController::Base #查找首页相关信息 def find_first_page @first_page = FirstPage.where("page_type = 'project'").first + if @first_page.nil? + @first_page = FirstPage.new + @first_page.page_type = 'project' + @first_page.description = "" + @first_page.save() + end @show_course = @first_page.show_course @show_contest = @first_page.show_contest end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 80b4e3576..4e7cf0ce9 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -20,11 +20,12 @@ class WelcomeController < ApplicationController include WelcomeHelper helper :project_score caches_action :robots + before_filter :find_first_page, :only => [:index] # before_filter :fake, :only => [:index, :course] before_filter :entry_select, :only => [:index] def index - @first_page = FirstPage.where("page_type = 'project'").first + #@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") @@ -76,7 +77,7 @@ class WelcomeController < ApplicationController logo = get_avatar?(@course_page) id = params[:school_id] logo_link = "" - if id.nil? && User.current.user_extensions.school.nil? + if id.nil? && (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) if logo logo_link = url_to_avatar(@course_page) else @@ -148,8 +149,8 @@ class WelcomeController < ApplicationController private # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 def entry_select - @first_page = FirstPage.where("page_type = 'project'").first - url = request.original_url + #@first_page = FirstPage.where("page_type = 'project'").first + url = request.original_url.gsub('/','') if url.include?(Setting.host_course) if @first_page.show_course == 1 course diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 3a7a6a8ee..3116a9a68 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -44,11 +44,11 @@ <% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%> <% hasCourse=true%> -
  • <%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %> +
  • <%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id} %> diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index d735e1013..8df19a280 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -153,7 +153,7 @@

    <%=l(:label_current_hot_contest)%>

    - <%= link_to l(:label_more_information), {:controller => 'contests', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %> + <%= link_to l(:label_more_information), {:controller => 'contests', :action => 'index'}, :target => "_blank" %>
    <% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %> @@ -294,7 +294,7 @@

    <%=l(:label_current_attendingcontest_work)%>

    - <%= link_to l(:label_more_information), {:controller => 'softapplications', :action => 'index', :host => Setting.contest_domain}, :target => "_blank" %> + <%= link_to l(:label_more_information), {:controller => 'softapplications', :action => 'index'}, :target => "_blank" %>
    <% if Softapplication.count > 0%>
    diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index c979807b9..c46df7777 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -42,7 +42,7 @@
    - <% if @school_id.nil? and User.current.user_extensions.school.nil? %> + <% if @school_id.nil? and (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) %> <% else %> <% if @school_id == "0" %> <% else %> @@ -58,7 +58,7 @@ <% unless @course_page.nil? %> <%= @course_page.title %> - <% if @school_id.nil? and User.current.user_extensions.school.nil? %> + <% if @school_id.nil? and (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) %> , <%= @course_page.description %> <% else %> <% if @school_id == "0" %> diff --git a/db/schema.rb b/db/schema.rb index a49ef688e..e39644b3b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -177,58 +177,6 @@ ActiveRecord::Schema.define(:version => 20140814062455) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -872,18 +820,18 @@ ActiveRecord::Schema.define(:version => 20140814062455) do create_table "relative_memos", :force => true do |t| t.integer "osp_id" t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :limit => 16777215, :null => false + t.string "subject", :null => false + t.text "content", :null => false t.integer "author_id" - t.integer "replies_count", :default => 0 + t.integer "replies_count", :default => 0 t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.boolean "is_quote", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count_crawl", :default => 0 + t.integer "viewed_count_local", :default => 0 t.string "url" t.string "username" t.string "userhomeurl" @@ -957,11 +905,10 @@ ActiveRecord::Schema.define(:version => 20140814062455) do t.string "url" t.string "title" t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "project_id" t.integer "user_id" - t.string "description" end create_table "softapplications", :force => true do |t| @@ -1067,8 +1014,8 @@ ActiveRecord::Schema.define(:version => 20140814062455) do t.integer "zip_code" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.string "technical_title" t.integer "identity" + t.string "technical_title" t.string "student_id" t.string "teacher_realname" t.string "student_realname" @@ -1126,6 +1073,9 @@ ActiveRecord::Schema.define(:version => 20140814062455) do t.integer "active" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.integer "level" + t.integer "file" + t.integer "issue" end create_table "user_statuses", :force => true do |t| diff --git a/lib/redmine.rb b/lib/redmine.rb index 4fa909325..64b39145e 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -408,7 +408,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', :host => Setting.course_domain} + menu.push :user_course, {:controller => 'users', :action => 'user_courses'} #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