From 7b14be73104936e9d5767e531fafbffc330e3b98 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 15 Aug 2014 08:54:19 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=AF=BC=E8=88=AA=E6=A0=8F=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=81=E6=96=B0=E5=BB=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E8=B7=9F=E8=B8=AAred=5Fproject=5Fscores=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/trackers_controller.rb | 3 ++- app/controllers/zipdown_controller.rb | 2 +- db/schema.rb | 17 ++--------------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb index 94131a2e0..de686493b 100644 --- a/app/controllers/trackers_controller.rb +++ b/app/controllers/trackers_controller.rb @@ -17,7 +17,7 @@ class TrackersController < ApplicationController layout 'admin' - + helper "project_score" before_filter :require_admin, :except => :index before_filter :require_admin_or_api_request, :only => :index accept_api_auth :index @@ -38,6 +38,7 @@ class TrackersController < ApplicationController @tracker ||= Tracker.new(params[:tracker]) @trackers = Tracker.sorted.all @projects = Project.all + @courses = Course.all end def create diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index a5506be93..10aa39df2 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -54,7 +54,7 @@ class ZipdownController < ApplicationController end rescue => e - render file: 'public/file_not_found.html' + render file: 'public/file_not_found.html' , :layout => 'course_base' end private diff --git a/db/schema.rb b/db/schema.rb index 525cfb745..a49ef688e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -441,10 +441,10 @@ ActiveRecord::Schema.define(:version => 20140814062455) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "sort_type" - t.integer "show_course", :default => 1 - t.integer "show_contest", :default => 1 t.integer "image_width", :default => 107 t.integer "image_height", :default => 63 + t.integer "show_course", :default => 1 + t.integer "show_contest", :default => 1 end create_table "forums", :force => true do |t| @@ -907,19 +907,6 @@ ActiveRecord::Schema.define(:version => 20140814062455) do add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - create_table "roles", :force => true do |t| t.string "name", :limit => 30, :default => "", :null => false t.integer "position", :default => 1 From 2b6a376d315091fa2df31bbe4084ca8b9c45dbeb Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 15 Aug 2014 14:30:01 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E4=B8=BA=E5=88=9D=E5=A7=8B=E7=8A=B6=E6=80=81=E6=97=B6?= =?UTF-8?q?=E4=BC=9A=E5=87=BA=E7=8E=B0=E7=9A=84=E9=83=A8=E5=88=86bug?= =?UTF-8?q?=E3=80=81=E5=8E=BB=E9=99=A4=E9=83=A8=E5=88=86=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E7=9A=84=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} %>
      <% User.current.courses.each do |course| %> <% if !course_endTime_timeout?(course) %> -
    • <%= link_to course.name.truncate(10, omission: '...'), {:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %>
    • +
    • <%= link_to course.name.truncate(10, omission: '...'), {:controller => 'courses',:action => 'show',id:course.id} %>
    • <% end %> <% end %>
    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 From ae61ccaca91af2d2efbdaec3e50566153b898f83 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 15 Aug 2014 14:42:28 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=98=BE=E7=A4=BA=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/show.html.erb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 71bea9cfa..3ea5bad92 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -25,13 +25,9 @@ <%= link_to "#{eventToLanguageCourse(e.event_type, @project)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Project)) ? project_files_path(e.container) : e.event_url %> -
    -
    -
    - <%#= textilizable e.event_url,:description %> -
    -
    - <%= h(truncate(strip_tags(e.event_description).gsub(/ /, ' '), length: 30, omission: '...')) %> +
    + <%= textAreailizable e,:event_description %> + <%#= h(truncate(strip_tags(e.event_description).gsub(/ /, ' '), length: 30, omission: '...')) %>
    <%= l :label_activity_time %> From 746022506d9c88f56fe4ea383b0b3fa77a76618d Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 15 Aug 2014 17:43:10 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E9=97=AE=E9=A2=98=E3=80=81=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=BE=97=E5=88=86=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 ++++---- app/views/layouts/base_projects.html.erb | 4 ++-- app/views/welcome/index.html.erb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index eaa96e82a..98b24bc12 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -295,8 +295,8 @@ class UsersController < ApplicationController # 活跃度排序, 就是所谓的得分情况 @s_type = 1 @users = scope. - joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). - reorder('user_scores.active DESC') + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') when '2' # 粉丝数排序 @s_type = 2 @@ -308,8 +308,8 @@ class UsersController < ApplicationController # 默认活跃度排序 @s_type = 1 @users = scope. - joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). - reorder('user_scores.active DESC') + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') end # limit and offset diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index eea7a0f61..d8eb17acd 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -54,7 +54,7 @@