Merge pull request #385 from AyuntamientoMadrid/author-cache
bugfix: adds cache for authors of debate/comment
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
module CacheKeysHelper
|
||||
|
||||
def locale_and_user_status
|
||||
@cache_key_user ||= calculate_user_status
|
||||
def locale_and_user_status(authorable=nil)
|
||||
@cache_key_user ||= calculate_user_status(authorable)
|
||||
"#{I18n.locale}/#{@cache_key_user}"
|
||||
end
|
||||
|
||||
def calculate_user_status
|
||||
def calculate_user_status(authorable=nil)
|
||||
user_status = "user"
|
||||
|
||||
if user_signed_in?
|
||||
@@ -14,6 +14,7 @@ module CacheKeysHelper
|
||||
user_status += ":org" if current_user.organization?
|
||||
user_status += ":admin" if current_user.administrator?
|
||||
user_status += ":moderator" if current_user.moderator?
|
||||
user_status += ":author" if authorable && authorable.author == current_user
|
||||
else
|
||||
user_status += ":visitor"
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<% cache [locale_and_user_status, comment, @commentable, comment.author, (@comment_flags[comment.id] if @comment_flags)] do %>
|
||||
<% cache [locale_and_user_status(comment), comment, @commentable, comment.author, (@comment_flags[comment.id] if @comment_flags)] do %>
|
||||
<div class="row">
|
||||
<div id="<%= dom_id(comment) %>" class="comment small-12 column">
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<% cache [locale_and_user_status, @debate, @debate.author, Flag.flagged?(current_user, @debate)] do %>
|
||||
<% cache [locale_and_user_status(@debate), @debate, @debate.author, Flag.flagged?(current_user, @debate)] do %>
|
||||
<section class="debate-show">
|
||||
<div id="<%= dom_id(@debate) %>" class="row">
|
||||
<div class="small-12 medium-9 column">
|
||||
|
||||
Reference in New Issue
Block a user