FEATURE: display unpinned state, allow unpinning by clicking on pin

This commit is contained in:
Sam
2014-04-10 10:56:56 +10:00
parent 3f6764ce22
commit b9d4edd91a
12 changed files with 107 additions and 33 deletions

View File

@@ -31,6 +31,7 @@ class TopicViewSerializer < ApplicationSerializer
:draft_sequence,
:starred,
:posted,
:unpinned,
:pinned, # Is topic pinned and viewer hasn't cleared the pin?
:pinned_at, # Ignores clear pin
:details,
@@ -41,7 +42,7 @@ class TopicViewSerializer < ApplicationSerializer
:expandable_first_post
# Define a delegator for each attribute of the topic we want
attributes *topic_attributes
attributes(*topic_attributes)
topic_attributes.each do |ta|
class_eval %{def #{ta}
object.topic.#{ta}
@@ -145,7 +146,11 @@ class TopicViewSerializer < ApplicationSerializer
alias_method :include_posted?, :has_topic_user?
def pinned
PinnedCheck.new(object.topic, object.topic_user).pinned?
PinnedCheck.pinned?(object.topic, object.topic_user)
end
def unpinned
PinnedCheck.unpinned?(object.topic, object.topic_user)
end
def pinned_at