Topic Auto-Close: admins and mods can set a topic to automatically close after a number of days

This commit is contained in:
Neil Lalonde
2013-05-07 14:25:41 -04:00
parent 87469fa4b7
commit 9828c87525
33 changed files with 600 additions and 55 deletions

View File

@ -15,7 +15,8 @@ class TopicsController < ApplicationController
:unmute,
:set_notifications,
:move_posts,
:clear_pin]
:clear_pin,
:autoclose]
before_filter :consider_user_for_promotion, only: :show
@ -97,6 +98,16 @@ class TopicsController < ApplicationController
toggle_mute(false)
end
def autoclose
requires_parameter(:auto_close_days)
@topic = Topic.where(id: params[:topic_id].to_i).first
guardian.ensure_can_moderate!(@topic)
@topic.auto_close_days = params[:auto_close_days]
@topic.auto_close_user = current_user
@topic.save
render nothing: true
end
def destroy
topic = Topic.where(id: params[:id]).first
guardian.ensure_can_delete!(topic)