# 2019-01-26 (ADH): # # Very simplistic quick-and-dirty implementation; Blacklist has just one # row, which contains a text field of newline separated items processed # by Ruby when checking a post. Not efficient but sufficient for now. # class BlacklistController < ApplicationController @@hubssolib_permissions = HubSsoLib::Permissions.new({ :show => [ :admin, :webmaster ], :new => [ :admin, :webmaster ], :create => [ :admin, :webmaster ], :edit => [ :admin, :webmaster ], :update => [ :admin, :webmaster ], :destroy => [ :admin, :webmaster ], }) public def BlacklistController.hubssolib_permissions @@hubssolib_permissions end def show @blacklist = Blacklist.find( :first ) end def new @blacklist = Blacklist.new end def create set_list_to( params[ :blacklist ] ) flash[ :notice ] = 'Blacklist created' redirect_to( blacklist_path() ) end def edit @blacklist = Blacklist.find( :first ) end def update set_list_to( params[ :blacklist ] ) flash[ :notice ] = 'Blacklist updated' redirect_to( blacklist_path() ) end def destroy set_list_to( { :list => '', :title_list => '' } ) flash[ :notice ] = 'Blacklist emptied' redirect_to( blacklist_path() ) end private def set_list_to( options ) list = options[ :list ] title_list = options[ :title_list ] blacklist = if Blacklist.count > 0 Blacklist.find(:first) else Blacklist.new end blacklist.list = list blacklist.title_list = title_list blacklist.save! end end