From 0a7c58530c7ca5c417e1353072411f1c523425d2 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Sat, 23 May 2009 18:28:07 -0300 Subject: [PATCH] ActionItem991: added pagination and cache to communities --- app/controllers/public/profile_controller.rb | 4 +++- app/models/community.rb | 4 ++++ app/views/profile/communities.rhtml | 14 ++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index 5501e0d..7c23c83 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -20,7 +20,9 @@ class ProfileController < PublicController end def communities - @communities = profile.communities + if is_cache_expired?(profile.communities_cache_key(params)) + @communities = profile.communities.paginate(:per_page => per_page, :page => params[:npage]) + end end def enterprises diff --git a/app/models/community.rb b/app/models/community.rb index 850590d..0cf01aa 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -44,4 +44,8 @@ class Community < Organization def news(limit = 30, highlight = false) recent_documents(limit, ["articles.type != ? AND articles.highlighted = ?", 'Folder', highlight]) end + + def blocks_to_expire_cache + [MembersBlock] + end end diff --git a/app/views/profile/communities.rhtml b/app/views/profile/communities.rhtml index 22b974b..94375fa 100644 --- a/app/views/profile/communities.rhtml +++ b/app/views/profile/communities.rhtml @@ -3,11 +3,17 @@

<%= _("%s's communities") % profile.name %>

- <% button_bar do %> <%= button :back, _('Go back'), { :controller => 'profile' }, -- libgit2 0.21.2