Class: Lcms::Engine::Admin::ResourcesController
Constant Summary
collapse
- CREATE_TAG_KEYS =
%i(new_topic_names new_tag_names new_content_source_names
new_standard_names).freeze
- CREATE_TAG_METHODS =
{
new_topic_names: 'topic',
new_tag_names: 'tag',
new_content_source_names: 'content_source'
}.freeze
Constants included
from ViewHelper
ViewHelper::ENABLE_BASE64_CACHING
AdminController::RE_GOOGLE_FOLDER
Instance Method Summary
collapse
Methods included from ViewHelper
#add_class_for_action, #add_class_for_path, #base64_encoded_asset, #color_code, #flash_to_hash, #header_mod, #inlined_asset, #lcms_engine_url_helpers, #nav_link, #page_description, #page_og_image, #page_title, #redirect_meta_tag, #redirect_via_meta_tag, #selected_id?, #set_canonical_url, #set_page_description, #set_page_title, #strip_tags_and_squish
settings
Methods included from PathHelper
#dynamic_document_path, #dynamic_material_path, #dynamic_path
Instance Method Details
#bundle ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'app/controllers/lcms/engine/admin/resources_controller.rb', line 54
def bundle
return redirect_to lcms_engine.admin_resources_path, notice: t('.fail') unless can_bundle?(@resource)
generator = DocTemplate.config.dig('bundles', @resource.curriculum_type).constantize
generator.perform(@resource)
redirect_to lcms_engine.admin_resources_path, notice: t('.success')
end
|
#create ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/lcms/engine/admin/resources_controller.rb', line 30
def create
@resource = Resource.new(resource_params)
if @resource.save
create_tags
redirect_to lcms_engine.admin_resources_path, notice: t('.success', resource_id: @resource.id)
else
render :new
end
end
|
#destroy ⇒ Object
81
82
83
84
|
# File 'app/controllers/lcms/engine/admin/resources_controller.rb', line 81
def destroy
@resource.destroy
redirect_to lcms_engine.admin_resources_path, notice: t('.success', resource_id: @resource.id)
end
|
#edit ⇒ Object
41
|
# File 'app/controllers/lcms/engine/admin/resources_controller.rb', line 41
def edit; end
|
#export_to_lti_cc ⇒ Object
43
44
45
46
47
48
49
50
51
52
|
# File 'app/controllers/lcms/engine/admin/resources_controller.rb', line 43
def export_to_lti_cc
unless @resource.module?
return redirect_back fallback_location: admin_resources_path, notice: 'Unsupported resource type'
end
data = LtiExporter.perform @resource
filename = "#{@resource.slug.parameterize}.zip"
send_data data, filename: filename, type: 'application/zip', disposition: 'attachment'
end
|
#index ⇒ Object
19
20
21
22
23
24
|
# File 'app/controllers/lcms/engine/admin/resources_controller.rb', line 19
def index
@query = Resource.ransack(params[:q].try(:except, :grades))
resources = @query.result.includes(:standards)
resources = resources.where_grade(grade_params) if grade_params.present?
@resources = resources.order(id: :desc).paginate(page: params[:page], per_page: 15)
end
|
#new ⇒ Object
26
27
28
|
# File 'app/controllers/lcms/engine/admin/resources_controller.rb', line 26
def new
@resource = Resource.new
end
|
#update ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/controllers/lcms/engine/admin/resources_controller.rb', line 63
def update
unless Settings[:editing_enabled]
return redirect_to(lcms_engine.admin_resources_path, alert: t('admin.common.editing_disabled'))
end
create_tags
Array.wrap(create_params[:new_standard_names]).each do |std_name|
std = Standard.create_with(subject: @resource.subject).find_or_create_by!(name: std_name)
resource_params[:standard_ids] << std.id
end
if @resource.update(resource_params)
redirect_to lcms_engine.admin_resources_path, notice: t('.success', resource_id: @resource.id)
else
render :edit
end
end
|