From 699c8f1eafa0a4c9b64f690241008c723ba15791 Mon Sep 17 00:00:00 2001 From: ArtOfCode- <hello@artofcode.co.uk> Date: Fri, 8 May 2020 21:20:27 +0100 Subject: [PATCH] Complain about trust level before posting --- app/controllers/posts_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index c95a3fc57..465447125 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -15,6 +15,10 @@ class PostsController < ApplicationController def new @category = Category.find(params[:category_id]) @post = Post.new(category: @category, post_type_id: params[:post_type_id]) + if @category.min_trust_level.present? && @category.min_trust_level > current_user.trust_level + flash[:danger] = "You don't have a high enough trust level to post in the #{@category.name} category." + redirect_back fallback_location: root_path + end end def create -- GitLab