Sha256: 93b2592499b7b126c11b118927501bc1b5fa59656e1e507f48cf73c359f129aa

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

module Thredded
  class PrivateTopicsController < Thredded::ApplicationController
    before_filter :ensure_messageboard_exists

    def index
      if cannot? :read, messageboard
        error = 'You are not authorized access to this messageboard.'
        redirect_to default_home, flash: { error: error }
      else
        @private_topics = private_topics
      end
    end

    def new
      @private_topic = messageboard.private_topics.build
      @private_topic.posts.build(filter: current_user.try(:post_filter))

      unless can? :create, @private_topic
        error = 'Sorry, you are not authorized to post on this messageboard.'
        redirect_to messageboard_topics_url(messageboard),
          flash: { error: error }
      end
    end

    def create
      params[:topic][:user_id] << current_user.id
      merge_default_topics_params
      @private_topic = PrivateTopic.create(params[:topic])
      redirect_to messageboard_topics_url(messageboard)
    end

    def private_topics
      PrivateTopic
        .for_messageboard(messageboard)
        .including_roles_for(current_user)
        .for_user(current_user)
        .order_by_stuck_and_updated_time
        .on_page(params[:page])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thredded-0.0.7 app/controllers/thredded/private_topics_controller.rb
thredded-0.0.6 app/controllers/thredded/private_topics_controller.rb
thredded-0.0.5 app/controllers/thredded/private_topics_controller.rb
thredded-0.0.4 app/controllers/thredded/private_topics_controller.rb