教师数目显示:-1 ,同时动态大量不显示。是不是只显示近期3个月的?

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2015-01-12 14:58:11 +08:00
parent 2cd805ef4c
commit 9f807438d6
9 changed files with 44 additions and 28 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

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

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

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