a11yist/app/controllers/checks_controller.rb
david 4dd445be57
Some checks failed
/ Run tests (push) Successful in 7m57s
/ Run system tests (push) Failing after 4m18s
/ Build, push and deploy image (push) Failing after 59s
wip: wcag structure
2025-05-16 19:02:33 +02:00

131 lines
4.6 KiB
Ruby

# frozen_string_literal: true
class ChecksController < ApplicationController
include BackofficeMenu
before_action :set_check, only: %i[show edit update destroy]
# GET /checks or /checks.json
def index
@pagy, @checks = pagy(Check.filter_by(filter_params).order(:external_number_1, :external_number_2, :external_number_3))
end
# GET /checks/1 or /checks/1.json
def show; end
# GET /checks/new
def new
@check = Check.new
end
# GET /checks/1/edit
def edit; end
# POST /checks or /checks.json
def create
@check = Check.new(check_params)
respond_to do |format|
if @check.save
format.html do
redirect_to check_url(@check),
notice: t("scaffold.model_created_successfully", model: @check.model_name.human)
end
format.json { render :show, status: :created, location: @check }
else
flash[:alert] = t("there_were_errors", count: @check.errors.size)
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @check.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /checks/1 or /checks/1.json
def update
respond_to do |format|
if @check.update(check_params)
format.html do
redirect_to check_url(@check),
notice: t("scaffold.model_updated_successfully", model: @check.model_name.human)
end
format.json { render :show, status: :ok, location: @check }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @check.errors, status: :unprocessable_entity }
end
end
end
# DELETE /checks/1 or /checks/1.json
def destroy
@check.destroy!
respond_to do |format|
format.html do
redirect_to checks_url, notice: t("scaffold.model_destroyed_successfully", model: @check.model_name.human)
end
format.json { head :no_content }
end
end
def filter_params
@filter_params ||= params.permit(filter: [ :s, priority: [], conformity_level: [], standard_ids: [], principle_id: [], target_disabilities: [] ])[:filter] || {}
end
private
# Use callbacks to share common setup or constraints between actions.
def set_check
@check = Check.find(params[:id])
end
# Only allow a list of trusted parameters through.
def check_params
params.require(:check).permit(:guideline_id,
:number,
:name_de,
:name_en,
:standard_id,
:visual,
:auditory,
:physical,
:cognitive,
:applicable_to_app,
:applicable_to_web,
:applicable_to_analogue,
:applicable_to_document,
:applicable_to_non_web,
:external_number_1,
:external_number_2,
:external_number_3,
:external_url,
:conformity_level,
:conformity_notice_de,
:conformity_notice_en,
:priority,
:quick_criterion_de,
:quick_criterion_en,
:quick_fail_de,
:quick_fail_en,
:quick_fix_de,
:quick_fix_en,
:criterion_de,
:criterion_en,
:criterion_details_de,
:criterion_details_en,
:example_de,
:example_en,
:annotation_de,
:annotation_en,
:exemption_details_de,
:exemption_details_en,
:standard_text_de,
:standard_text_en,
:test_instructions,
:powerpoint_text_de,
:powerpoint_text_en,
:comment,
link_ids: [],
standard_ids: [])
end
end