Sha256: 6f165dc4ba316710d7cec181ff17b895fe2d8713ad2029f7f900e081652f2372

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 KB

Contents

module MongoidForums
  module Admin
    class TopicsController < BaseController
      before_filter :find_topic

      def edit
      end

      def update
        @topic.subject  = params[:topic][:subject]
        @topic.pinned   = params[:topic][:pinned]
        @topic.locked   = params[:topic][:locked]
        @topic.hidden   = params[:topic][:hidden]
        @topic.forum_id = params[:topic][:forum_id]
        if @topic.save
          flash[:notice] = t("mongoid_forums.topic.updated")
          redirect_to topic_path(@topic)
        else
          flash.alert = t("mongoid_forums.topic.not_updated")
          render :action => "edit"
        end
      end

      def toggle_hide
        @topic.toggle!(:hidden)
        flash[:notice] = t("mongoid_forums.topic.hidden.#{@topic.hidden?}")
        redirect_to topic_path(@topic)
      end

      def toggle_lock
        @topic.toggle!(:locked)
        flash[:notice] = t("mongoid_forums.topic.locked.#{@topic.locked?}")
        redirect_to topic_path(@topic)
      end

      def toggle_pin
        @topic.toggle!(:pinned)
        flash[:notice] = t("mongoid_forums.topic.pinned.#{@topic.pinned?}")
        redirect_to topic_path(@topic)
      end

      private
        def find_topic
          @topic = Topic.find(params[:format])
        end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
mongoid-forums-1.0.7 app/controllers/mongoid_forums/admin/topics_controller.rb
mongoid-forums-1.0.6 app/controllers/mongoid_forums/admin/topics_controller.rb
ack-mongoid-forums-1.0.6.1 app/controllers/mongoid_forums/admin/topics_controller.rb
ack-mongoid-forums-1.0.6 app/controllers/mongoid_forums/admin/topics_controller.rb
ack-mongoid-forums-1.0.5 app/controllers/mongoid_forums/admin/topics_controller.rb
mongoid-forums-1.0.4 app/controllers/mongoid_forums/admin/topics_controller.rb
mongoid-forums-1.0.3 app/controllers/mongoid_forums/admin/topics_controller.rb
mongoid-forums-1.0.2 app/controllers/mongoid_forums/admin/topics_controller.rb
mongoid-forums-1.0.1 app/controllers/mongoid_forums/admin/topics_controller.rb
mongoid-forums-1.0.0 app/controllers/mongoid_forums/admin/topics_controller.rb
mongoid-forums-0.0.11 app/controllers/mongoid_forums/admin/topics_controller.rb
mongoid-forums-0.0.10 app/controllers/mongoid_forums/admin/topics_controller.rb
mongoid-forums-0.0.9 app/controllers/mongoid_forums/admin/topics_controller.rb
mongoid-forums-0.0.5 app/controllers/mongoid_forums/admin/topics_controller.rb