Skip to content
Snippets Groups Projects

Improve conference and import management

17 files
+ 673
18
Compare changes
  • Side-by-side
  • Inline

Files

@@ -2,7 +2,7 @@ module Admin
class ConferencesController < ApplicationController
before_action :authenticate_user!
before_action :authorize_permission
before_action :set_conference, only: [ :edit, :update, :destroy ]
before_action :set_conference, except: [ :index, :new, :create ]
def index
@conferences = Conference.all
@@ -16,7 +16,8 @@ module Admin
@conference = Conference.new(conference_params)
if @conference.save
redirect_to admin_conferences_path, notice: "Conference was successfully created."
FetchConferenceDataJob.perform_later(@conference.slug)
redirect_to import_progress_admin_conference_path(@conference), notice: "Conference was successfully created and data import has started."
else
render :new, status: :unprocessable_entity
end
@@ -38,6 +39,47 @@ module Admin
redirect_to admin_conferences_path, notice: "Conference was successfully deleted."
end
def import_progress
end
def import_status
render json: {
status: @conference.import_status,
started_at: @conference.last_import_started_at,
completed_at: @conference.last_import_completed_at,
error_summary: @conference.import_error_summary,
has_error: @conference.last_import_error.present?
}
end
def import_error
render layout: false if request.xhr?
end
def import_history
@import_histories = @conference.import_histories.order(created_at: :desc).limit(20)
end
def retry_import
FetchConferenceDataJob.perform_later(@conference.slug)
redirect_to import_progress_admin_conference_path(@conference), notice: "Data import has been started."
end
def select_relevant_stages
@stages = @conference.stages
end
def update_relevant_stages
@conference.relevant_stage_ids = params[:conference][:relevant_stage_ids]
if @conference.save
redirect_to admin_conferences_path, notice: "Relevant stages updated successfully."
else
@stages = @conference.stages
render :select_relevant_stages
end
end
private
def authorize_permission
Loading