This commit is contained in:
z9hang 2015-01-12 17:34:51 +08:00
commit 525cf10376
12 changed files with 79 additions and 51 deletions

24
Gemfile
View File

@ -1,4 +1,4 @@
source 'http://ruby.taobao.org'
source 'http://rubygems.org'
#source 'http://ruby.sdutlinux.org/'
unless RUBY_PLATFORM =~ /w32/
@ -33,21 +33,21 @@ group :test do
gem 'selenium-webdriver', '~> 2.42.0'
platforms :mri, :mingw do
group :rmagick do
# RMagick 2 supports ruby 1.9
# RMagick 1 would be fine for ruby 1.8 but Bundler does not support
# different requirements for the same gem on different platforms
gem "rmagick", ">= 2.0.0"
end
end
# platforms :mri, :mingw do
# group :rmagick do
# # RMagick 2 supports ruby 1.9
# # RMagick 1 would be fine for ruby 1.8 but Bundler does not support
# # different requirements for the same gem on different platforms
# gem "rmagick", ">= 2.0.0"
# end
#end
end
group :development, :test do
gem "guard-rails", '~> 0.5.3'
# gem "guard-rails", '~> 0.5.3'
gem 'spork-testunit', '~> 0.0.8'
gem 'guard-spork', '~> 1.5.1'
gem 'guard-test', '~> 1.0.0'
# gem 'guard-spork', '~> 1.5.1'
# gem 'guard-test', '~> 1.0.0'
gem 'ruby-prof', '~> 0.15.1' unless RUBY_PLATFORM =~ /w32/
gem 'pry'
gem 'pry-nav'

View File

@ -810,9 +810,9 @@ class CoursesController < ApplicationController
# modify by nwb
# 添加私密性判断
if User.current.member_of_course?(@course)|| User.current.admin?
events = @activity.events(@date_from, @date_to)
events = @activity.events(@days, @course.created_at)
else
events = @activity.events(@date_from, @date_to, :is_public => 1)
events = @activity.events(@days, @course.created_at, :is_public => 1)
end
# 无新动态时,显示老动态

View File

@ -597,8 +597,8 @@ class ProjectsController < ApplicationController
"show_wiki_edits"=>true,
"show_journals_for_messages" => true
}
@date_to ||= Date.today + 1
@date_from = @date_to - @days-1.years
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
# 决定显示所用用户或单个用户活动
@ -612,9 +612,9 @@ class ProjectsController < ApplicationController
# modify by nwb
# 添加私密性判断
if User.current.member_of?(@project)|| User.current.admin?
events = @activity.events(@date_from, @date_to)
events = @activity.events(@days)
else
events = @activity.events(@date_from, @date_to, :is_public => 1)
events = @activity.events(@days,nil, :is_public => 1)
end
@offset, @limit = api_offset_and_limit({:limit => 10})

View File

@ -7,17 +7,6 @@ class ZipdownController < ApplicationController
SAVE_FOLDER = "#{Rails.root}/files"
OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip"
#通过作业Id找到项目课程
def find_project_by_bid_id
obj_class = params[:obj_class]
obj_id = params[:obj_id]
obj = obj_class.constantize.find(obj_id)
case obj.class.to_s.to_sym
when :Bid
@project = obj.courses[0]
end
end
def assort
if params[:obj_class] == "Bid"
bid = Bid.find params[:obj_id]
@ -33,8 +22,8 @@ class ZipdownController < ApplicationController
end
send_file zipfile, :filename => bid.name + ".zip", :type => detect_content_type(zipfile) if zipfile
rescue Exception => e
render file: 'public/no_file_found.html'
#rescue Exception => e
# render file: 'public/no_file_found.html'
end
#下载某一学生的作业的所有文件
@ -56,12 +45,23 @@ class ZipdownController < ApplicationController
else
render_403
end
rescue => e
render file: 'public/file_not_found.html'
#rescue => e
# render file: 'public/file_not_found.html'
end
private
#通过作业Id找到项目课程
def find_project_by_bid_id
obj_class = params[:obj_class]
obj_id = params[:obj_id]
obj = obj_class.constantize.find(obj_id)
case obj.class.to_s.to_sym
when :Bid
@project = obj.courses[0]
end
end
def zip_bid(bid)
# Todo: User Access Controll
bid_homework_path = []
@ -101,10 +101,20 @@ class ZipdownController < ApplicationController
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
input_filename.each do |filename|
flag = true
index = 1
rename_file = ic.iconv( (File.basename(filename)) ).to_s
rename_file = ic.iconv( filename_to_real( File.basename(filename))).to_s if is_attachment
zipfile.add(rename_file, filename)
begin
zipfile.add(rename_file, filename)
flag = false
rescue Exception => e
zipfile.get_output_stream('FILE_NOTICE.txt') do |os|
os.write l(:label_file_exist)
end
next
end
end
unless not_exist_file.empty?
zipfile.get_output_stream('FILE_LOST.txt') do |os|
@ -113,9 +123,9 @@ class ZipdownController < ApplicationController
end
end
zipfile_name
rescue Errno => e
logger.error "[zipdown#zipping] ===> #{e}"
@error = e
#rescue Errno => e
# logger.error "[zipdown#zipping] ===> #{e}"
# @error = e
end
def detect_content_type(name)
content_type = Redmine::MimeType.of(name)

