我的课程、我的项目、他的课程、他的项目只显示出有权限的课程和项目。以及数量统计不正确
This commit is contained in:
parent
03c1099b78
commit
5dc3eba27a
|
@ -112,39 +112,20 @@ class UsersController < ApplicationController
|
|||
|
||||
#added by young
|
||||
def user_projects
|
||||
|
||||
#add by huang
|
||||
unless User.current.admin?
|
||||
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
||||
render_404
|
||||
return
|
||||
end
|
||||
end
|
||||
#end
|
||||
# if User.current.admin?
|
||||
# @memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}")
|
||||
# else
|
||||
# cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
|
||||
# @memberships = @user.memberships.all(:conditions => cond)
|
||||
# end
|
||||
#events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
|
||||
#@events_by_day = events.group_by(&:event_date)
|
||||
# @state = 0
|
||||
|
||||
limit = 10;
|
||||
query = Project.joins("join members m on #{Project.table_name}.id=m.project_id")
|
||||
query = query.where("m.user_id = ? and #{Project.table_name}.project_type=?",@user.id,Project::ProjectType_project)
|
||||
projects = @user.projects.visible.order("updated_on desc")
|
||||
if(params[:status] == '1')
|
||||
query = query.where("#{Project.table_name}.user_id = ?",@user.id);
|
||||
projects = projects.where("user_id = ?",@user.id)
|
||||
elsif(params[:status] == '2')
|
||||
query = query.where("#{Project.table_name}.user_id <> ?",@user.id);
|
||||
projects = projects.where("user_id <> ?",@user.id)
|
||||
end
|
||||
@obj_count = query.count();
|
||||
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("#{Project.table_name}.updated_on desc,#{Project.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
@params = params
|
||||
|
||||
@list = paginateHelper projects,10
|
||||
@params = params[:status]
|
||||
respond_to do |format|
|
||||
format.html{render :layout=>'base_users_new'}
|
||||
format.api
|
||||
|
@ -262,57 +243,20 @@ class UsersController < ApplicationController
|
|||
def user_courses
|
||||
|
||||
unless User.current.admin?
|
||||
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
|
||||
if !@user.active?
|
||||
render_404
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
|
||||
limit = 10;
|
||||
query = Course.joins("join members m on #{Course.table_name}.id=m.course_id")
|
||||
query = query.where("m.user_id = ?",@user.id)
|
||||
courses = @user.courses.visible.order("created_at desc")
|
||||
if(params[:status] == '1')
|
||||
query = query.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now);
|
||||
courses = courses.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now)
|
||||
elsif(params[:status] == '2')
|
||||
query = query.where("endup_time < ?",Time.now);
|
||||
courses = courses.where("endup_time < ?",Time.now)
|
||||
end
|
||||
@obj_count = query.count();
|
||||
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("#{Course.table_name}.updated_at desc,#{Course.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
@params = params
|
||||
@list = paginateHelper courses,10
|
||||
@params = params[:status]
|
||||
render :layout=>'base_users_new'
|
||||
|
||||
# if User.current == @user || User.current.admin?
|
||||
# membership = @user.coursememberships.all
|
||||
# else
|
||||
# membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
# end
|
||||
#
|
||||
# membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||
# @memberships = []
|
||||
# membership.collect { |e|
|
||||
# @memberships.push(e)
|
||||
# }
|
||||
# ## 判断课程是否过期 [需封装]
|
||||
# @memberships_doing = []
|
||||
# @memberships_done = []
|
||||
# #now_time = Time.now.year
|
||||
# @memberships.map { |e|
|
||||
# #end_time = e.course.get_time.year
|
||||
# isDone = course_endTime_timeout?(e.course)
|
||||
# if isDone
|
||||
# @memberships_done.push e
|
||||
# else
|
||||
# @memberships_doing.push e
|
||||
# end
|
||||
# }
|
||||
# respond_to do |format|
|
||||
# format.html
|
||||
# format.api
|
||||
# end
|
||||
end
|
||||
|
||||
# modified by fq
|
||||
|
|
|
@ -126,9 +126,13 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
|
||||
<% if @center_flag %>
|
||||
<div class="subNavBox ">
|
||||
<div class="subNav "><a href="<%=url_for(:controller => 'users', :action => 'show',:id=>@user.id)%>" class=" f14 c_blue02">动态</a></div>
|
||||
<div class="subNav ">
|
||||
<a href="<%=url_for(:controller => 'users', :action => 'show',:id=>@user.id)%>" class=" f14 c_blue02">
|
||||
动态
|
||||
</a>
|
||||
</div>
|
||||
<% if @center_flag %>
|
||||
<div class="subNav">
|
||||
<a href="<%=url_for(:controller => 'users', :action => 'user_courses',:id=>@user.id)%>" class=" f14 c_blue02">
|
||||
我的课程
|
||||
|
@ -141,9 +145,27 @@
|
|||
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.count%>)</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="subNav "><a href="<%= url_for(:controller => 'my', :action => 'account') %>" class=" f14 c_blue02">编辑资料</a></div>
|
||||
</div><!--侧导航 end-->
|
||||
<div class="subNav ">
|
||||
<a href="<%= url_for(:controller => 'my', :action => 'account') %>" class=" f14 c_blue02">编辑资料</a>
|
||||
</div>
|
||||
<% else%>
|
||||
<div class="subNav">
|
||||
<a href="<%=url_for(:controller => 'users', :action => 'user_courses',:id=>@user.id)%>" class=" f14 c_blue02">
|
||||
TA的课程
|
||||
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.courses.visible.count%>)</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="subNav">
|
||||
<a href="<%=url_for(:controller => 'users', :action => 'user_projects',:id=>@user.id)%>" class=" f14 c_blue02">
|
||||
TA的项目
|
||||
<span style="font-weight:normal;font-size:12px;color:#FF5722;">(<%=@user.projects.visible.count%>)</span>
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="subNav "><a href="javascirpt:void(0);" class=" f14 c_blue02">留言</a></div>
|
||||
</div><!--侧导航 end-->
|
||||
|
||||
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="leftbox mt10">
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
<div class="courses_top mb10">
|
||||
<h2 class="courses_h2 fl">所有课程</h2>
|
||||
<div class="courses_select fr">
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_courses')%>" class="select_btn <%= (@params['status']!='1' && @params['status']!='2') ? 'select_btn_select' : '' %> fl "> 全部</a>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_courses', :status=>'1')%>" class="select_btn <%= (@params['status']=='1') ? 'select_btn_select' : '' %> fl ">正在进行</a>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_courses', :status=>'2')%>" class="select_btn <%= (@params['status']=='2') ? 'select_btn_select' : '' %> fl "> 已经结束</a>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_courses')%>" class="select_btn <%= (@params!='1' && @params!='2') ? 'select_btn_select' : '' %> fl "> 全部</a>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_courses', :status=>'1')%>" class="select_btn <%= (@params=='1') ? 'select_btn_select' : '' %> fl ">正在进行</a>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_courses', :status=>'2')%>" class="select_btn <%= (@params=='2') ? 'select_btn_select' : '' %> fl "> 已经结束</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
<div class="courses_top mb10">
|
||||
<h2 class="courses_h2 fl">全部项目</h2>
|
||||
<div class="courses_select fr">
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_projects')%>" class="select_btn <%= (@params['status']!='1' && @params['status']!='2') ? 'select_btn_select' : '' %> fl "> 全部</a>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_projects', :status=>'1')%>" class="select_btn <%= (@params['status']=='1') ? 'select_btn_select' : '' %> fl ">我创建</a>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_projects', :status=>'2')%>" class="select_btn <%= (@params['status']=='2') ? 'select_btn_select' : '' %> fl "> 我参与</a>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_projects')%>" class="select_btn <%= (@params!='1' && @params!='2') ? 'select_btn_select' : '' %> fl "> 全部</a>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_projects', :status=>'1')%>" class="select_btn <%= (@params=='1') ? 'select_btn_select' : '' %> fl ">我创建</a>
|
||||
<a href="<%= url_for(:controller => 'users', :action => 'user_projects', :status=>'2')%>" class="select_btn <%= (@params=='2') ? 'select_btn_select' : '' %> fl "> 我参与</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue