From 2c79a51e48d2123762e92c95f3ffaabacb99b828 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 28 Jul 2014 14:43:38 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E7=BC=96=E7=A0=81=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 36dd61105..0f29d6000 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -26,6 +26,7 @@ class AttachmentsController < ApplicationController accept_api_auth :show, :download, :upload require 'iconv' + def show respond_to do |format| format.html { @@ -41,6 +42,13 @@ class AttachmentsController < ApplicationController render :action => 'diff' elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte @content = File.new(@attachment.diskfile, "rb").read + # 编码为非 UTF-8先进行间接转码 + # 部分unicode编码不直接支持转为 UTF-8 + # modify by nwb + if @content.encoding.name != 'UTF-8' + @content = @content.force_encoding('GBK') + @content = @content.encode('UTF-8') + end render :action => 'file' else download From bf9a9923998045f20a2345493a2a6ae90d141c73 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 28 Jul 2014 12:17:58 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B4=BB=E8=B7=83=E5=BA=A6=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 41 +++++++++++++---------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a3bb96aa9..1d5dd65eb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -263,9 +263,6 @@ class UsersController < ApplicationController sort_init 'login', 'asc' sort_update %w(login firstname lastname mail admin created_on last_login_on) - # Deprecation - @project_type = params[:project_type] - case params[:format] when 'xml', 'json' @offset, @limit = api_offset_and_limit({:limit => 15}) @@ -274,16 +271,9 @@ class UsersController < ApplicationController end # retrieve all users - scope = UserStatus.visible - - # if role has something, change scope. - case params[:role] - when 'teacher' - scope = UserStatus.teacher - when 'student' - scope = UserStatus.student - else - end + # 先内连一下statuses 保证排序之后数量一致 + scope = User.visible. + joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id") # unknow scope = scope.in_group(params[:group_id]) if params[:group_id].present? @@ -295,25 +285,32 @@ class UsersController < ApplicationController # users classify case params[:user_sort_type] when '0' + # 创建时间排序 @s_type = 0 - @us_ordered = scope. - joins("LEFT JOIN users ON user_statuses.user_id = users.id"). - reorder('users.created_on DESC') + @users = scope.reorder('users.created_on DESC') when '1' + # 活跃度排序, 就是所谓的得分情况 @s_type = 1 - @us_ordered = scope.reorder('user_statuses.grade DESC') + @users = scope. + joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). + reorder('user_scores.active DESC') when '2' + # 粉丝数排序 @s_type = 2 - @us_ordered = scope.reorder('user_statuses.watchers_count DESC') + @users = scope. + #joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id"). + reorder('user_statuses.watchers_count DESC') + else + # 默认活跃度排序 @s_type = 1 - @us_ordered = scope.reorder('user_statuses.grade DESC') + @users = scope. + joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). + reorder('user_scores.active DESC') end # limit and offset - @users_statuses = @us_ordered.offset(@user_pages.offset).limit(@user_pages.per_page) - # get users ActiveRecord - @users = @users_statuses.includes(:user).map(&:user) + @users = @users.limit(@user_pages.per_page).offset(@user_pages.offset) @user_base_tag = params[:id] ? 'base_users':'users_base' respond_to do |format| From f18e82863249571c92bf045b70f545f21c0f53ba Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 28 Jul 2014 15:37:10 +0800 Subject: [PATCH 3/6] usercontroller#test --- test/fixtures/activities.yml | 13 +++++---- test/fixtures/journals_for_messages.yml | 33 +++++++++++++++++++-- test/functional/users_controller_test.rb | 37 ++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 test/functional/users_controller_test.rb diff --git a/test/fixtures/activities.yml b/test/fixtures/activities.yml index 585b0e66f..760473856 100644 --- a/test/fixtures/activities.yml +++ b/test/fixtures/activities.yml @@ -1,11 +1,12 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html one: - act_id: - act_type: MyString - user_id: + id: 1 + act_id: 1 + act_type: JournalsForMessage + user_id: 5 two: - act_id: - act_type: MyString - user_id: + act_id: 2 + act_type: JournalsForMessage + user_id: 5 diff --git a/test/fixtures/journals_for_messages.yml b/test/fixtures/journals_for_messages.yml index d0fc66d84..a5d28caec 100644 --- a/test/fixtures/journals_for_messages.yml +++ b/test/fixtures/journals_for_messages.yml @@ -1,4 +1,34 @@ jfm_001: + id: 1 + jour_id: 5 + jour_type: Principal + user_id: 2 + notes: + status: 0 + reply_id: 0 + created_on: 2014-07-16 15:27:2 + updated_on: 2014-07-16 15:27:2 + m_parent_id: + is_readed: + m_reply_count: + m_reply_id: + is_comprehensive_evaluation: +jfm_002: + id: 2 + jour_id: 5 + jour_type: Principal + user_id: 2 + notes: 我觉得这个系统挺实用,界面挺简洁美观1! + status: + reply_id: 0 + created_on: 2014-07-16 15:27:2 + updated_on: 2014-07-16 15:27:2 + m_parent_id: + is_readed: + m_reply_count: + m_reply_id: + is_comprehensive_evaluation: +jfm_045: id: 45 jour_id: 2 jour_type: Project @@ -64,7 +94,7 @@ jfm_060: jour_id: 2 jour_type: Project user_id: 2 - notes: something very nice + notes: status: reply_id: 0 created_on: 2013-08-21 07:04:43 @@ -119,4 +149,3 @@ jfm_088: m_reply_count: m_reply_id: is_comprehensive_evaluation: - diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb new file mode 100644 index 000000000..4d7f8d6a9 --- /dev/null +++ b/test/functional/users_controller_test.rb @@ -0,0 +1,37 @@ +require File.expand_path('../../test_helper', __FILE__) + +class UsersControllerTest < ActionController::TestCase + fixtures :users, :projects, :members, :member_roles, :roles, + :custom_fields, :custom_values, :groups_users, + :auth_sources, + :activities, + :journals_for_messages + def setup + User.current = nil + @request.session[:user_id] = 1 + @request.session[:ctime] = Time.now + @request.session[:atime] = Time.now + end + + test '#index by non-member' do + @request.session[:user_id] = nil + get :index + assert_response :success + assert_template 'index' + end + + test '#show by non-member' do + @request.session[:user_id] = 8 + get :show, {id: 5} + assert_response :success + assert_template 'show' + end + + test '#user_newfeedback by non-member' do + @request.session[:user_id] = nil + get :user_newfeedback, {id: 5} + assert_response :success + assert_template 'user_newfeedback' + end + +end From cb4efd914e01dbe0f12ae9e0cc2559cc3806dcda Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 28 Jul 2014 17:14:02 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=88=A0=E9=99=A4BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 8 +++++- config/locales/en.yml | 1 + config/locales/zh.yml | 1 + db/schema.rb | 33 ++++++++++++++--------- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 0f29d6000..f00cbb03d 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -181,7 +181,7 @@ class AttachmentsController < ApplicationController respond_to do |format| # modify by nwb - if !@attachment.container.nil? && (@attachment.container.is_a?(Course) || @attachment.container.course) + if !@attachment.container.nil? && (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) &&(@attachment.container.is_a?(Course) || @attachment.container.course) if @attachment.container.is_a?(News) format.html { redirect_to_referer_or news_path(@attachment.container) } elsif @course.nil? @@ -243,6 +243,9 @@ class AttachmentsController < ApplicationController attach_copied_obj.container = obj attach_copied_obj.created_on = Time.now attach_copied_obj.author_id = User.current.id + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 1 + end @obj = obj @save_flag = attach_copied_obj.save @save_message = attach_copied_obj.errors.full_messages @@ -272,6 +275,9 @@ class AttachmentsController < ApplicationController attach_copied_obj.container = obj attach_copied_obj.created_on = Time.now attach_copied_obj.author_id = User.current.id + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 4 + end @obj = obj @save_flag = attach_copied_obj.save @save_message = attach_copied_obj.errors.full_messages diff --git a/config/locales/en.yml b/config/locales/en.yml index 1e975decc..e1b93f649 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_attachment_empty: "error in add file" 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." diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 3f9e3200a..f51548875 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -195,6 +195,7 @@ zh: notice_gantt_chart_truncated: "这个表是截断的因为它超过了可以显示的最大数量(%{max})" error_complete_occupation: "请您填写工作单位,否则本系统的部分功能将无法正常使用。" + error_attachment_empty: "添加文件出错!" error_class_period_only_num: "课程学时只能为数字" error_can_t_load_default_data: "无法载入默认设置:%{value}" diff --git a/db/schema.rb b/db/schema.rb index 05886b190..85fd8a8f8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -439,6 +439,26 @@ ActiveRecord::Schema.define(:version => 20140728014933) do t.datetime "updated_at", :null => false end + create_table "gitlab_projects", :force => true do |t| + t.integer "gitlab_project_id" + t.integer "project_id" + t.string "repository_url" + t.string "web_url" + t.string "localfile_url" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "gitlab_users", :force => true do |t| + t.integer "gitlab_user_id" + t.integer "user_id" + t.string "email" + t.string "password" + t.string "login", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "groups_users", :id => false, :force => true do |t| t.integer "group_id", :null => false t.integer "user_id", :null => false @@ -881,19 +901,6 @@ ActiveRecord::Schema.define(:version => 20140728014933) 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 2141fcc3cac5bccee8dccb7c2102f1026af06805 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 28 Jul 2014 17:49:28 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=B0=86=E6=98=AF=E5=90=A6=E5=90=AF?= =?UTF-8?q?=E7=94=A8DTS=E6=B5=8B=E8=AF=95=E7=A7=BB=E5=85=A5=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=A8=A1=E5=9D=97=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 2 +- app/views/projects/_form.html.erb | 4 +++- app/views/projects/_tools_expand.html.erb | 2 +- config/locales/zh.yml | 1 + config/settings.yml | 1 + db/schema.rb | 20 ++++++++++---------- lib/redmine.rb | 3 +++ lib/redmine/access_control.rb | 1 + 8 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index eedb29329..15a26fbae 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -747,7 +747,7 @@ class ProjectsController < ApplicationController def update @project.safe_attributes = params[:project] - @project.dts_test = params[:project][:dts_test] + #@project.dts_test = params[:project][:dts_test] if validate_parent_id && @project.save @course = Course.find_by_extra(@project.identifier) unless @course.nil? diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index f5781b26a..47a87f441 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -15,9 +15,11 @@

<%= f.check_box :is_public, :style => "margin-left:10px;" %>

<%= f.check_box :hidden_repo, :style => "margin-left:10px;" %>

+

<%= f.text_field :project_type, :value => 0 %>

<%= wikitoolbar_for 'project_description' %> diff --git a/app/views/projects/_tools_expand.html.erb b/app/views/projects/_tools_expand.html.erb index 5ee70fa9d..df6cd481b 100644 --- a/app/views/projects/_tools_expand.html.erb +++ b/app/views/projects/_tools_expand.html.erb @@ -16,7 +16,7 @@
  • <%= link_to l(:project_module_gantt) ,project_gantt_path(@project) %>
    • 其他工具

      - <% if @project.dts_test == 1 %> + <% if @project.enabled_modules.where(" name = 'dts'").count > 0 %>
    • <%= link_to l(:label_module_share) ,share_show_path(@project) %>
    • <% end %>
    • <%= link_to l(:project_module_documents), project_documents_path(@project) %>
    • diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 1efa72680..6ff930e28 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -505,6 +505,7 @@ zh: project_module_calendar: 日历 project_module_gantt: 甘特图 project_module_course: 课程 + project_module_dts: DTS测试工具 label_module_share: DTS测试工具 label_user: 用户 diff --git a/config/settings.yml b/config/settings.yml index cffbaa5fa..20801e03e 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -177,6 +177,7 @@ default_projects_modules: - calendar - gantt - course + - dts default_projects_tracker_ids: serialized: true default: diff --git a/db/schema.rb b/db/schema.rb index 05886b190..3cbfefa76 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -846,18 +846,18 @@ ActiveRecord::Schema.define(:version => 20140728014933) 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" diff --git a/lib/redmine.rb b/lib/redmine.rb index 6215a04ba..4fa909325 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -244,6 +244,9 @@ Redmine::AccessControl.map do |map| map.permission :view_gantt, {:gantts => [:show, :update]}, :read => true end + map.project_module :dts do |map| + map.permission :do_dts, {:dts => :show}, :read => true + end # map.project_module :journals do |map| # map.permission :view_journals_for_messages, {:gantts => [:show, :update]}, :read => true # end diff --git a/lib/redmine/access_control.rb b/lib/redmine/access_control.rb index e0a8e16c0..e71c0090a 100644 --- a/lib/redmine/access_control.rb +++ b/lib/redmine/access_control.rb @@ -67,6 +67,7 @@ module Redmine def available_project_modules @available_project_modules ||= @permissions.collect(&:project_module).uniq.compact end + def available_contest_modules @available_contest_modules ||= @permissions.collect(&:contest_module).uniq.compact end From 115638716154ee1d3e763a2ebaf0457174d54f89 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 29 Jul 2014 08:36:30 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E2=80=9C=E6=96=87=E4=BB=B6=E5=AF=86?= =?UTF-8?q?=E7=BA=A7=E2=80=9D=E6=94=B9=E4=B8=BA=E2=80=9C=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=85=AC=E5=BC=80=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/zh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 04d048b3e..51f8ac44c 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -252,7 +252,7 @@ zh: field_lastname_eg: '(例:张三丰,请填写[张])' field_mail: 邮件地址 field_filename: 文件 - field_file_dense: 文件密级 + field_file_dense: 是否公开 field_filesize: 大小 field_downloads: 下载次数 field_author: 作者