Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
41ea3a1baf
12
ReadMe.txt
12
ReadMe.txt
|
@ -57,15 +57,9 @@ bundle exec rake db:migrate:up VERSION=20140410021724
|
||||||
2.运行 bundle install --without development test
|
2.运行 bundle install --without development test
|
||||||
3.运行 rake redmine:plugins:migrate RAILS_ENV=production
|
3.运行 rake redmine:plugins:migrate RAILS_ENV=production
|
||||||
4.启动服务器
|
4.启动服务器
|
||||||
5.把文本格式 (Administration > Settings > General > Text formatting)改为CKEditor
|
5.配置CKEditor插件(Administration > Plugins > Configure)
|
||||||
6.配置CKEditor插件(Administration > Plugins > Configure)
|
6.把文本格式 (Administration > Settings > General > Text formatting)改为CKEditor
|
||||||
|
注意:一定要先配置CKEditor插件再见文本格式更改,不然,数据库不会生成对应记录,会报错。。
|
||||||
某些情况数据库未插入插件配置值解决方案:
|
|
||||||
1 复制plugins
|
|
||||||
2 启动rails
|
|
||||||
3 运行migrate
|
|
||||||
3 打开admin配置插件(http://127.0.0.1:3000/settings/plugin/redmine_ckeditor)
|
|
||||||
4 点击“查询”(就是确定的功能)
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
0719:若遇到首页定制报错问题请尝试如下操作
|
0719:若遇到首页定制报错问题请尝试如下操作
|
||||||
如果运行迁移文件有报错与‘sort_type’相关 先运行 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202
|
如果运行迁移文件有报错与‘sort_type’相关 先运行 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202
|
||||||
|
|
|
@ -70,7 +70,7 @@ class BoardsController < ApplicationController
|
||||||
@message = Message.new(:board => @board)
|
@message = Message.new(:board => @board)
|
||||||
#modify by nwb
|
#modify by nwb
|
||||||
if @project
|
if @project
|
||||||
render :action => 'show', :layout => !request.xhr?
|
render :action => 'show', :layout => 'base_projects'
|
||||||
elsif @course
|
elsif @course
|
||||||
render :action => 'show', :layout => 'base_courses'
|
render :action => 'show', :layout => 'base_courses'
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,14 +29,21 @@ class DocumentsController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
||||||
documents = @project.documents.includes(:attachments, :category).all
|
temp = @project.documents.includes(:attachments, :category).all
|
||||||
|
documents = []
|
||||||
|
temp.each do |doc|
|
||||||
|
if doc.has_right?(@project)
|
||||||
|
documents << doc
|
||||||
|
end
|
||||||
|
end
|
||||||
case @sort_by
|
case @sort_by
|
||||||
when 'date'
|
when 'date'
|
||||||
@grouped = documents.group_by {|d| d.updated_on.to_date }
|
@grouped = documents.group_by {|d| d.updated_on.to_date }
|
||||||
when 'title'
|
when 'title'
|
||||||
@grouped = documents.group_by {|d| d.title.first.upcase}
|
@grouped = documents.group_by {|d| d.title.first.upcase}
|
||||||
when 'author'
|
when 'author'
|
||||||
@grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
|
# @grouped = documents.select{|d| d.attachments.any?}.group_by {|d| d.attachments.last.author}
|
||||||
|
@grouped = documents.group_by {|d| d.user.name }
|
||||||
else
|
else
|
||||||
@grouped = documents.group_by(&:category)
|
@grouped = documents.group_by(&:category)
|
||||||
end
|
end
|
||||||
|
@ -105,7 +112,7 @@ class DocumentsController < ApplicationController
|
||||||
# 权限判断
|
# 权限判断
|
||||||
# add by nwb
|
# add by nwb
|
||||||
def authorize_document
|
def authorize_document
|
||||||
if !(User.current.admin? || User.current.member_of?(@project) || @document.is_public==1)
|
if !(User.current.admin? || User.current.member_of?(@project) || @document == nil || (@document != nil && @document.is_public==1))
|
||||||
render_403 :message => :notice_not_authorized
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -148,7 +148,7 @@ class WelcomeController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
|
||||||
def entry_select
|
def entry_select
|
||||||
url = request.original_url
|
url = request.original_url
|
||||||
if url.include?("course.trustie.net")
|
if url.include?("course.trustie.net")
|
||||||
|
@ -166,28 +166,6 @@ class WelcomeController < ApplicationController
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
|
|
||||||
def entry_select_course
|
|
||||||
if request.original_url.match(/.*course\.trustie\.net/)
|
|
||||||
(course() and render :course and return 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def entry_select_contest
|
|
||||||
if request.original_url.match(/.*contest\.trustie\.net/)
|
|
||||||
contest
|
|
||||||
render :contest
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def entry_select_user
|
|
||||||
if request.original_url.match(/.*user\.trustie\.net$/)
|
|
||||||
redirect_to(:controller => "users", :action => "index")
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# def render(*args)
|
# def render(*args)
|
||||||
# _fake if @fake_filter
|
# _fake if @fake_filter
|
||||||
# super
|
# super
|
||||||
|
|
|
@ -37,12 +37,22 @@ class ZipdownController < ApplicationController
|
||||||
#下载某一学生的作业的所有文件
|
#下载某一学生的作业的所有文件
|
||||||
def download_user_homework
|
def download_user_homework
|
||||||
homework = HomeworkAttach.find params[:homework]
|
homework = HomeworkAttach.find params[:homework]
|
||||||
if homework != nil && (User.current.admin? || User.current.member_of_course?(homework.bid.courses.first))
|
if User.current.admin? || User.current.member_of_course?(homework.bid.courses.first)
|
||||||
|
if homework != nil
|
||||||
|
if homework.attachments.count > 0
|
||||||
zipfile = zip_homework_by_user homework
|
zipfile = zip_homework_by_user homework
|
||||||
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile
|
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if(zipfile)
|
||||||
|
else
|
||||||
|
render_403 :message => :no_file_dowmload
|
||||||
|
end
|
||||||
|
else
|
||||||
|
render_403 :message =>:notice_file_not_found
|
||||||
|
end
|
||||||
else
|
else
|
||||||
render_403 :message => :notice_not_authorized
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
|
rescue => e
|
||||||
|
render file: 'public/file_not_found.html'
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -67,8 +77,10 @@ class ZipdownController < ApplicationController
|
||||||
# 得到每一个人所有文件打包的zip文件
|
# 得到每一个人所有文件打包的zip文件
|
||||||
# 并将每一个人的zip打包为一个并返回路径
|
# 并将每一个人的zip打包为一个并返回路径
|
||||||
user_zip_paths = homeattaches.map do |homeattach|
|
user_zip_paths = homeattaches.map do |homeattach|
|
||||||
|
if homeattach.attachments.count > 0
|
||||||
zip_homework_by_user homeattach
|
zip_homework_by_user homeattach
|
||||||
end
|
end
|
||||||
|
end
|
||||||
zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER
|
zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER
|
||||||
|
|
||||||
#@paths = homeworks_attach_path
|
#@paths = homeworks_attach_path
|
||||||
|
@ -81,6 +93,7 @@ class ZipdownController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def zip_homework_by_user(homeattach)
|
def zip_homework_by_user(homeattach)
|
||||||
|
#if homeattach.attachments.count > 0
|
||||||
homeworks_attach_path = []
|
homeworks_attach_path = []
|
||||||
# 需要将所有homework.attachments遍历加入zip
|
# 需要将所有homework.attachments遍历加入zip
|
||||||
# 并且返回zip路径
|
# 并且返回zip路径
|
||||||
|
@ -88,8 +101,9 @@ class ZipdownController < ApplicationController
|
||||||
#length = attach.storage_path.length
|
#length = attach.storage_path.length
|
||||||
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1)
|
||||||
end
|
end
|
||||||
zipping "#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true
|
zipping("#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true)
|
||||||
#user_attaches_paths
|
#user_attaches_paths
|
||||||
|
#end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,10 @@ class Document < ActiveRecord::Base
|
||||||
!user.nil? && user.allowed_to?(:view_documents, project)
|
!user.nil? && user.allowed_to?(:view_documents, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_right?(project,user=User.current)
|
||||||
|
user.admin? || user.member_of?(project) || self.is_public==1
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(attributes=nil, *args)
|
def initialize(attributes=nil, *args)
|
||||||
super
|
super
|
||||||
if new_record?
|
if new_record?
|
||||||
|
|
|
@ -56,13 +56,12 @@ class Project < ActiveRecord::Base
|
||||||
#added by xianbo for delete biding_project
|
#added by xianbo for delete biding_project
|
||||||
has_many :biding_projects, :dependent => :destroy
|
has_many :biding_projects, :dependent => :destroy
|
||||||
has_many :contesting_projects, :dependent => :destroy
|
has_many :contesting_projects, :dependent => :destroy
|
||||||
has_many :projecting_softapplications, :dependent => :destroy
|
|
||||||
has_many :softapplications, :through => :projecting_softapplications
|
has_many :softapplications, :through => :projecting_softapplications
|
||||||
#ended by xianbo
|
#ended by xianbo
|
||||||
# added by fq
|
# added by fq
|
||||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||||
has_many :homework_for_courses, :dependent => :destroy
|
#has_many :homework_for_courses, :dependent => :destroy
|
||||||
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
#has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||||
has_many :shares, :dependent => :destroy
|
has_many :shares, :dependent => :destroy
|
||||||
# has_many :students_for_courses, :dependent => :destroy
|
# has_many :students_for_courses, :dependent => :destroy
|
||||||
has_many :student, :through => :students_for_courses, :source => :user
|
has_many :student, :through => :students_for_courses, :source => :user
|
||||||
|
@ -1138,13 +1137,13 @@ class Project < ActiveRecord::Base
|
||||||
# 创建项目后在项目下同步创建一个讨论区
|
# 创建项目后在项目下同步创建一个讨论区
|
||||||
def create_board_sync
|
def create_board_sync
|
||||||
@board = self.boards.build
|
@board = self.boards.build
|
||||||
self.name=" #{l(:label_borad_course) }"
|
self.name=" #{l(:label_borad_project) }"
|
||||||
@board.name = self.name
|
@board.name = self.name
|
||||||
@board.description = self.name.to_s
|
@board.description = self.name.to_s
|
||||||
if @board.save
|
if @board.save
|
||||||
logger.debug "[Course Model] ===> #{@board.to_json}"
|
logger.debug "[Project Model] ===> #{@board.to_json}"
|
||||||
else
|
else
|
||||||
logger.error "[Course Model] ===> Auto create board when Course saved, because #{@board.full_messages}"
|
logger.error "[Project Model] ===> Auto create board when Project saved, because #{@board.full_messages}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -35,3 +35,5 @@
|
||||||
<% content_for :header_tags do %>
|
<% content_for :header_tags do %>
|
||||||
<%= javascript_include_tag 'attachments' %>
|
<%= javascript_include_tag 'attachments' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,7 @@
|
||||||
<table width="100%" valign="center">
|
<table width="100%" valign="center">
|
||||||
<tr>
|
<tr>
|
||||||
<td ><span style="margin-left:0px"><%= l(:label_task_plural)%>(<%= @homework_list.count%>)</span>
|
<td ><span style="margin-left:0px"><%= l(:label_task_plural)%>(<%= @homework_list.count%>)</span>
|
||||||
<%#= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(
|
<%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(is_teacher && @bid.homeworks.count > 0) %>
|
||||||
User.current.admin? ||
|
|
||||||
!(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) ||
|
|
||||||
(Rails.env.development?) %>
|
|
||||||
</td>
|
</td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<div class="project-search">
|
<div class="project-search">
|
||||||
|
|
|
@ -1867,6 +1867,7 @@ zh:
|
||||||
lable_close_mutual_evaluation: 关闭互评
|
lable_close_mutual_evaluation: 关闭互评
|
||||||
label_has_been: 已经被
|
label_has_been: 已经被
|
||||||
label_course_userd_by: 个课程引用
|
label_course_userd_by: 个课程引用
|
||||||
|
no_file_dowmload: 该作业没有任何的附件可以下载
|
||||||
|
|
||||||
role_of_course: 课程角色
|
role_of_course: 课程角色
|
||||||
label_student: 学生
|
label_student: 学生
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
class UpdateCourseAttachment < ActiveRecord::Migration
|
||||||
|
# 更新课程资源类型
|
||||||
|
def up
|
||||||
|
Attachment.all.each do |attachment|
|
||||||
|
if attachment.container_type == 'Course'
|
||||||
|
if attachment.attachtype == 1
|
||||||
|
attachment.attachtype = 4
|
||||||
|
elsif attachment.attachtype == 2
|
||||||
|
attachment.attachtype = 5
|
||||||
|
elsif attachment.attachtype == 3
|
||||||
|
attachment.attachtype = 6
|
||||||
|
end
|
||||||
|
attachment.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140721074353) do
|
ActiveRecord::Schema.define(:version => 20140722024513) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
|
|
@ -156,12 +156,12 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addInputFiles(inputEl) {
|
function addInputFiles(inputEl) {
|
||||||
var clearedFileInput = $(inputEl).clone().val('');
|
// var clearedFileInput = $(inputEl).clone().val('');
|
||||||
|
|
||||||
if (inputEl.files) {
|
if (inputEl.files) {
|
||||||
// upload files using ajax
|
// upload files using ajax
|
||||||
uploadAndAttachFiles(inputEl.files, inputEl);
|
uploadAndAttachFiles(inputEl.files, inputEl);
|
||||||
$(inputEl).remove();
|
// $(inputEl).remove();
|
||||||
} else {
|
} else {
|
||||||
// browser not supporting the file API, upload on form submission
|
// browser not supporting the file API, upload on form submission
|
||||||
var attachmentId;
|
var attachmentId;
|
||||||
|
@ -172,7 +172,7 @@ function addInputFiles(inputEl) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearedFileInput.insertAfter('#attachments_fields');
|
//clearedFileInput.insertAfter('#attachments_fields');
|
||||||
}
|
}
|
||||||
|
|
||||||
function uploadAndAttachFiles(files, inputEl) {
|
function uploadAndAttachFiles(files, inputEl) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ class CoursesControllerTest < ActionController::TestCase
|
||||||
Setting.default_language = 'en'
|
Setting.default_language = 'en'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get :index
|
||||||
def test_index_by_anonymous_should_not_show_private_projects
|
def test_index_by_anonymous_should_not_show_private_projects
|
||||||
get :index
|
get :index
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -19,6 +20,7 @@ class CoursesControllerTest < ActionController::TestCase
|
||||||
assert courses.all?(&:is_public?)
|
assert courses.all?(&:is_public?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get :new
|
||||||
# 人员添加课程的权限是不属于任何角色
|
# 人员添加课程的权限是不属于任何角色
|
||||||
def test_new_course_anyone_temporary
|
def test_new_course_anyone_temporary
|
||||||
@request.session[:user_id] = 5
|
@request.session[:user_id] = 5
|
||||||
|
@ -29,6 +31,7 @@ class CoursesControllerTest < ActionController::TestCase
|
||||||
assert_template :new
|
assert_template :new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# post :create
|
||||||
def test_create_course_with_access_control
|
def test_create_course_with_access_control
|
||||||
@request.session[:user_id] = 5
|
@request.session[:user_id] = 5
|
||||||
Role.find_by_name("Non member").add_permission! :add_course #Non member
|
Role.find_by_name("Non member").add_permission! :add_course #Non member
|
||||||
|
@ -54,6 +57,7 @@ class CoursesControllerTest < ActionController::TestCase
|
||||||
# assert_redirected_to "courses/#{course.id}/settings"
|
# assert_redirected_to "courses/#{course.id}/settings"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# post :create 403
|
||||||
def test_create_course_without_access_control
|
def test_create_course_without_access_control
|
||||||
@request.session[:user_id] = 5
|
@request.session[:user_id] = 5
|
||||||
#Role.find_by_name("Non member").add_permission! :add_course #Non member
|
#Role.find_by_name("Non member").add_permission! :add_course #Non member
|
||||||
|
|
Loading…
Reference in New Issue