Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
fb6cd2e9d8
|
@ -36,15 +36,12 @@ class AdminController < ApplicationController
|
|||
|
||||
scope = Project.status(@status).order('lft')
|
||||
scope = scope.like(params[:name]) if params[:name].present?
|
||||
@projects = scope.all
|
||||
@projects = scope.where(project_type: Project::ProjectType_project).all
|
||||
|
||||
render :action => "projects", :layout => false if request.xhr?
|
||||
end
|
||||
|
||||
def users
|
||||
@project_type = params[:project_type]
|
||||
role = params[:role]
|
||||
|
||||
sort_init 'login', 'asc'
|
||||
sort_update %w(login firstname lastname mail admin created_on last_login_on)
|
||||
|
||||
|
@ -56,95 +53,14 @@ class AdminController < ApplicationController
|
|||
end
|
||||
|
||||
@status = params[:status] || 1
|
||||
has = {
|
||||
"show_changesets" => true
|
||||
}
|
||||
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
|
||||
|
||||
scope = UserStatus.visible
|
||||
case role
|
||||
when 'teacher'
|
||||
scope = UserStatus.teacher
|
||||
when 'student'
|
||||
scope = UserStatus.student
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
scope = User.logged.status(@status)
|
||||
scope = User.like(params[:name]) if params[:name].present?
|
||||
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
|
||||
# scope.each do |user|
|
||||
# UserStatus.create(:changesets_count => user.changesets.count, :watchers_count => user.watcher_users.count, :user_id => user.id)
|
||||
# end
|
||||
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||
#@offset ||= @user_pages.offset
|
||||
#@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
||||
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||
if params[:user_sort_type].present?
|
||||
case params[:user_sort_type]
|
||||
when '0'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 0
|
||||
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||
# @projects = @projects[@offset, @limit]
|
||||
when '1'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 1
|
||||
#sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count}
|
||||
#@users = @users[@offset, @limit]
|
||||
when '2'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 2
|
||||
#@users = @users[@offset, @limit]
|
||||
end
|
||||
|
||||
else
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users_statuses = scope.reorder('grade').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_type = 1
|
||||
# @projects = @projects.sort {|x,y| y.created_on <=> x.created_on }
|
||||
# @projects = @projects[@offset, @limit]
|
||||
end
|
||||
|
||||
@users = []
|
||||
@users_statuses.each do |obj|
|
||||
@users << User.find_by_id("#{obj.user_id}")
|
||||
end
|
||||
@offset ||= @user_pages.offset
|
||||
@users = scope.order(sort_clause).limit(@limit).offset(@offset).all
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -209,24 +125,13 @@ class AdminController < ApplicationController
|
|||
end
|
||||
|
||||
@status = params[:status] || 1
|
||||
has = {
|
||||
"show_changesets" => true
|
||||
}
|
||||
scope = User.logged.status(@status)
|
||||
scope = scope.like(params[:name]) if params[:name].present?
|
||||
@user_count = scope.count
|
||||
@user_pages = Paginator.new @user_count, @limit, params['page']
|
||||
@user_base_tag = params[:id] ? 'base_users':'base'
|
||||
@offset ||= @user_pages.reverse_offset
|
||||
unless @offset == 0
|
||||
@users = scope.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @user_count % @limit
|
||||
if limit == 0
|
||||
limit = @limit
|
||||
end
|
||||
@users = scope.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
|
||||
@users = scope.offset(@user_pages.offset).limit(@user_pages.per_page)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
|
|
@ -173,7 +173,7 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
# modify by nwb
|
||||
if @attachment.container_type == 'Course'
|
||||
if @attachment.container.is_a?(Course) || @attachment.container.course
|
||||
if @course.nil?
|
||||
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
|
||||
else
|
||||
|
@ -286,6 +286,8 @@ private
|
|||
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
|
||||
if @attachment.container_type == 'Course'
|
||||
@course = @attachment.course
|
||||
elsif @attachment.container.course
|
||||
@course = @attachment.container.course
|
||||
else
|
||||
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication'
|
||||
@project = @attachment.project
|
||||
|
|
|
@ -163,7 +163,7 @@ class FilesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 返回制定资源类型的资源列表
|
||||
# 返回指定资源类型的资源列表
|
||||
# added by nwb
|
||||
def getattachtype
|
||||
sort_init 'created_on', 'desc'
|
||||
|
|
|
@ -98,10 +98,12 @@ class NewsController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@news = News.new(:project => @project, :author => User.current)
|
||||
@course_tag = @project.project_type
|
||||
if @course_tag
|
||||
render :layout => 'base_courses'
|
||||
#modify by nwb
|
||||
if @project
|
||||
@news = News.new(:project => @project, :author => User.current)
|
||||
elsif @course
|
||||
@news = News.new(:course => @course, :author => User.current)
|
||||
render :layout => 'base_courses'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -19,17 +19,17 @@ class SoftapplicationsController < ApplicationController
|
|||
|
||||
#new added sort
|
||||
if params[:softapplication_sort_type].present?
|
||||
case params[:softapplication_sort_type]
|
||||
case params[:softapplication_sort_type]
|
||||
when '0'
|
||||
@softapplications = @softapplications[@offset, @limit]
|
||||
@softapplications = @softapplications[@offset, @limit]
|
||||
@s_state = 0
|
||||
when '1'
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
end
|
||||
else
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
else
|
||||
@softapplications = @softapplications.sort { |x, y| y[:created_at] <=> x[:created_at]}[@offset, @limit]
|
||||
@s_state = 1
|
||||
end
|
||||
#new added end
|
||||
|
||||
|
@ -216,19 +216,19 @@ class SoftapplicationsController < ApplicationController
|
|||
def new_message
|
||||
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
|
||||
if @jour
|
||||
user = @jour.user
|
||||
text = @jour.notes
|
||||
user = @jour.user
|
||||
text = @jour.notes
|
||||
else
|
||||
user = @softapplication.user
|
||||
text = @softapplication.description
|
||||
user = @softapplication.user
|
||||
text = @softapplication.description
|
||||
end
|
||||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
||||
@content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> "
|
||||
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
@id = user.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
#新建评价
|
||||
def create_message
|
||||
|
|
|
@ -151,7 +151,7 @@ class UsersController < ApplicationController
|
|||
|
||||
# added by fq
|
||||
def user_activities
|
||||
redirect_to user_path(@user, type: params[:type])
|
||||
redirect_to user_path(@user, type: params[:type], page: params[:page])
|
||||
return
|
||||
# useless abort.
|
||||
@watcher = User.watched_by_id(@user)
|
||||
|
@ -586,7 +586,7 @@ class UsersController < ApplicationController
|
|||
def destroy
|
||||
@user.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_default(users_path) }
|
||||
format.html { redirect_back_or_default(admin_users_path) }
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,6 @@ class Softapplication < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :project
|
||||
has_many :contests, :through => :contesting_softapplications
|
||||
belongs_to :project
|
||||
|
||||
def add_jour(user, notes, reference_user_id = 0, options = {})
|
||||
if options.count == 0
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<h3><%= l(:label_user_plural)%></h3>
|
||||
|
||||
<%= form_tag(:controller => 'admin', :action => 'search', :method => :get) do %>
|
||||
<%= form_tag(:controller => 'admin', :action => 'search') do %>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<%= l(:label_filter_plural) %>
|
||||
|
@ -51,7 +51,7 @@
|
|||
<td class="created_on" align="center"><%= format_time(user.created_on) %></td>
|
||||
<td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
|
||||
<td class="buttons"> <%= change_status_link(user) %>
|
||||
<%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %> </td>
|
||||
<%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> </td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
</tbody>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<h3><%= l(:label_user_plural)%></h3>
|
||||
|
||||
<%= form_tag(:controller => 'admin', :action => 'search', :method => :get) do %>
|
||||
<%= form_tag(:controller => 'admin', :action => 'search') do %>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<%= l(:label_filter_plural) %>
|
||||
|
@ -51,7 +51,7 @@
|
|||
<td class="created_on" align="center"><%= format_time(user.created_on) %></td>
|
||||
<td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
|
||||
<td class="buttons"> <%= change_status_link(user) %>
|
||||
<%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %> </td>
|
||||
<%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> </td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
</tbody>
|
||||
|
|
|
@ -83,6 +83,14 @@ module Redmine
|
|||
end
|
||||
|
||||
def save_attachments(attachments, author=User.current)
|
||||
# 清除临时文件
|
||||
if attachments
|
||||
tempAttach = attachments[:dummy]
|
||||
if tempAttach && tempAttach[:file]
|
||||
attachments.delete(:dummy)
|
||||
end
|
||||
end
|
||||
|
||||
if attachments.is_a?(Hash)
|
||||
attachments = attachments.stringify_keys
|
||||
attachments = attachments.to_a.sort {|a, b|
|
||||
|
|
Loading…
Reference in New Issue