##// END OF EJS Templates
Projects menu item now shows the list of public projects and projects for which the user is a member (marked with a star)....
Jean-Philippe Lang -
r457:623d2f25b1ec
parent child
Show More
@@ -41,12 +41,12 class ProjectsController < ApplicationController
41 def list
41 def list
42 sort_init "#{Project.table_name}.name", "asc"
42 sort_init "#{Project.table_name}.name", "asc"
43 sort_update
43 sort_update
44 @project_count = Project.count(:all, :conditions => ["is_public=?", true])
44 @project_count = Project.count(:all, :conditions => Project.visible_by(logged_in_user))
45 @project_pages = Paginator.new self, @project_count,
45 @project_pages = Paginator.new self, @project_count,
46 15,
46 15,
47 params['page']
47 params['page']
48 @projects = Project.find :all, :order => sort_clause,
48 @projects = Project.find :all, :order => sort_clause,
49 :conditions => ["#{Project.table_name}.is_public=?", true],
49 :conditions => Project.visible_by(logged_in_user),
50 :include => :parent,
50 :include => :parent,
51 :limit => @project_pages.items_per_page,
51 :limit => @project_pages.items_per_page,
52 :offset => @project_pages.current.offset
52 :offset => @project_pages.current.offset
@@ -69,7 +69,9 class Project < ActiveRecord::Base
69 end
69 end
70
70
71 def self.visible_by(user=nil)
71 def self.visible_by(user=nil)
72 if user && !user.memberships.empty?
72 if user && user.admin?
73 return nil
74 elsif user && !user.memberships.empty?
73 return ["#{Project.table_name}.is_public = ? or #{Project.table_name}.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')})", true]
75 return ["#{Project.table_name}.is_public = ? or #{Project.table_name}.id IN (#{user.memberships.collect{|m| m.project_id}.join(',')})", true]
74 else
76 else
75 return ["#{Project.table_name}.is_public = ?", true]
77 return ["#{Project.table_name}.is_public = ?", true]
@@ -1,17 +1,18
1 <h2><%=l(:label_public_projects)%></h2>
1 <h2><%=l(:label_project_plural)%></h2>
2
2
3 <table class="list">
3 <table class="list">
4 <thead><tr>
4 <thead><tr>
5 <%= sort_header_tag("#{Project.table_name}.name", :caption => l(:label_project)) %>
5 <%= sort_header_tag("#{Project.table_name}.name", :caption => l(:label_project)) %>
6 <th><%=l(:field_description)%></th>
7 <th><%=l(:field_parent)%></th>
6 <th><%=l(:field_parent)%></th>
8 <%= sort_header_tag("#{Project.table_name}.created_on", :caption => l(:field_created_on)) %>
7 <%= sort_header_tag("#{Project.table_name}.created_on", :caption => l(:field_created_on)) %>
9 </tr></thead>
8 </tr></thead>
10 <tbody>
9 <tbody>
11 <% for project in @projects %>
10 <% for project in @projects %>
12 <tr class="<%= cycle("odd", "even") %>">
11 <tr class="<%= cycle("odd", "even") %>">
13 <td><%= link_to project.name, :action => 'show', :id => project %></td>
12 <td>
14 <td><%=h project.description %></td>
13 <%= link_to project.name, {:action => 'show', :id => project}, :class => (@logged_in_user && @logged_in_user.role_for_project(project) ? "icon icon-fav" : "") %><br />
14 <%=h project.description %>
15 </td>
15 <td><%= link_to(project.parent.name, :action => 'show', :id => project.parent) unless project.parent.nil? %></td>
16 <td><%= link_to(project.parent.name, :action => 'show', :id => project.parent) unless project.parent.nil? %></td>
16 <td align="center"><%= format_date(project.created_on) %></td>
17 <td align="center"><%= format_date(project.created_on) %></td>
17 </tr>
18 </tr>
@@ -19,5 +20,11
19 </tbody>
20 </tbody>
20 </table>
21 </table>
21
22
23 <% if @logged_in_user %>
24 <div class="contextual">
25 <span class="icon icon-fav"><%= l(:label_my_projects) %></span>
26 </div>
27 <% end %>
28
22 <%= pagination_links_full @project_pages %>
29 <%= pagination_links_full @project_pages %>
23 [ <%= @project_pages.current.first_item %> - <%= @project_pages.current.last_item %> / <%= @project_count %> ] No newline at end of file
30 [ <%= @project_pages.current.first_item %> - <%= @project_pages.current.last_item %> / <%= @project_count %> ]
General Comments 0
You need to be logged in to leave comments. Login now