From 88c3347f7c217dda346e8895074247ac0a803b1f Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 26 Jun 2014 09:15:56 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E5=88=86=E6=94=AF=E5=90=8E=E7=9A=84=E5=88=9B=E5=BB=BA=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 8 +-- db/schema.rb | 124 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 108 insertions(+), 24 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index 7a9e411d5..ceced2301 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -199,9 +199,11 @@ class Course < ActiveRecord::Base # 删除课程所有成员 def delete_all_members - me, mr = Member.table_name, MemberRole.table_name - connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})") - Member.delete_all(['course_id = ?', id]) + if self.members && self.members.count > 0 + me, mr = Member.table_name, MemberRole.table_name + connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})") + Member.delete_all(['course_id = ?', id]) + end end def get_endup_time diff --git a/db/schema.rb b/db/schema.rb index 63020ad61..67da188af 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 => 20140618020535) do +ActiveRecord::Schema.define(:version => 20140618155324) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -117,6 +117,7 @@ ActiveRecord::Schema.define(:version => 20140618020535) do t.integer "messages_count", :default => 0, :null => false t.integer "last_message_id" t.integer "parent_id" + t.integer "course_id" end add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" @@ -174,6 +175,58 @@ ActiveRecord::Schema.define(:version => 20140618020535) 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 @@ -229,6 +282,23 @@ ActiveRecord::Schema.define(:version => 20140618020535) do t.datetime "updated_on", :null => false end + create_table "course_infos", :force => true do |t| + t.integer "course_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "course_id" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "courses", :force => true do |t| t.integer "tea_id" t.string "name" @@ -236,8 +306,8 @@ ActiveRecord::Schema.define(:version => 20140618020535) do t.string "code" t.integer "time" t.string "extra" - 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.string "location" t.string "term" t.string "string" @@ -246,6 +316,13 @@ ActiveRecord::Schema.define(:version => 20140618020535) do t.string "endup_time" t.string "class_period" t.integer "school_id" + t.text "description" + t.integer "status", :default => 1 + t.integer "attachmenttype", :default => 2 + t.integer "lft" + t.integer "rgt" + t.integer "is_public", :limit => 1, :default => 1 + t.integer "inherit_members", :limit => 1, :default => 1 end create_table "custom_fields", :force => true do |t| @@ -309,6 +386,7 @@ ActiveRecord::Schema.define(:version => 20140618020535) do create_table "enabled_modules", :force => true do |t| t.integer "project_id" t.string "name", :null => false + t.integer "course_id" end add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" @@ -358,7 +436,7 @@ ActiveRecord::Schema.define(:version => 20140618020535) do end create_table "homework_for_courses", :force => true do |t| - t.integer "project_id" + t.integer "course_id" t.integer "bid_id" end @@ -513,13 +591,14 @@ ActiveRecord::Schema.define(:version => 20140618020535) do create_table "members", :force => true do |t| t.integer "user_id", :default => 0, :null => false - t.integer "project_id", :default => 0, :null => false + t.integer "project_id", :default => 0 t.datetime "created_on" t.boolean "mail_notification", :default => false, :null => false + t.integer "course_id", :default => -1 end add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id"], :name => "index_members_on_user_id_and_project_id", :unique => true + add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true add_index "members", ["user_id"], :name => "index_members_on_user_id" create_table "memos", :force => true do |t| @@ -565,6 +644,7 @@ ActiveRecord::Schema.define(:version => 20140618020535) do t.integer "author_id", :default => 0, :null => false t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false + t.integer "course_id" end add_index "news", ["author_id"], :name => "index_news_on_author_id" @@ -715,18 +795,18 @@ ActiveRecord::Schema.define(:version => 20140618020535) 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", :null => false + t.string "subject", :null => false + t.text "content", :limit => 16777215, :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" @@ -961,11 +1041,13 @@ ActiveRecord::Schema.define(:version => 20140618020535) do end create_table "user_scores", :force => true do |t| - t.integer "user_id" - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "activity" + t.integer "user_id", :null => false + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "active" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "user_statuses", :force => true do |t| From f4aa817f423a73d742636f716717f9ac58e23b84 Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 26 Jun 2014 10:01:44 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E5=90=8E=E9=A6=96=E9=A1=B5=E5=87=BA=E9=94=99=E7=9A=84=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/models/course.rb | 2 +- app/views/layouts/base_courses.html.erb | 1 - config/locales/en.yml | 1 + config/locales/zh.yml | 1 + .../20140618105213_migrate_course_students.rb | 2 +- lib/redmine/activity/fetcher.rb | 18 ++++++++++-------- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index ceced2301..b828af0ce 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -34,7 +34,7 @@ class Course < ActiveRecord::Base :delete_permission => :manage_files validates_presence_of :password, :term - validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/ + validates_format_of :class_period, :message => l(:error_class_period_only_num), :with =>/^[1-9]\d*$/ after_save :create_board_sync before_destroy :delete_all_members diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 2601d7c7e..ac5cc104d 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -66,7 +66,6 @@ <%= link_to @course.name,course_path(@course) %> - <%= @course.name %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 4e2ba0781..4c177b58e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -186,6 +186,7 @@ en: notice_account_deleted: "Your account has been permanently deleted." notice_user_successful_create: "User %{id} created." + error_class_period_only_num: "class period can only digital" error_can_t_load_default_data: "Default configuration could not be loaded: %{value}" error_scm_not_found: "The entry or revision was not found in the repository." error_scm_command_failed: "An error occurred when trying to access the repository: %{value}" diff --git a/config/locales/zh.yml b/config/locales/zh.yml index cd3e83b38..71972a6fd 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -196,6 +196,7 @@ zh: error_complete_occupation: "请您填写工作单位,否则本系统的部分功能将无法正常使用。" + error_class_period_only_num: "课程学时只能为数字" error_can_t_load_default_data: "无法载入默认设置:%{value}" error_scm_not_found: "版本库中不存在该条目和(或)其修订版本。" error_scm_command_failed: "访问版本库时发生错误:%{value}" diff --git a/db/migrate/20140618105213_migrate_course_students.rb b/db/migrate/20140618105213_migrate_course_students.rb index b9ac66714..ef037682a 100644 --- a/db/migrate/20140618105213_migrate_course_students.rb +++ b/db/migrate/20140618105213_migrate_course_students.rb @@ -3,7 +3,7 @@ class MigrateCourseStudents < ActiveRecord::Migration # 原课程的学生数据迁移成新模式 StudentsForCourse.all.each do |student| project = Project.find_by_id(student.course_id) - if project + if project && project.course_extra student.course_id = project.course_extra.id student.save end diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb index 6a1b88b59..b95ae2bc3 100644 --- a/lib/redmine/activity/fetcher.rb +++ b/lib/redmine/activity/fetcher.rb @@ -102,16 +102,18 @@ module Redmine @options[:limit] = options[:limit] @scope.each do |event_type| constantized_providers(event_type).each do |provider| - if event_type.to_s != 'course_journals_for_messages' - cur_objs = provider.find_events1(event_type, @user, from, to, @options) - end - cur_objs.each do |cur_obj| - if cur_obj.class == Issue - if cur_obj.project != nil && cur_obj.project.project_status != nil + if event_type.to_s != 'course_journals_for_messages' + cur_objs = provider.find_events1(event_type, @user, from, to, @options) + end + if cur_objs + cur_objs.each do |cur_obj| + if cur_obj.class == Issue + if cur_obj.project != nil && cur_obj.project.project_status != nil + e += [cur_obj] + end + else e += [cur_obj] end - else - e += [cur_obj] end end end From 7702b746c623d663bae331eeb77b04d7b12ee0d0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 26 Jun 2014 10:55:50 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2=EF=BC=8C=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=8C=89=E9=92=AE=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_homework.html.erb | 2 +- db/schema.rb | 74 ++++-------------------- 2 files changed, 12 insertions(+), 64 deletions(-) diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index ac10931dc..396457c35 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -211,7 +211,7 @@
  • <%= link_to l(:label_question_student), {:controller => 'bids', :action => 'show'}, :class => link_class(:respond) %>
  • - <% if User.current.member_of? @bid.courses.first %> + <% if User.current.member_of_course? @bid.courses.first %>
  • <% if User.current.logged? && @bid.courses.first && (!Member.where('user_id = ? and course_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?', 5, 10, 7)).size >0) %> <%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_course'}, :class => link_class(:course) %> diff --git a/db/schema.rb b/db/schema.rb index 67da188af..0032afedb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -175,58 +175,6 @@ ActiveRecord::Schema.define(:version => 20140618155324) 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 @@ -793,20 +741,20 @@ ActiveRecord::Schema.define(:version => 20140618155324) do end create_table "relative_memos", :force => true do |t| - t.integer "osp_id" + t.integer "osp_id", :null => false 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" From b4af75f2893423fae14dec1650af57d3ef6e312d Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 26 Jun 2014 11:15:06 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E9=83=A8=E5=88=86=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 2 +- app/views/news/_course_news.html.erb | 2 +- config/locales/zh.yml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index b828af0ce..2dfb6ae44 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -34,7 +34,7 @@ class Course < ActiveRecord::Base :delete_permission => :manage_files validates_presence_of :password, :term - validates_format_of :class_period, :message => l(:error_class_period_only_num), :with =>/^[1-9]\d*$/ + validates_format_of :class_period, :with =>/^[1-9]\d*$/ after_save :create_board_sync before_destroy :delete_all_members diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index 60d0f0ed3..5104cd851 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -76,7 +76,7 @@ <%= stylesheet_link_tag 'scm' %> <% end %> - <% html_title(l(:label_news_plural)) -%> + <% html_title(l(:label_course_news)) -%>