View File

@ -49,7 +49,7 @@ form #search_type{
<%= form_tag({controller: :welcome, action: :search }, method: :get) do %>
<div class="project-search" style="float: right">
<div class='search_widget'>
<%= text_field_tag :q, nil, placeholder:'请输入要搜索的关键字', :size => 27, %>
<%= text_field_tag :q, nil, placeholder:'请输入要搜索的关键字', :size => 27, style: "float:left" %>
<%= select_tag(:search_type, options_for_select(select_option), :style => "float:right" ) %>
</div>
<%#= hidden_field_tag 'project_type', project_type %>

View File

@ -89,7 +89,7 @@ form #search_by
<div class="project-search" style="float: right">
<div class='search_widget' >
<%= text_field_tag :q, nil, placeholder:'请输入要搜索的关键字' %>
<%= text_field_tag :q, nil, placeholder:'请输入要搜索的关键字', style:"float:left" %>
<input type="text" name="search_by_input" style="display: none" id="search_by_input" value="0">
<%= select_tag(:search_type, options_for_select(select_option), :onchange => "searchTypeChange();", :style => "float:right" ) %>
<%= select_tag(:search_by,options_for_select([["昵称","0"],["姓名","1"],["邮箱","2"]]), :onchange => "searchByChange();",:style => "float:right" ) %>

View File

@ -2239,5 +2239,6 @@ zh:
label_course_prompt: 课程:
label_contain_resource: 已包含资源:
label_quote_resource_failed: ",此资源引用失败! "
label_file_lost: 以下文件在服务器丢失,请联系相关人员重新上传:
label_file_lost: 以下无法成功下载,请联系相关人员重新上传:
label_file_exist: 该作品中有重复命名文件,请通过文件名学号和姓名信息进入该作业详细界面手动下载

View File

@ -0,0 +1,10 @@
class AddDataForMembers < ActiveRecord::Migration
def change
StudentsForCourse.all.each do |stu|
if Member.where(:user_id => stu.student_id, :course_id => stu.course_id).first.nil?
mem = Member.new(:user_id => stu.student_id, :course_id => stu.course_id, :course_group_id => 0, :project_id => -1, :mail_notification => 0, :role_ids => [10])
mem.save!
end
end
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150108035338) do
ActiveRecord::Schema.define(:version => 20150112024820) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -831,8 +831,9 @@ ActiveRecord::Schema.define(:version => 20150108035338) do
t.integer "user_id"
t.datetime "published_at"
t.datetime "closed_at"
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.text "polls_description"
end
create_table "praise_tread_caches", :force => true do |t|

View File

@ -50,15 +50,13 @@ module Redmine
module ClassMethods
# Returns events of type event_type visible by user that occured between from and to
def find_events(event_type, user, from, to, options)
def find_events(event_type, user, days, created_time, options)
provider_options = activity_provider_options[event_type]
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?
scope = self
if from && to
scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to])
end
if options[:author]
return [] if provider_options[:author_key].nil?
@ -93,7 +91,15 @@ module Redmine
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
scope = scope.scoped(:conditions => Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
end
to = scope.select(:created_on).order("created_on desc").first.created_on
if options[:course]
from = (to - days) > created_time ? (to - days) : created_time.to_date
else
from = to - days -1.years
end
if from && to
scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to])
end
scope.all(provider_options[:find_options].dup)
end

View File

@ -79,7 +79,7 @@ module Redmine
# Returns an array of events for the given date range
# sorted in reverse chronological order
def events(from = nil, to = nil, options={})
def events(days = nil, created_time = nil, options={})
e = []
@options[:limit] = options[:limit]
# modify by nwb
@ -87,7 +87,7 @@ module Redmine
@scope.each do |event_type|
constantized_providers(event_type).each do |provider|
e += provider.find_events(event_type, @user, from, to, @options)
e += provider.find_events(event_type, @user, days, created_time, @options)
end
end

View File

@ -118,7 +118,7 @@ a.yellowBtn{ display:inline-block;color:#0d90c3; height:22px;}
.upload_con { }
.upload_con h2{ display:block; background:#eaeaea; font-size:14px; color:#343333; height:31px; width: auto; margin-top:25px; padding-left:20px; padding-top:5px;}
.upload_box{ width:430px; margin:15px auto;}
a.upload_btn{ display:block; float:left; margin-top:15px; width:80px; height:30px; text-align: center; color:#fff; font-size:14px; background:#15bccf; margin-right:15px;}
a.upload_btn{ display:block; float:left; margin-top:15px; width:80px; height:30px; text-align: center; color:#fff; font-size:14px; background:#15bccf; margin-right:15px;padding-top: 10px;}
a:hover.upload_btn{ background:#55a1b9;}
a.upload_btn_grey{background:#a3a3a3;}
a:hover.upload_btn_grey{background:#8a8a8a;}