This commit is contained in:
z9hang 2014-07-29 10:07:02 +08:00
commit d8fcf8eb9b
14 changed files with 153 additions and 58 deletions

View File

@ -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
@ -173,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?
@ -235,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
@ -264,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

View File

@ -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?

View File

@ -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|

View File

@ -15,9 +15,11 @@
<!-- <p style="margin-left:-10px;"><%#= f.text_field :homepage, :size => 60, :style => "width:488px;margin-left: 10px;" %></p> --> <!-- by huang -->
<p style="margin-left:-10px;"><em style ="color: #888888;display: block;font-size: 90%;font-style: normal;"><%= f.check_box :is_public, :style => "margin-left:10px;" %></em></p>
<p style="margin-left:-10px;"><em style ="color: #888888;display: block;font-size: 90%;font-style: normal;"><%= f.check_box :hidden_repo, :style => "margin-left:10px;" %></em></p>
<!--
<p style="margin-left:-10px;"><em style ="color: #888888;display: block;font-size: 90%;font-style: normal;">
<%= f.check_box :dts_test, :style => "margin-left:10px;" %>
<%#= f.check_box :dts_test, :style => "margin-left:10px;" %>
</em></p>
-->
<p style="display:none;"><%= f.text_field :project_type, :value => 0 %></p>
<%= wikitoolbar_for 'project_description' %>

View File

@ -16,7 +16,7 @@
<li><%= link_to l(:project_module_gantt) ,project_gantt_path(@project) %></li>
</ul>
<ul><h3>其他工具</h3>
<% if @project.dts_test == 1 %>
<% if @project.enabled_modules.where(" name = 'dts'").count > 0 %>
<li><%= link_to l(:label_module_share) ,share_show_path(@project) %></li>
<% end %>
<li><%= link_to l(:project_module_documents), project_documents_path(@project) %></li>

View File

@ -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."

View File

@ -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}"
@ -251,7 +252,7 @@ zh:
field_lastname_eg: '(例:张三丰,请填写[张])'
field_mail: 邮件地址
field_filename: 文件
field_file_dense: 文件密级
field_file_dense: 是否公开
field_filesize: 大小
field_downloads: 下载次数
field_author: 作者
@ -505,6 +506,7 @@ zh:
project_module_calendar: 日历
project_module_gantt: 甘特图
project_module_course: 课程
project_module_dts: DTS测试工具
label_module_share: DTS测试工具
label_user: 用户

View File

@ -177,6 +177,7 @@ default_projects_modules:
- calendar
- gantt
- course
- dts
default_projects_tracker_ids:
serialized: true
default:

View File

@ -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
@ -846,18 +866,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"
@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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