Skip to content
Snippets Groups Projects
Commit d493e9a4 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

adding learning object builder controller

parent 9e7d2917
No related branches found
No related tags found
No related merge requests found
......@@ -169,3 +169,5 @@ gem 'mimemagic'
# html screenshot
gem 'screencap'
gem 'wicked'
class LearningObjects::BuildController < ::ApplicationController
include Wicked::Wizard
before_action :set_learning_object, only: [:show, :update]
steps :upload_attachments, :select_default_attachment, :define_highlight_picture
def show
render_wizard
end
def update
@learning_object.update_attributes(params[:learning_object])
publish_learning_object if step == steps.last
render_wizard @learning_object
end
def create
@learning_object = LearningObject.create
redirect_to wizard_path(steps.first, learning_object_id: @learning_object.id)
end
private
def set_learning_object
@learning_object = LearningObject.unscoped.find(params[:learning_object_id])
end
def publish_learning_object
@learning_object.publish
@learning_object.save
end
end
\ No newline at end of file
......@@ -45,9 +45,6 @@ class LearningObjectsController < ApplicationController
end
end
def upload
end
# PATCH/PUT /learning_objects/1
# PATCH/PUT /learning_objects/1.json
def update
......@@ -121,11 +118,7 @@ class LearningObjectsController < ApplicationController
end
def success_redirect(learning_object)
id = learning_object.id
if 'Website externo' == learning_object.object_type.name
redirect_to learning_object_path(id: id), notice: 'Seu objeto foi criado e publicado com sucesso!'
else
redirect_to upload_learning_object_path(id: id), notice: 'Seu objeto foi criado! Para que ele seja publicado é necessário enviar o arquivo.'
end
#if 'Website externo' == learning_object.object_type.name
redirect_to learning_object_build_path(learning_object, :upload_attachments), notice: 'Seu objeto foi criado com sucesso!'
end
end
......@@ -18,7 +18,7 @@ class LearningObject < ActiveRecord::Base
has_attached_file :thumbnail, styles: {medium: "530x300", small: "250x140"}
validates_attachment_content_type :thumbnail, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
validates_presence_of :name, :id_dspace
validates_presence_of :name, :id_dspace, :publisher, :object_type
validates_uniqueness_of :id_dspace
searchkick language: 'brazilian', match: :word_start, searchable: [:name, :description, :author, :object_type]
......
......@@ -42,7 +42,7 @@ class LearningObjectPublisher
item = @dspace.collections.create_item(build_dspace_item(draft), id: DspaceService::TEST_COLLECTION)
# update dspace metadata
metadata = [::Dspace::Metadata.new({'key' => 'dc.title', 'value' => draft.name, 'language' => draft.language.name})]
metadata = ::Dspace::Metadata.new({'key' => 'dc.title', 'value' => draft.name, 'language' => draft.language.name})
@dspace.items.add_metadata(metadata, id: item.id)
item
......
<%= form_for @learning_object , url: wizard_path do |f| %>
<%= render 'file_upload_form' %>
<% end %>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment