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

refactoring learning object attachments

parent 23077147
No related branches found
No related tags found
No related merge requests found
......@@ -9,24 +9,11 @@ class LearningObject < ActiveRecord::Base
has_many :collections, through: :collection_items
has_many :complaints
has_many :attachments, class_name: 'LearningObject::Attachment'
belongs_to :publisher, polymorphic: true
def categories
get_metadata_value_of 'dc.subject.category'
end
def liked?(user)
return false if likes.where(user: user).blank?
true
end
def like(user)
Like.create(user: user, likeable: self)
end
def dislike(user)
Like.where(user: user, likeable: self).destroy_all
end
end
class LearningObject::Attachment
include ActiveModel::Model
#this attributes mirror Dspace bitstream values
attr_accessor :id, :name, :link, :retrieve_link, :description, :format, :mime_type, :size, :bundle_name
class LearningObject::Attachment < ActiveRecord::Base
belongs_to :learning_object
end
class CreateLearningObjectAttachments < ActiveRecord::Migration
def change
create_table :learning_object_attachments do |t|
t.string :name
t.string :link
t.string :retrieve_link
t.text :description
t.string :format
t.string :mime_type
t.integer :size
t.string :bundle_name
t.belongs_to :learning_object, index: true
t.timestamps null: false
end
add_foreign_key :learning_object_attachments, :learning_objects
end
end
class RemoveBitstreamsColumnFromLearningObjects < ActiveRecord::Migration
def change
remove_column :learning_objects, :bitstreams
end
end
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