Commit 26f8889c250391f4adc61178129e9396b05dae98
1 parent
67e3c824
Exists in
master
and in
11 other branches
proposals_discussion: fix cache issues
Showing
4 changed files
with
16 additions
and
1 deletions
Show diff stats
lib/proposals_discussion_plugin/discussion.rb
@@ -21,4 +21,9 @@ class ProposalsDiscussionPlugin::Discussion < Folder | @@ -21,4 +21,9 @@ class ProposalsDiscussionPlugin::Discussion < Folder | ||
21 | end | 21 | end |
22 | end | 22 | end |
23 | 23 | ||
24 | + def cache_key_with_person(params = {}, user = nil, language = 'en') | ||
25 | + cache_key_without_person + (user ? "-#{user.identifier}" : '') | ||
26 | + end | ||
27 | + alias_method_chain :cache_key, :person | ||
28 | + | ||
24 | end | 29 | end |
lib/proposals_discussion_plugin/proposal.rb
@@ -33,4 +33,9 @@ class ProposalsDiscussionPlugin::Proposal < TinyMceArticle | @@ -33,4 +33,9 @@ class ProposalsDiscussionPlugin::Proposal < TinyMceArticle | ||
33 | (score/holder.max_score.to_f).round(2) | 33 | (score/holder.max_score.to_f).round(2) |
34 | end | 34 | end |
35 | 35 | ||
36 | + def cache_key_with_person(params = {}, user = nil, language = 'en') | ||
37 | + cache_key_without_person + (user && created_by == user ? "-#{user.identifier}" : '') | ||
38 | + end | ||
39 | + alias_method_chain :cache_key, :person | ||
40 | + | ||
36 | end | 41 | end |
lib/proposals_discussion_plugin/topic.rb
@@ -51,4 +51,9 @@ class ProposalsDiscussionPlugin::Topic < Folder | @@ -51,4 +51,9 @@ class ProposalsDiscussionPlugin::Topic < Folder | ||
51 | proposals.joins(:comments).group('date(comments.created_at)').count('comments.id') | 51 | proposals.joins(:comments).group('date(comments.created_at)').count('comments.id') |
52 | end | 52 | end |
53 | 53 | ||
54 | + def cache_key_with_person(params = {}, user = nil, language = 'en') | ||
55 | + cache_key_without_person + (user ? "-#{user.identifier}" : '') | ||
56 | + end | ||
57 | + alias_method_chain :cache_key, :person | ||
58 | + | ||
54 | end | 59 | end |
views/content_viewer/proposal.html.erb
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | <div class="content"><%= @page.body %></div> | 22 | <div class="content"><%= @page.body %></div> |
23 | </div> | 23 | </div> |
24 | 24 | ||
25 | -<% if @page.allow_edit?(user) && !@page.published %> | 25 | +<% if @page.created_by == user && !@page.published %> |
26 | <div class="actions"> | 26 | <div class="actions"> |
27 | <%= link_to url_for({:controller => 'proposals_discussion_plugin_myprofile', :action => 'publish_proposal', :proposal_id => @page.id}), :class => 'button with-text icon-suggest' do %> | 27 | <%= link_to url_for({:controller => 'proposals_discussion_plugin_myprofile', :action => 'publish_proposal', :proposal_id => @page.id}), :class => 'button with-text icon-suggest' do %> |
28 | <strong><%= _("Publish") %></strong> | 28 | <strong><%= _("Publish") %></strong> |