fixing the forms again

This commit is contained in:
2023-01-21 22:43:39 +02:00
parent 6852883273
commit accb668267
6 changed files with 23 additions and 7 deletions

View File

@ -1,14 +1,14 @@
module Merged
class FormController < MergedController
class FormController < ::ApplicationController
def sendit
def post
@section = Section.find( params[:section_id] )
@errors = { }
return if bot_alert
check_maths
verify_data
if( @errors.length > 0)
render :form
render "merged/form/form"
else
dispatch_form_data( )
redirect_to main_app.root_url , notice: @section.option("ok_message")
@ -36,7 +36,6 @@ module Merged
end
def check_option(card , value)
return unless value.blank?
puts "Checking #{card.header} #{value}"
compulsory = card.option("compulsory") != "no"
return unless compulsory
# check different types
@ -48,7 +47,7 @@ module Merged
def check_maths
key = params[:bot_fudder].to_i / 2
if( (2*key + 1).to_s != params[:challenge])
@errors[:challenge] = "Check the maths #{params[:challenge]}"
@errors[:challenge] = "Check the anti bot maths, it wasn't: #{params[:challenge]}"
end
end