Sha256: d3ee656b3935642381194c0bcd0e6b1fdb1d812c28b744f595e5cdd64dea4bb3

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

module Commontator
  class ThreadsController < Commontator::ApplicationController
    skip_before_filter :ensure_user, :only => :show
    before_filter :set_thread

    # GET /threads/1
    def show
      commontator_thread_show(@thread.commontable)
      @show_all = params[:show_all] && @thread.can_be_edited_by?(@user)

      respond_to do |format|
        format.html { redirect_to main_app.polymorphic_path(@thread.commontable) }
        format.js
      end
    end
    
    # PUT /threads/1/close
    def close
      security_transgression_unless @thread.can_be_edited_by?(@user)

      @thread.errors.add(:base, t('commontator.thread.errors.already_closed')) \
        unless @thread.close(@user)

      @show_all = true

      respond_to do |format|
        format.html { redirect_to @thread }
        format.js { render :show }
      end
    end
    
    # PUT /threads/1/reopen
    def reopen
      security_transgression_unless @thread.can_be_edited_by?(@user)

      @thread.errors.add(:base, t('commontator.thread.errors.not_closed')) \
        unless @thread.reopen

      @show_all = true

      respond_to do |format|
        format.html { redirect_to @thread }
        format.js { render :show }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
commontator-4.10.5 app/controllers/commontator/threads_controller.rb
commontator-4.10.4 app/controllers/commontator/threads_controller.rb
commontator-4.10.3 app/controllers/commontator/threads_controller.rb
commontator-4.10.2 app/controllers/commontator/threads_controller.rb
commontator-4.10.1 app/controllers/commontator/threads_controller.rb
commontator-4.10.0 app/controllers/commontator/threads_controller.rb
commontator-4.9.0 app/controllers/commontator/threads_controller.rb