Modified: branches/event_logging/app/models/group_announcement_sweeper.rb (2002 => 2003)
--- branches/event_logging/app/models/group_announcement_sweeper.rb 2008-11-27 11:08:56 UTC (rev 2002)
+++ branches/event_logging/app/models/group_announcement_sweeper.rb 2008-11-27 11:45:22 UTC (rev 2003)
@@ -14,11 +14,13 @@
# (the link/title of the last announcement is not cached at the moment, because it's user-specific: for members/non-members)
# - listing of groups on the home page (same as above)
#
- # However content in
+ # Content in
# - listing of group announcements;
# - group announcements box on group's page
# is user-specific: i.e. either public or private&public
# group announcements are shown to the current user
+ # (the filtering is performed by the controller and caching done on individual fragments only,
+ # which means that non-members will not see certain fragments)
def after_create(group_announcement)
expire_group_announcement(group_announcement)
expire_listing(group_announcement.network.id, 'Network')
@@ -41,8 +43,8 @@
private
def expire_group_announcement(group_announcement)
- # any specific expires for the group announcement itself
- # (none for now)
+ # specific expires for the group announcement itself
+ expire_listing(group_announcement.id, 'GroupAnnouncement')
end
end
Modified: branches/event_logging/app/views/group_announcements/_table.rhtml (2002 => 2003)
--- branches/event_logging/app/views/group_announcements/_table.rhtml 2008-11-27 11:08:56 UTC (rev 2002)
+++ branches/event_logging/app/views/group_announcements/_table.rhtml 2008-11-27 11:45:22 UTC (rev 2003)
@@ -1,3 +1,7 @@
+<% # public / private announcements are already filtered in the "collection" for the current user; -%>
+<% # no need to cache individual announcement listings for members/non-members, because non-members -%>
+<% # simply won't see the private ones -%>
+
<% unless collection.empty? %>
<table class="alt_table">
@@ -4,30 +8,32 @@
<% odd_row = false -%>
<% for announcement in collection %>
<tr class="<%= (odd_row = !odd_row) ? "odd_row" : "even_row" %>">
- <td width="100px">
- <%= contributor(announcement.user_id, 'User', true, 60) %>
- </td>
- <td class="mid" style="text-align: left;">
- <p style="margin-top:0; padding-top:0; font-weight:bold; font-size: 108%;">
- <%= icon "announcement", nil, nil, nil, '' %>
- <%= link_to h(announcement.title), group_announcement_url(group, announcement) %>
- </p>
-
- <p style="font-size: 85%;">
- <b><%= datetime announcement.created_at %></b>
- </p>
-
- <% if announcement.body and announcement.body.length > 0 %>
- <div class="desc" style="font-size: 85%;">
- <%= truncate(strip_html(announcement.body), 180) %>
- </div>
- <% end %>
-
- <p style="text-align: right; margin-left: 0.3em; margin-top: 1em; font-size: 85%; font-weight: bold; color: #333333;">
- <%= (announcement.public ? "Public" : "Private")+ " announcement" -%>
- </p>
-
- </td>
+ <% cache(:controller => 'group_announcements_cache', :action ="" 'listing', :id => announcement.id) do -%>
+ <td width="100px">
+ <%= contributor(announcement.user_id, 'User', true, 60) %>
+ </td>
+ <td class="mid" style="text-align: left;">
+ <p style="margin-top:0; padding-top:0; font-weight:bold; font-size: 108%;">
+ <%= icon "announcement", nil, nil, nil, '' %>
+ <%= link_to h(announcement.title), group_announcement_url(group, announcement) %>
+ </p>
+
+ <p style="font-size: 85%;">
+ <b><%= datetime announcement.created_at %></b>
+ </p>
+
+ <% if announcement.body and announcement.body.length > 0 %>
+ <div class="desc" style="font-size: 85%;">
+ <%= truncate(strip_html(announcement.body), 180) %>
+ </div>
+ <% end %>
+
+ <p style="text-align: right; margin-left: 0.3em; margin-top: 1em; font-size: 85%; font-weight: bold; color: #333333;">
+ <%= (announcement.public ? "Public" : "Private")+ " announcement" -%>
+ </p>
+
+ </td>
+ <% end -%>
<td class="actions" style="width: 80px;">
<%= icon "show", group_announcement_path(group, announcement), nil, nil, "View" %>
<% if group.owner?(current_user.id) %>