Commit 0a7c58530c7ca5c417e1353072411f1c523425d2
Committed by
Antonio Terceiro
1 parent
e5dba6d0
Exists in
master
and in
28 other branches
ActionItem991: added pagination and cache to communities
Showing
3 changed files
with
17 additions
and
5 deletions
Show diff stats
app/controllers/public/profile_controller.rb
@@ -20,7 +20,9 @@ class ProfileController < PublicController | @@ -20,7 +20,9 @@ class ProfileController < PublicController | ||
20 | end | 20 | end |
21 | 21 | ||
22 | def communities | 22 | def communities |
23 | - @communities = profile.communities | 23 | + if is_cache_expired?(profile.communities_cache_key(params)) |
24 | + @communities = profile.communities.paginate(:per_page => per_page, :page => params[:npage]) | ||
25 | + end | ||
24 | end | 26 | end |
25 | 27 | ||
26 | def enterprises | 28 | def enterprises |
app/models/community.rb
@@ -44,4 +44,8 @@ class Community < Organization | @@ -44,4 +44,8 @@ class Community < Organization | ||
44 | def news(limit = 30, highlight = false) | 44 | def news(limit = 30, highlight = false) |
45 | recent_documents(limit, ["articles.type != ? AND articles.highlighted = ?", 'Folder', highlight]) | 45 | recent_documents(limit, ["articles.type != ? AND articles.highlighted = ?", 'Folder', highlight]) |
46 | end | 46 | end |
47 | + | ||
48 | + def blocks_to_expire_cache | ||
49 | + [MembersBlock] | ||
50 | + end | ||
47 | end | 51 | end |
app/views/profile/communities.rhtml
@@ -3,11 +3,17 @@ | @@ -3,11 +3,17 @@ | ||
3 | 3 | ||
4 | <h1><%= _("%s's communities") % profile.name %></h1> | 4 | <h1><%= _("%s's communities") % profile.name %></h1> |
5 | 5 | ||
6 | -<ul class='profile-list'> | ||
7 | -<% @communities.each do |community| %> | ||
8 | - <li><%= profile_image_link(community)%></li> | 6 | +<% cache(profile.communities_cache_key(params)) do %> |
7 | + <ul class='profile-list'> | ||
8 | + <% @communities.each do |community| %> | ||
9 | + <li><%= profile_image_link(community)%></li> | ||
10 | + <% end %> | ||
11 | + </ul> | ||
12 | + | ||
13 | + <div id='pagination-profiles'> | ||
14 | + <%= pagination_links @communities, :param_name => 'npage' %> | ||
15 | + </div> | ||
9 | <% end %> | 16 | <% end %> |
10 | -</ul> | ||
11 | 17 | ||
12 | <% button_bar do %> | 18 | <% button_bar do %> |
13 | <%= button :back, _('Go back'), { :controller => 'profile' }, | 19 | <%= button :back, _('Go back'), { :controller => 'profile' }, |