FEATURE: bookmark topic button

This commit is contained in:
Régis Hanol
2015-01-12 12:10:15 +01:00
parent a9ef92f3d8
commit c681b353f2
14 changed files with 103 additions and 48 deletions

View File

@ -25,7 +25,8 @@ class TopicsController < ApplicationController
:autoclose,
:bulk,
:reset_new,
:change_post_owners]
:change_post_owners,
:bookmark]
before_filter :consider_user_for_promotion, only: :show
@ -212,6 +213,19 @@ class TopicsController < ApplicationController
render nothing: true
end
def bookmark
topic = Topic.find_by(id: params[:topic_id])
first_post = topic.ordered_posts.first
if params[:bookmarked] == "true"
PostAction.act(current_user, first_post, PostActionType.types[:bookmark])
else
PostAction.remove_act(current_user, first_post, PostActionType.types[:bookmark])
end
render nothing: true
end
def destroy
topic = Topic.find_by(id: params[:id])
guardian.ensure_can_delete!(topic)