Skip to content
Snippets Groups Projects

Add Admin UI

Merged Teal requested to merge admin-ui into main
13 files
+ 748
0
Compare changes
  • Side-by-side
  • Inline
Files
13
module Admin
class ConferencesController < ApplicationController
before_action :authenticate_user!
before_action :authorize_permission
before_action :set_conference, only: [ :edit, :update, :destroy ]
def index
@conferences = Conference.all
end
def new
@conference = Conference.new
end
def create
@conference = Conference.new(conference_params)
if @conference.save
redirect_to admin_conferences_path, notice: "Conference was successfully created."
else
render :new, status: :unprocessable_entity
end
end
def edit
end
def update
if @conference.update(conference_params)
redirect_to admin_conferences_path, notice: "Conference was successfully updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@conference.destroy
redirect_to admin_conferences_path, notice: "Conference was successfully deleted."
end
private
def authorize_permission
super("manage_conferences")
end
def set_conference
@conference = Conference.find_by(slug: params[:slug])
end
def conference_params
all_params = params.require(:conference).permit(:name, :slug, :starts_at, :ends_at, :url, :time_zone, :import_job_class).to_h
data_hash = @conference&.data&.dup || {}
if params[:data].present?
params[:data].each do |key, value|
data_hash[key] = value.presence
end
end
if params[:custom_field_keys].present? && params[:custom_field_values].present?
keys = params[:custom_field_keys]
values = params[:custom_field_values]
keys.each_with_index do |key, index|
next if key.blank?
data_hash[key] = values[index].presence
end
end
all_params[:data] = data_hash
all_params
end
end
end
Loading