项目列表中:私有项目对非成员显示,非成员不点击进入

This commit is contained in:
daiao 2016-09-05 16:55:56 +08:00
parent 3dc0e8407a
commit cdd4dfcf09
3 changed files with 2358 additions and 2343 deletions

View File

@ -3516,11 +3516,15 @@ class UsersController < ApplicationController
@order, @c_sort, @type, @list_type = 1, 2, 1, 1
#limit = 5
@my_projects = @user.projects.visible.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
# 用户的所有项目
# @my_projects = @user.projects.visible.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
@my_projects = @user.projects.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
@my_projects_count = @my_projects.count
@my_joined_projects = @user.projects.visible.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
#@my_joined_projects = @user.projects.visible.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
@my_joined_projects = @user.projects.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
@my_joined_projects_count = @my_joined_projects.count
respond_to do |format|
format.html {render :layout => 'new_base_user'}
end

View File

@ -1,17 +1,23 @@
<div class="syllabus_category">
<% unless projects.empty? %>
<% if @type.to_i == 2 %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :style => "margin-right: 5px;", :remote => true %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 },
:class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :style => "margin-right: 5px;", :remote => true %>
<% else %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortdownbtn sort_no fr", :style => "margin-right: 5px;", :remote => true %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 },
:class => "sortdownbtn sort_no fr", :style => "margin-right: 5px;", :remote => true %>
<% end %>
<%= link_to "人气", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortTxt fr", :remote => true %>
<%= link_to "人气", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 },
:class => "sortTxt fr", :remote => true %>
<% if @type.to_i == 1 %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :remote => true %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 },
:class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :remote => true %>
<% else %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortdownbtn sort_no fr", :remote => true %>
<%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 },
:class => "sortdownbtn sort_no fr", :remote => true %>
<% end %>
<%= link_to "时间", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortTxt fr", :remote => true %>
<%= link_to "时间", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 },
:class => "sortTxt fr", :remote => true %>
<% end %>
<span class="grayTxt fl "><%= @user == User.current ? "我" : "他" %><%= list_type == 1 ? "创建" : "参与"%>的项目</span>
<div class="cl"></div>
@ -31,11 +37,13 @@
<% else %>
<% projects.each_with_index do |project, i| %>
<div class="syllabus_courses_list <%= i > 4 ? 'none' : ''%>" style="cursor: default;">
<% allow_visit = User.current.member_of?(project) || User.current.admin? || project.is_public %>
<div class="sy_courses_open">
<span id="collect_project_icon_<%= project.id %>">
<%=render :partial => 'collect_project', :locals => {:project => project} %>
</span>
<h3><%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%></h3>
<h3><%= link_to project.name, allow_visit ? project_path(project.id,:host=>Setting.host_name) : 'javascript:void(0)', :target => '_blank',
:class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (allow_visit ? "#{project.name}" : "私有班级不可访问") %></h3>
<% unless project.is_public? %>
<span class="syllabus_class_private fl ml10 mt3 syllabus_class_property">私有</span>
<% end %>
@ -58,7 +66,8 @@
<% end %>
<% if count > 5 %>
<div class="syllabus_courses_list">
<p class="new_projectlist_more"><a id="project_more_<%=list_type %>" href="javascript:void(0);" data-count="<%= count %>" data-init="0" onclick="expand_projects('#project_more_<%=list_type %>', '#project_li_<%=list_type %>', <%=count%>);">共<%=count %>个项目,点击全部展开</a></p>
<p class="new_projectlist_more"><a id="project_more_<%=list_type %>" href="javascript:void(0);" data-count="<%= count %>" data-init="0" onclick="expand_projects('#project_more_<%=list_type %>',
'#project_li_<%=list_type %>', <%=count%>);">共<%=count %>个项目,点击全部展开</a></p>
</div>
<% end %>
<% end %>

View File

@ -56,8 +56,8 @@ ActiveRecord::Schema.define(:version => 20160830090214) do
t.integer "user_id"
t.integer "applied_id"
t.string "applied_type"
t.integer "viewed", :default => 0
t.integer "status", :default => 0
t.integer "viewed"
t.integer "status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "name"
@ -318,6 +318,8 @@ ActiveRecord::Schema.define(:version => 20160830090214) do
t.date "commit_date"
t.string "scmid"
t.integer "user_id"
t.integer "project_id"
t.integer "type", :default => 0
end
add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on"