diff --git a/Gemfile b/Gemfile index f3fe2e957ca953bebd59674889e0014480109ec6..4a21fee1ff475a319cb6afc6b8c8bcaa5fcf2c04 100644 --- a/Gemfile +++ b/Gemfile @@ -90,8 +90,18 @@ gem 'stackprof' gem 'font-awesome-rails' group :development do + gem 'annotate' + gem 'immigrant' + # Generate ER Diagram from database (use: rake erd) + # Github Page: https://github.com/voormedia/rails-erd + gem "rails-erd" + + # Manage the database application (use: localhost:3000/rails/db) + # Github Page: https://github.com/igorkasyanchuk/rails_db + gem 'rails_db' + # mute assets in log gem 'quiet_assets' diff --git a/app/controllers/chunks_controller.rb b/app/controllers/chunks_controller.rb index be663c6f83cc362d0027c3bd32f31a05e7120ccb..460eee164e8ffd09737ccad7e0c45e3fc612a20a 100644 --- a/app/controllers/chunks_controller.rb +++ b/app/controllers/chunks_controller.rb @@ -113,7 +113,9 @@ class ChunksController < ApplicationController end def valid_mime_type? - @learning_object.object_type.mime_types.map(&:extension).include? resumable_file_extension + mime_types = @learning_object.object_type.mime_types.map(&:extension) + return true if mime_types.empty? + mime_types.include? resumable_file_extension end # Never trust parameters from the scary internet, only allow the white list through. def chunks_params diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index fd8ca3a098e7745f3b1dbaf67f006f3e7cdaed41..f04f91b3fb7d8137cfc9f0a3a49a11383f99ff34 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -39,7 +39,7 @@ class CollectionsController < ApplicationController check_collection_privacy! @collection @user = @collection.owner - @own = user_signed_in? ? @collection.owner?(current_user) : false + @own = user_signed_in? ? @collection.user_own?(current_user) : false end @reviews = Review.includes(:user).where(reviewable: @collection) @@ -56,7 +56,7 @@ class CollectionsController < ApplicationController # POST /collections.json def create @collection = Collection.new(collection_params) - @collection.owner = current_user if collection_params[:owner].blank? + @collection.owner = params[:collection][:owner].blank? ? current_user : Institution.find(params[:collection][:owner]) respond_to do |format| if @collection.save @@ -95,7 +95,7 @@ class CollectionsController < ApplicationController # list all @collection = nil if @collection == 'all' - @collections = Collection.from_user(current_user) + @collections = current_user.associated_collections @collections.select! { |c| c.id != @collection.id } unless @collection.blank? unless params[:type].blank? @@ -117,14 +117,14 @@ class CollectionsController < ApplicationController def me @new_collection = Collection.new - @publishers = publishers_for current_user + @publishers = current_user.institutions @bookmark = (current_user.bookmarks.nil? || current_user.bookmarks.first.nil?) ? [] : [current_user.bookmarks.first] @groups = [ CollectionsGroup.new(title: 'Coleções Automáticas', collections: @bookmark ), CollectionsGroup.new(title: 'Coleções Adicionadas', - collections: current_user.collections.includes(:owner)) + collections: current_user.associated_collections) ] end @@ -132,12 +132,12 @@ class CollectionsController < ApplicationController # POST /collections/1/learning_object def add_learning_object @collections.each do |collection| - if collection.owner?(current_user) - @learning_objects.each do |learning_object| - collection.learning_objects << learning_object - end - collection.save + next unless collection.user_own?(current_user) + + @learning_objects.each do |learning_object| + collection.learning_objects << learning_object end + collection.save end render json: { status: true } if request.xhr? @@ -146,12 +146,12 @@ class CollectionsController < ApplicationController # DELETE /collections/1/learning_object def remove_learning_object @collections.each do |collection| - if collection.owner?(current_user) - @learning_objects.each do |learning_object| - collection.learning_objects.destroy(learning_object) - end - collection.save + next unless collection.user_own?(current_user) + + @learning_objects.each do |learning_object| + collection.learning_objects.destroy(learning_object) end + collection.save end render json: { status: true } if request.xhr? @@ -169,8 +169,8 @@ class CollectionsController < ApplicationController private def check_collection_privacy!(collection) - if collection.private? - redirect_to :root, notice: 'Está é uma coleção privada.' unless collection.owner?(current_user) + if collection.private? && !collection.user_own?(current_user) + redirect_to :root, notice: 'Está é uma coleção privada.' end end @@ -179,7 +179,7 @@ class CollectionsController < ApplicationController end def set_collections - if params[:id] == "all" || params[:id].blank? + if params[:id] == 'all' || params[:id].blank? @collections = ['all'] else @collections = (params[:id].class == String) ? [Collection.find(params[:id])] : params[:id].map{|id| Collection.find id} @@ -195,17 +195,9 @@ class CollectionsController < ApplicationController end end - def publishers_for(user) - user_new = Institution.new() - user_new.id = user.id - user_new.name = user.name - - [user_new] + user.institutions - end - # Never trust parameters from the scary internet, only allow the white list through. def collection_params - params.require(:collection).permit(:name, :description, :owner, learning_objects: []) + params.require(:collection).permit(:name, :description, learning_objects: []) end def user_not_authorized diff --git a/app/controllers/learning_objects_controller.rb b/app/controllers/learning_objects_controller.rb index 0f40b94dcad9e3e51fe9dd8039fee346e8ca4341..7af866f1a2d40a4ef5525bb0c81d5c40f36d75b6 100644 --- a/app/controllers/learning_objects_controller.rb +++ b/app/controllers/learning_objects_controller.rb @@ -64,7 +64,7 @@ class LearningObjectsController < ApplicationController LearningObject.destroy @learning_object respond_to do |format| - format.html { redirect_to learning_objects_url, notice: t('activerecord.attributes.learning_object.destroy.notice.successfully_destroy') } + format.html { redirect_to user_path(current_user), notice: t('activerecord.attributes.learning_object.destroy.notice.successfully_destroy') } end end diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index de19b6ff8bbc4a8c49a829b0a38605bfebd744ad..548b3ddc2a2fc9100f01475449af7ea34ba4aeaa 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: bookmarks +# +# id :integer not null, primary key +# user_id :integer +# bookmarkable_id :integer +# bookmarkable_type :string +# created_at :datetime not null +# updated_at :datetime not null +# + class Bookmark < ActiveRecord::Base belongs_to :user, counter_cache: true belongs_to :bookmarkable, polymorphic: true diff --git a/app/models/carousel.rb b/app/models/carousel.rb index e8a81d995ee3d9d870b2e3915ac5032f5cc35ab6..e44675b5c95350bc06b265bc90645b9c75812bd9 100644 --- a/app/models/carousel.rb +++ b/app/models/carousel.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: carousels +# +# id :integer not null, primary key +# title :string +# url :text +# created_at :datetime not null +# updated_at :datetime not null +# image_file_name :string +# image_content_type :string +# image_file_size :integer +# image_updated_at :datetime +# + class Carousel < ActiveRecord::Base has_attached_file :image, styles: { larger: "600x600>", diff --git a/app/models/collection.rb b/app/models/collection.rb index 1eab50e15dea07141b6e6ead2f94fa1a39ccafc2..08597902e1a14126efc9559135f4f2443787f8db 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -1,3 +1,27 @@ +# == Schema Information +# +# Table name: collections +# +# id :integer not null, primary key +# name :string +# description :text +# privacy :string default("private") +# owner_id :integer +# owner_type :string +# created_at :datetime not null +# updated_at :datetime not null +# views_count :integer default("0") +# downloads_count :integer default("0") +# likes_count :integer default("0") +# shares_count :integer default("0") +# score :float default("0.0") +# follows_count :integer default("0") +# thumbnail_file_name :string +# thumbnail_content_type :string +# thumbnail_file_size :integer +# thumbnail_updated_at :datetime +# + class Collection < ActiveRecord::Base include Reviewable include Sociable @@ -34,6 +58,11 @@ class Collection < ActiveRecord::Base owner == candidate end + def user_own?(user) + return false unless user.is_a? User + owner?(user) || owner.users.include?(user) + end + def private? privacy == 'private' end diff --git a/app/models/collection_item.rb b/app/models/collection_item.rb index 5aba4c6d945baf546d28cde15fd3060dbd811353..aa4659532dd1ae8cf63b4b06148565f088bfebf5 100644 --- a/app/models/collection_item.rb +++ b/app/models/collection_item.rb @@ -1,3 +1,16 @@ +# == Schema Information +# +# Table name: collection_items +# +# id :integer not null, primary key +# collectionable_id :integer +# collectionable_type :string +# collection_id :integer +# order :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class CollectionItem < ActiveRecord::Base belongs_to :collection diff --git a/app/models/complaint.rb b/app/models/complaint.rb index 7011367cc74df24a87e8392141dc69036a8c4f9c..a8f3567cf163bdaec30b13677476e16385875969 100644 --- a/app/models/complaint.rb +++ b/app/models/complaint.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: complaints +# +# id :integer not null, primary key +# description :text +# user_id :integer +# complaintable_id :integer +# complaintable_type :string +# complaint_reason_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class Complaint < ActiveRecord::Base belongs_to :complaint_reason belongs_to :user diff --git a/app/models/complaint_reason.rb b/app/models/complaint_reason.rb index 9994f39bb230df80d872fd29d390e2795c1f3b07..26ee8777f0c3631591f4d29ba5a7b34da7cd51e4 100644 --- a/app/models/complaint_reason.rb +++ b/app/models/complaint_reason.rb @@ -1,3 +1,13 @@ +# == Schema Information +# +# Table name: complaint_reasons +# +# id :integer not null, primary key +# reason :text +# created_at :datetime not null +# updated_at :datetime not null +# + class ComplaintReason < ActiveRecord::Base has_many :complaints diff --git a/app/models/download.rb b/app/models/download.rb index 9dc3563f6892601b3f0bdb7d6a6c7bc0da85dc33..b2687da8dd1917b887c8de3331ecb2f9625a6b8d 100644 --- a/app/models/download.rb +++ b/app/models/download.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: downloads +# +# id :integer not null, primary key +# downloadable_id :integer +# downloadable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class Download < ActiveRecord::Base belongs_to :downloadable, polymorphic: true, counter_cache: true belongs_to :user diff --git a/app/models/follow.rb b/app/models/follow.rb index 44c4ad86729a2d6ce6b4210dbaa852a545a1db62..59d125fb24de39aae8821431e1bb5045a2a8125a 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: follows +# +# id :integer not null, primary key +# followable_id :integer +# followable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class Follow < ActiveRecord::Base belongs_to :followable, polymorphic: true, counter_cache: true belongs_to :user diff --git a/app/models/institution.rb b/app/models/institution.rb index e474c9a0c91834ec8a11d6422d4ea731e6d2d155..5903d6b3a4985713ebb7e7f3097828eebed73dd6 100644 --- a/app/models/institution.rb +++ b/app/models/institution.rb @@ -1,7 +1,22 @@ +# == Schema Information +# +# Table name: institutions +# +# id :integer not null, primary key +# name :string +# address :string +# city :string +# country :string +# description :text +# created_at :datetime not null +# updated_at :datetime not null +# + class Institution < ActiveRecord::Base has_and_belongs_to_many :users has_many :learning_objects, as: :publisher + has_many :collections, as: :owner validates_presence_of :name end diff --git a/app/models/language.rb b/app/models/language.rb index f95d7ed7cc5cb1785ffd3d57624c525bef846aac..b9370bc7df571cd556d97bc011b92f7d6a453fe5 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: languages +# +# id :integer not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# code :string +# + class Language < ActiveRecord::Base has_many :learning_objects diff --git a/app/models/learning_object.rb b/app/models/learning_object.rb index ee386fd9f997ade131abfb6971752707ba8c4d8e..7e1e9811450453670438a88700045066f394304a 100644 --- a/app/models/learning_object.rb +++ b/app/models/learning_object.rb @@ -1,3 +1,35 @@ +# == Schema Information +# +# Table name: learning_objects +# +# id :integer not null, primary key +# id_dspace :integer +# name :string +# author :string +# description :text +# published_at :datetime +# score :float default("0.0") +# school_level :integer +# metadata :jsonb default("{}") +# keywords :text +# publisher_id :integer +# publisher_type :string +# language_id :integer +# object_type_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# views_count :integer default("0") +# downloads_count :integer default("0") +# likes_count :integer default("0") +# shares_count :integer default("0") +# state :string default("published") +# thumbnail_file_name :string +# thumbnail_content_type :string +# thumbnail_file_size :integer +# thumbnail_updated_at :datetime +# attachment_id :integer +# + class LearningObject < ActiveRecord::Base include Metadatable include Reviewable diff --git a/app/models/learning_object/attachment.rb b/app/models/learning_object/attachment.rb index 168e5f5cc020249f562b940b7248e66c10910813..e1435b65879cf2002be0e7cddbce7afc0ab675e8 100644 --- a/app/models/learning_object/attachment.rb +++ b/app/models/learning_object/attachment.rb @@ -1,3 +1,27 @@ +# == Schema Information +# +# Table name: learning_object_attachments +# +# id :integer not null, primary key +# name :string +# link :string +# retrieve_link :string +# description :text +# format :string +# mime_type :string +# size :integer +# bundle_name :string +# learning_object_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# id_dspace :integer +# thumbnail_file_name :string +# thumbnail_content_type :string +# thumbnail_file_size :integer +# thumbnail_updated_at :datetime +# cache_link :string +# + class LearningObject::Attachment < ActiveRecord::Base include ::Thumbnailable belongs_to :learning_object diff --git a/app/models/learning_object/draft.rb b/app/models/learning_object/draft.rb index 36c59c60019d40172a1b44314d67ac5f7f035b1b..e5bd5c94159956ad823a789d7e09e9d8478c675b 100644 --- a/app/models/learning_object/draft.rb +++ b/app/models/learning_object/draft.rb @@ -1,3 +1,35 @@ +# == Schema Information +# +# Table name: learning_objects +# +# id :integer not null, primary key +# id_dspace :integer +# name :string +# author :string +# description :text +# published_at :datetime +# score :float default("0.0") +# school_level :integer +# metadata :jsonb default("{}") +# keywords :text +# publisher_id :integer +# publisher_type :string +# language_id :integer +# object_type_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# views_count :integer default("0") +# downloads_count :integer default("0") +# likes_count :integer default("0") +# shares_count :integer default("0") +# state :string default("published") +# thumbnail_file_name :string +# thumbnail_content_type :string +# thumbnail_file_size :integer +# thumbnail_updated_at :datetime +# attachment_id :integer +# + class LearningObject::Draft < LearningObject ##overwrites initialize method to force @state value as draft @@ -6,4 +38,4 @@ class LearningObject::Draft < LearningObject @state = 'draft' end -end \ No newline at end of file +end diff --git a/app/models/like.rb b/app/models/like.rb index 112b6063094f506bd10715eb2be570c4a76ebfc5..f30976e61fda0f28b7b182120c37628bddc61488 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: likes +# +# id :integer not null, primary key +# likeable_id :integer +# likeable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class Like < ActiveRecord::Base belongs_to :likeable, polymorphic: true, counter_cache: true belongs_to :user diff --git a/app/models/mime_type.rb b/app/models/mime_type.rb index 4aa9f72fc04926d9e63f56e978b7ca7e57644311..6c6baa1acb6a9d75f3d582c7c937fd6342d82393 100644 --- a/app/models/mime_type.rb +++ b/app/models/mime_type.rb @@ -1,3 +1,12 @@ +# == Schema Information +# +# Table name: mime_types +# +# id :integer not null, primary key +# extension :string +# mime_type :string +# + class MimeType < ActiveRecord::Base has_and_belongs_to_many :object_types end diff --git a/app/models/object_type.rb b/app/models/object_type.rb index 0aedd137ed47c2fdb9b1b9dbb8a797c498a5bfa0..1153bd9cbb4755e792bd3ecf60ee2bdf2c85757f 100644 --- a/app/models/object_type.rb +++ b/app/models/object_type.rb @@ -1,3 +1,11 @@ +# == Schema Information +# +# Table name: object_types +# +# id :integer not null, primary key +# name :string +# + class ObjectType < ActiveRecord::Base has_many :learning_objects has_and_belongs_to_many :mime_types diff --git a/app/models/rate.rb b/app/models/rate.rb index 88ebc8b782935ed460d2b177b626f219709289e9..b2bc26f33b26b6cc04465c63a378b63fffa70d82 100644 --- a/app/models/rate.rb +++ b/app/models/rate.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: rates +# +# id :integer not null, primary key +# approves :boolean +# user_id :integer +# review_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class Rate < ActiveRecord::Base belongs_to :user belongs_to :review diff --git a/app/models/rating.rb b/app/models/rating.rb index a8a63a00385218a107c257a88a15f3509be78bbb..a28b192f5a8b3f440154cbde5ab075df466c7cfd 100644 --- a/app/models/rating.rb +++ b/app/models/rating.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: ratings +# +# id :integer not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# description :string +# + class Rating < ActiveRecord::Base has_many :review_ratings has_many :reviews, through: :review_ratings diff --git a/app/models/review.rb b/app/models/review.rb index 8a70f670021e8446a4718b1596f3b9313d2f585f..9567a9b9e797fb9ac83ec9cb6337d015efd7d3fb 100644 --- a/app/models/review.rb +++ b/app/models/review.rb @@ -1,3 +1,20 @@ +# == Schema Information +# +# Table name: reviews +# +# id :integer not null, primary key +# name :string +# description :text +# pros :text +# cons :text +# reviewable_id :integer +# reviewable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# rates_count :integer default("0") +# + class Review < ActiveRecord::Base belongs_to :reviewable, polymorphic: true belongs_to :user diff --git a/app/models/review_rating.rb b/app/models/review_rating.rb index a554ef971c3b917c6054f45aa11e9d1f469081e6..3b5cab5cc218c5c7feeb098a2eec2e569ef8f4e5 100644 --- a/app/models/review_rating.rb +++ b/app/models/review_rating.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: review_ratings +# +# id :integer not null, primary key +# review_id :integer +# rating_id :integer +# value :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class ReviewRating < ActiveRecord::Base belongs_to :review belongs_to :rating diff --git a/app/models/role.rb b/app/models/role.rb index 21202003872571477b285008b79f74aee0568487..7302eac54aa9e3b8e4e6935fba25e632cd515a97 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: roles +# +# id :integer not null, primary key +# name :string +# description :text +# created_at :datetime not null +# updated_at :datetime not null +# + class Role < ActiveRecord::Base has_and_belongs_to_many :users diff --git a/app/models/score.rb b/app/models/score.rb index aea63b8f9536aa2bb9dd7b31480dded369cc303d..d2031038913696ba2cc061971ee7587b2ee04d26 100644 --- a/app/models/score.rb +++ b/app/models/score.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: scores +# +# id :integer not null, primary key +# name :string +# code :string +# weight :float +# active :boolean default("true") +# created_at :datetime not null +# updated_at :datetime not null +# score_type :string default("{}"), is an Array +# + class Score < ActiveRecord::Base has_many :score_user_categories has_many :user_categories, through: :score_user_categories diff --git a/app/models/score_user_category.rb b/app/models/score_user_category.rb index b7b864266ac4a3dc5e8c7806c96b0e8abf353b21..f249ec23cf02005b4c2c68777e50cd83ab627be0 100644 --- a/app/models/score_user_category.rb +++ b/app/models/score_user_category.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: score_user_categories +# +# id :integer not null, primary key +# score_id :integer +# user_category_id :integer +# value :float +# created_at :datetime not null +# updated_at :datetime not null +# + class ScoreUserCategory < ActiveRecord::Base belongs_to :score belongs_to :user_category diff --git a/app/models/share.rb b/app/models/share.rb index f40e60fc467ad03b92594cec226f02505bd03844..67e365cf005921d7baa1e30df9721d1bbdbe87f4 100644 --- a/app/models/share.rb +++ b/app/models/share.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: shares +# +# id :integer not null, primary key +# shareable_id :integer +# shareable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class Share < ActiveRecord::Base belongs_to :shareable, polymorphic: true, counter_cache: true belongs_to :user diff --git a/app/models/topic.rb b/app/models/topic.rb index d7a6326ab604ed04b77e7521fa20b8da7ac50353..3b0013dd40e0b69326e4ad39f02a8f333a9482ce 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# default :boolean default("false") +# + class Topic < ActiveRecord::Base has_and_belongs_to_many :learning_objects diff --git a/app/models/topic_highlight.rb b/app/models/topic_highlight.rb index 1fba48bccbc578e378a41ed4271e51f32a56a9a3..e59a26428f7b5e5d117a0a9bd4a7bc38db202819 100644 --- a/app/models/topic_highlight.rb +++ b/app/models/topic_highlight.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topic_highlights +# +# id :integer not null, primary key +# topic_id :integer +# learning_object_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class TopicHighlight < ActiveRecord::Base belongs_to :topic belongs_to :learning_object diff --git a/app/models/topic_relationship.rb b/app/models/topic_relationship.rb index c5007d12988ade58cc2cd036f90fcd1aabed0b71..82fd29386160749bbb05bac1999d803edf661208 100644 --- a/app/models/topic_relationship.rb +++ b/app/models/topic_relationship.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topic_relationships +# +# id :integer not null, primary key +# parent_id :integer +# child_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class TopicRelationship < ActiveRecord::Base belongs_to :parent, class_name: 'Topic' belongs_to :child, class_name: 'Topic' diff --git a/app/models/user.rb b/app/models/user.rb index 1c32e107597ae2fdf4f9d2005552d6fa5b8b6a36..0b8815ec4a7125a1bdbae4efda920d91a9ff7dd3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,38 @@ +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# email :string default(""), not null +# encrypted_password :string default(""), not null +# reset_password_token :string +# reset_password_sent_at :datetime +# remember_created_at :datetime +# sign_in_count :integer default("0"), not null +# current_sign_in_at :datetime +# last_sign_in_at :datetime +# current_sign_in_ip :string +# last_sign_in_ip :string +# created_at :datetime not null +# updated_at :datetime not null +# provider :string default("email"), not null +# uid :string default(""), not null +# confirmation_token :string +# confirmed_at :datetime +# confirmation_sent_at :datetime +# unconfirmed_email :string +# tokens :text +# name :string +# avatar_file_name :string +# avatar_content_type :string +# avatar_file_size :integer +# avatar_updated_at :datetime +# bookmarks_count :integer default("0") +# user_category_id :integer +# score :float default("0.0") +# follows_count :integer default("0") +# + class User < ActiveRecord::Base include Followable include Reputationable @@ -54,6 +89,11 @@ class User < ActiveRecord::Base false end + def associated_collections + c = collections.blank? ? [] : collections.includes(:owner) + c + Collection.where(owner: institutions).includes(:owner) + end + private def default_role diff --git a/app/models/user_category.rb b/app/models/user_category.rb index 845710a3415b9b79ad82c6b3ce182ade35e58dc2..d4603f14fb70376f16fff61bcb8f29834a7e7254 100644 --- a/app/models/user_category.rb +++ b/app/models/user_category.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: user_categories +# +# id :integer not null, primary key +# name :string +# reference :float +# created_at :datetime not null +# updated_at :datetime not null +# + class UserCategory < ActiveRecord::Base has_many :score_user_categories has_many :scores, through: :score_user_categories diff --git a/app/models/view.rb b/app/models/view.rb index 53cd81b0a71a4ace75ea2ca1eb893440ba965f87..72579609f1fc97f0a61283772ed71c0789c9ee46 100644 --- a/app/models/view.rb +++ b/app/models/view.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: views +# +# id :integer not null, primary key +# viewable_id :integer +# viewable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + class View < ActiveRecord::Base belongs_to :viewable, polymorphic: true, counter_cache: true belongs_to :user diff --git a/app/views/collections/_form.html.erb b/app/views/collections/_form.html.erb index c96b8ab2e320f4f1bd10eb5d4216f59732869070..003e6bd36a168a5835c4f0c839bc3b1c35c3803b 100644 --- a/app/views/collections/_form.html.erb +++ b/app/views/collections/_form.html.erb @@ -3,10 +3,10 @@ <%= f.label :name, 'Nome' %> <%= f.text_field :name, required: true, style: 'width: 250px;' %> - <% if publishers.length > 1 %> + <% unless publishers.blank? %> <br><br> <label>Criar como:</label> - <%= f.collection_select :owner, publishers, :id, :name %> + <%= f.collection_select :owner, publishers, :id, :name, prompt: "Usuário" %> <br><br> <% end %> diff --git a/app/views/learning_objects/show.html.erb b/app/views/learning_objects/show.html.erb index 53b8448cecb3a6ffc12685586951dbd65e338cbd..6d6dd00eb9dfb5a583f8ee2adac6b94dea90872b 100644 --- a/app/views/learning_objects/show.html.erb +++ b/app/views/learning_objects/show.html.erb @@ -1,7 +1,7 @@ <% content_for(:body_attributes) do %>data-no-turbolink="true"<% end %> <% if @learning_object.state == 'suspended' %> - <h2> Este conteúdo está suspenso! </h2> + <h2> Este conteúdo está suspenso! </h2> <% end %> <div class="row learning-object"> @@ -16,7 +16,7 @@ <br/><br/> <h2 class="title"><%= learning_object_title(@learning_object) %></h2> <% unless @learning_object.description.nil? %> - <p class="description"><%= @learning_object.description %></p> + <p class="description"><%= @learning_object.description %></p> <% end %> <span class="category"><%= ("Em " + show_categories(@learning_object.categories)) unless @learning_object.categories.nil? %></span> </div> @@ -25,27 +25,26 @@ <div class="col-md-5"> <div class="rightbar"> <% unless @learning_object.author.blank? %> - <div class="media"> - <div class="media-left"> - <a href="#"><img class="user-image-small" src="<%#= current_user.avatar.url(:thumb) %><%= asset_path('user-anon.png')%>" alt="Foto do usuário"/></a> - </div> - <div class="media-body"> - <h5>Autor</h5> - <h3><%= @learning_object.author %></h3> - </div> - </div> + <div class="media"> + <div class="media-left"> + <a href="#"><img class="user-image-small" src="<%#= current_user.avatar.url(:thumb) %><%= asset_path('user-anon.png')%>" alt="Foto do usuário"/></a> + </div> + <div class="media-body"> + <h5>Autor</h5> + <h3><%= @learning_object.author %></h3> + </div> <% end %> <% unless @learning_object.publisher.nil? %> - <div class="media"> - <div class="media-left"> - <a href="#"><img class="user-image-small" src="<%#= current_user.avatar.url(:thumb) %><%= asset_path('user-anon.png')%>" alt="Foto do usuário"/></a> - </div> - <div class="media-body"> - <% publisher_type = @learning_object.publisher.class %> - <h5><%= publisher_type == User ? 'Adicionado por' : 'Origem'%></h5> - <h3 class="media-heading"><%= @learning_object.publisher.name %></h3> + <div class="media"> + <div class="media-left"> + <a href="#"><img class="user-image-small" src="<%#= current_user.avatar.url(:thumb) %><%= asset_path('user-anon.png')%>" alt="Foto do usuário"/></a> + </div> + <div class="media-body"> + <% publisher_type = @learning_object.publisher.class %> + <h5><%= publisher_type == User ? 'Adicionado por' : 'Origem'%></h5> + <h3 class="media-heading"><%= @learning_object.publisher.name %></h3> + </div> </div> - </div> <% end %> <div class="panel panel-default"> <h3>Detalhes do Objeto</h3> @@ -58,66 +57,67 @@ </div> <div class="rating-panel"> <% if user_signed_in? %> - <div class="actions"> - <div class="action download"> + <div class="actions"> + <div class="action download"> <%= link_to download_learning_object_path, class: 'download btn btn-success', target: "_blank" do %> - <i class="fa fa-download"></i>FAZER DOWNLOAD + <i class="fa fa-download"></i>FAZER DOWNLOAD <%end%> - </div> - <div class="action"> - <%= link_to like_learning_object_path(id: @learning_object.id), class: 'vote btn btn-primary',method: :post, remote: true do %> - <% if @liked %> - <%= image_tag "icons/btn_like_down.png", alt: "Descurtir" %> - <% else %> - <%= image_tag "icons/btn_like_up.png", alt: "Curtir" %> - <% end %> - <% end %> - </div> - <div class="action"> - <a tabindex="0" class="add-to-collection btn btn-primary" role="button" title="Adicionar as coleções" data-loid="<%= @learning_object.id %>"> - <%= image_tag "icons/btn_add.png", alt: "Adicionar à coleção" %> - </a> - </div> - <div class="action"> - <%= link_to bookmark_add_path(id: @learning_object.id, type: @learning_object.class.to_s), class:"btn btn-primary bookmark", title: "Adicionar aos favoritos", method: :post, remote: true do %> - <i class="fa fa-bookmark"></i> - <%end%> - </div> - <div class="action"> - <%= render 'complaints/complaints_button' %> - </div> - <div class="action"> - <a tabindex="1" class="btn btn-primary share" role="button" title="Compartilhar" data-toggle="modal" data-target="#share_modal"> - <i class="fa fa-share"></i> - <%#= image_tag "icons/collection-add.png", alt: "Compartilhar" %> - </a> - <%= render 'share_modal' %> - </div> + </div> + <div class="action"> + <%= link_to like_learning_object_path(id: @learning_object.id), class: 'vote btn btn-primary',method: :post, remote: true do %> + <% if @liked %> + <%= image_tag "icons/btn_like_down.png", alt: "Descurtir" %> + <% else %> + <%= image_tag "icons/btn_like_up.png", alt: "Curtir" %> + <% end %> + <% end %> + </div> + <div class="action"> + <a tabindex="0" class="add-to-collection btn btn-primary" role="button" title="Adicionar as coleções" data-loid="<%= @learning_object.id %>"> + <%= image_tag "icons/btn_add.png", alt: "Adicionar à coleção" %> + </a> + </div> + <div class="action"> + <%= link_to bookmark_add_path(id: @learning_object.id, type: @learning_object.class.to_s), class:"btn btn-primary bookmark", title: "Adicionar aos favoritos", method: :post, remote: true do %> + <i class="fa fa-bookmark"></i> + <%end%> + </div> + <div class="action"> + <%= render 'complaints/complaints_button' %> + </div> + <div class="action"> + <a tabindex="1" class="btn btn-primary share" role="button" title="Compartilhar" data-toggle="modal" data-target="#share_modal"> + <i class="fa fa-share"></i> + <%#= image_tag "icons/collection-add.png", alt: "Compartilhar" %> + </a> + <%= render 'share_modal' %> + </div> - <% if policy(@learning_object).update? %> - <div class="action"> - <a tabindex="1" class="btn btn-primary share" role="button" title="Editar conteúdo" href="<%= edit_learning_object_path(@learning_object) %>"> - <i class="fa fa-pencil"></i> - </a> - </div> - <% end %> + <% if policy(@learning_object).update? %> + <div class="action"> + <a tabindex="1" class="btn btn-primary share" role="button" title="Editar conteúdo" href="<%= edit_learning_object_path(@learning_object) %>"> + <i class="fa fa-pencil"></i> + </a> + </div> + <% end %> - <% if policy(@learning_object).destroy? %> - <div class="action"> - <%= link_to learning_object_path(@learning_object), method: :delete, data: { confirm: 'Você tem certeza?' }, class:'btn btn-primary share', tabindex: 1, role: 'button', title: 'Apagar conteúdo' do %> - <i class="fa fa-trash"></i> - <% end %> - </div> - <% end %> + <% if policy(@learning_object).destroy? %> + <div class="action"> + <a tabindex="1" data-method='delete' class="btn btn-primary share" role="button" title="Deletar conteúdo" href="<%= learning_object_path(@learning_object) %>" data-confirm="Você tem certeza que quer deletar esse objeto?"> + <i class="fa fa-trash"></i> + </a> + </div> + <% end %> + </div> - </div> <% else %> - <div class="login-info"> - <%= image_tag "icons/i_estilizado.png"%> - <h4>Logue-se para poder curtir, adicionar o objeto em uma coleção, baixar o counteúdo ou denunciar.</h4> - </div> + <div class="login-info"> + <%= image_tag "icons/i_estilizado.png"%> + <h4>Logue-se para poder curtir, adicionar o objeto em uma coleção, baixar o counteúdo ou denunciar.</h4> + </div> <% end %> </div> + </div> </div> </div> </div> @@ -131,33 +131,32 @@ <button type="button" class="close" data-dismiss="modal" aria-label="Fechar"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="extra_metadata_modal_label">Metadados Adicionais</h4> </div> - <div class="modal-body" style="text-align:justify"> - - <div class="container-fluid"> - <div class="row"> - <div class="col-sm-12"> - <ul> - <li><b>Autor:</b> <%= @learning_object.author %></li> - <li><b>Tipo:</b> <%= @learning_object.get_metadata_value_of("dc.type") %></li> - <li><b>Data:</b> <%= @learning_object.get_metadata_value_of("dc.date.available") %></li> - <li><b>Linguagem:</b> <%= @learning_object.get_metadata_value_of("dc.language") %></li> - </ul> - <table class="table table-striped"> - <% @learning_object.metadata.each do |m| %> + <div class="modal-body" style="text-align:justify"> + <div class="container-fluid"> + <div class="row"> + <div class="col-sm-12"> + <ul> + <li><b>Autor:</b> <%= @learning_object.author %></li> + <li><b>Tipo:</b> <%= @learning_object.get_metadata_value_of("dc.type") %></li> + <li><b>Data:</b> <%= @learning_object.get_metadata_value_of("dc.date.available") %></li> + <li><b>Linguagem:</b> <%= @learning_object.get_metadata_value_of("dc.language") %></li> + </ul> + <table class="table table-striped"> + <% @learning_object.metadata.each do |m| %> <tr> <th><span><%= "#{m["key"]}:" %></span></th> <td><%= "#{m["value"]}" %></td> </tr> - <% end %> - </table> - </div> + <% end %> + </table> </div> </div> - - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button> </div> + + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button> + </div> </div> </div> </div> diff --git a/test/fixtures/learning_objects.yml b/test/fixtures/learning_objects.yml index 369e22d2c81dc68d01dcf8543c97289c8488f67c..67ad40a31b8f2bb1b745b936be9c0c29da8d2fa8 100644 --- a/test/fixtures/learning_objects.yml +++ b/test/fixtures/learning_objects.yml @@ -1,3 +1,35 @@ +# == Schema Information +# +# Table name: learning_objects +# +# id :integer not null, primary key +# id_dspace :integer +# name :string +# author :string +# description :text +# published_at :datetime +# score :float default("0.0") +# school_level :integer +# metadata :jsonb default("{}") +# keywords :text +# publisher_id :integer +# publisher_type :string +# language_id :integer +# object_type_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# views_count :integer default("0") +# downloads_count :integer default("0") +# likes_count :integer default("0") +# shares_count :integer default("0") +# state :string default("published") +# thumbnail_file_name :string +# thumbnail_content_type :string +# thumbnail_file_size :integer +# thumbnail_updated_at :datetime +# attachment_id :integer +# + one: name: 'Object 1' description: 'Testing' diff --git a/test/fixtures/score_user_categories.yml b/test/fixtures/score_user_categories.yml index dd1a50ef51f7a63eb6ddca2675a58efb262ca82d..12393cb656b20318d332711f1d09561dc0d0f867 100644 --- a/test/fixtures/score_user_categories.yml +++ b/test/fixtures/score_user_categories.yml @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: score_user_categories +# +# id :integer not null, primary key +# score_id :integer +# user_category_id :integer +# value :float +# created_at :datetime not null +# updated_at :datetime not null +# + <% values = [ [ 0, 0, 0, 0, 0, 0, 0, 0, 0], # Iniciante diff --git a/test/fixtures/scores.yml b/test/fixtures/scores.yml index ce46d73db1aa79645dbea2b1de678922dd42199a..b7ed2273b747e09dac016999b37ce4465b4fbd4c 100644 --- a/test/fixtures/scores.yml +++ b/test/fixtures/scores.yml @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: scores +# +# id :integer not null, primary key +# name :string +# code :string +# weight :float +# active :boolean default("true") +# created_at :datetime not null +# updated_at :datetime not null +# score_type :string default("{}"), is an Array +# + 1: name: 'Quantidade de envio de objetos' code: 'submitted_objects' diff --git a/test/fixtures/user_categories.yml b/test/fixtures/user_categories.yml index af786e20410f61d164cebe9dc38a9e55b4006761..b3b825ff71bc0fb75730ce2760883d921f23c442 100644 --- a/test/fixtures/user_categories.yml +++ b/test/fixtures/user_categories.yml @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: user_categories +# +# id :integer not null, primary key +# name :string +# reference :float +# created_at :datetime not null +# updated_at :datetime not null +# + 1: name: 'Iniciante' reference: 0.0 diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 798e181807bf4626b7a5bec657f665f0cc70daa5..2f387beb582c41549ce12b512348205bc83fac20 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,3 +1,38 @@ +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# email :string default(""), not null +# encrypted_password :string default(""), not null +# reset_password_token :string +# reset_password_sent_at :datetime +# remember_created_at :datetime +# sign_in_count :integer default("0"), not null +# current_sign_in_at :datetime +# last_sign_in_at :datetime +# current_sign_in_ip :string +# last_sign_in_ip :string +# created_at :datetime not null +# updated_at :datetime not null +# provider :string default("email"), not null +# uid :string default(""), not null +# confirmation_token :string +# confirmed_at :datetime +# confirmation_sent_at :datetime +# unconfirmed_email :string +# tokens :text +# name :string +# avatar_file_name :string +# avatar_content_type :string +# avatar_file_size :integer +# avatar_updated_at :datetime +# bookmarks_count :integer default("0") +# user_category_id :integer +# score :float default("0.0") +# follows_count :integer default("0") +# + one: name: 'John' email: 'john@test.com' diff --git a/test/models/bookmark_test.rb b/test/models/bookmark_test.rb index 2c739dca1a030bf397ff8a50bfd2f6c34461f69b..41533dbb3191d7939a99dcc20ce5bb6ca75ff03e 100644 --- a/test/models/bookmark_test.rb +++ b/test/models/bookmark_test.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: bookmarks +# +# id :integer not null, primary key +# user_id :integer +# bookmarkable_id :integer +# bookmarkable_type :string +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class BookmarkTest < ActiveSupport::TestCase diff --git a/test/models/carousel_test.rb b/test/models/carousel_test.rb index 26c20b1e122e221fdec4d8ab8789e1a060cbeb11..663ca53b191aceb35dbdd19681d1bc9aca0177ce 100644 --- a/test/models/carousel_test.rb +++ b/test/models/carousel_test.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: carousels +# +# id :integer not null, primary key +# title :string +# url :text +# created_at :datetime not null +# updated_at :datetime not null +# image_file_name :string +# image_content_type :string +# image_file_size :integer +# image_updated_at :datetime +# + require 'test_helper' class CarouselTest < ActiveSupport::TestCase diff --git a/test/models/collection_item_test.rb b/test/models/collection_item_test.rb index b037df012ac2ab01ad0c2d656c7dfe75e362a779..26cf5e85756c1e52375525d4150e09fc6a698582 100644 --- a/test/models/collection_item_test.rb +++ b/test/models/collection_item_test.rb @@ -1,3 +1,16 @@ +# == Schema Information +# +# Table name: collection_items +# +# id :integer not null, primary key +# collectionable_id :integer +# collectionable_type :string +# collection_id :integer +# order :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class CollectionItemTest < ActiveSupport::TestCase diff --git a/test/models/collection_test.rb b/test/models/collection_test.rb index 22288ef0b23563f795b36eeadc901ef384308a61..650f1b60dfb1c55c773131b4a884e2813971f5d2 100644 --- a/test/models/collection_test.rb +++ b/test/models/collection_test.rb @@ -1,3 +1,27 @@ +# == Schema Information +# +# Table name: collections +# +# id :integer not null, primary key +# name :string +# description :text +# privacy :string default("private") +# owner_id :integer +# owner_type :string +# created_at :datetime not null +# updated_at :datetime not null +# views_count :integer default("0") +# downloads_count :integer default("0") +# likes_count :integer default("0") +# shares_count :integer default("0") +# score :float default("0.0") +# follows_count :integer default("0") +# thumbnail_file_name :string +# thumbnail_content_type :string +# thumbnail_file_size :integer +# thumbnail_updated_at :datetime +# + require 'test_helper' class CollectionTest < ActiveSupport::TestCase diff --git a/test/models/complaint_reason_test.rb b/test/models/complaint_reason_test.rb index 09bcb0abdce3fc052df43fc7dde0c4729a705769..e283642fe0b29c3774de639dec23a4008996c79d 100644 --- a/test/models/complaint_reason_test.rb +++ b/test/models/complaint_reason_test.rb @@ -1,3 +1,13 @@ +# == Schema Information +# +# Table name: complaint_reasons +# +# id :integer not null, primary key +# reason :text +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class ComplaintReasonTest < ActiveSupport::TestCase diff --git a/test/models/complaint_test.rb b/test/models/complaint_test.rb index cdafb092d34794d2b3b6bb8ea8bf77922151937e..5e9714c680f059c4bc83177a973ea6aaa1848c6b 100644 --- a/test/models/complaint_test.rb +++ b/test/models/complaint_test.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: complaints +# +# id :integer not null, primary key +# description :text +# user_id :integer +# complaintable_id :integer +# complaintable_type :string +# complaint_reason_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class ComplaintTest < ActiveSupport::TestCase diff --git a/test/models/download_test.rb b/test/models/download_test.rb index 68692b44973d1e3b2beceaa88ab69d46f8328995..207c3afb3029fb68d3efa82592c6b2346eb01e05 100644 --- a/test/models/download_test.rb +++ b/test/models/download_test.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: downloads +# +# id :integer not null, primary key +# downloadable_id :integer +# downloadable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class DownloadTest < ActiveSupport::TestCase diff --git a/test/models/follow_test.rb b/test/models/follow_test.rb index aff2aaab9ac5084e6894c5d05ac1c0fb034aa36c..c4a512a8f6d503384d5ab4d1a8c43fb407e726fd 100644 --- a/test/models/follow_test.rb +++ b/test/models/follow_test.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: follows +# +# id :integer not null, primary key +# followable_id :integer +# followable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class FollowTest < ActiveSupport::TestCase diff --git a/test/models/institution_test.rb b/test/models/institution_test.rb index d3aac9f68f188f0ec5a5e2a9665af45b33652035..1fa31ccab4bd96b27ea3f1578a0ee4b94884013b 100644 --- a/test/models/institution_test.rb +++ b/test/models/institution_test.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: institutions +# +# id :integer not null, primary key +# name :string +# address :string +# city :string +# country :string +# description :text +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class InstitutionTest < ActiveSupport::TestCase diff --git a/test/models/language_test.rb b/test/models/language_test.rb index 1d4315f9fec45981bece6110d363aa334469bcd4..03d2bdf92e7d47e9a2a289549644732b71894a71 100644 --- a/test/models/language_test.rb +++ b/test/models/language_test.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: languages +# +# id :integer not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# code :string +# + require 'test_helper' class LanguageTest < ActiveSupport::TestCase diff --git a/test/models/learning_object/attachment_test.rb b/test/models/learning_object/attachment_test.rb index 93a755513df8f0cceefca77238d685a37066ff80..bc9898cd7143f294a6ea396e8b02c5163c62ab96 100644 --- a/test/models/learning_object/attachment_test.rb +++ b/test/models/learning_object/attachment_test.rb @@ -1,3 +1,27 @@ +# == Schema Information +# +# Table name: learning_object_attachments +# +# id :integer not null, primary key +# name :string +# link :string +# retrieve_link :string +# description :text +# format :string +# mime_type :string +# size :integer +# bundle_name :string +# learning_object_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# id_dspace :integer +# thumbnail_file_name :string +# thumbnail_content_type :string +# thumbnail_file_size :integer +# thumbnail_updated_at :datetime +# cache_link :string +# + require 'test_helper' class LearningObject::AttachmentTest < ActiveSupport::TestCase diff --git a/test/models/learning_object_test.rb b/test/models/learning_object_test.rb index 5f2eb2802556654e295407602320c1adccc842ab..c669b8c7d3304993f1c6382375b218451ff70cfd 100644 --- a/test/models/learning_object_test.rb +++ b/test/models/learning_object_test.rb @@ -1,3 +1,35 @@ +# == Schema Information +# +# Table name: learning_objects +# +# id :integer not null, primary key +# id_dspace :integer +# name :string +# author :string +# description :text +# published_at :datetime +# score :float default("0.0") +# school_level :integer +# metadata :jsonb default("{}") +# keywords :text +# publisher_id :integer +# publisher_type :string +# language_id :integer +# object_type_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# views_count :integer default("0") +# downloads_count :integer default("0") +# likes_count :integer default("0") +# shares_count :integer default("0") +# state :string default("published") +# thumbnail_file_name :string +# thumbnail_content_type :string +# thumbnail_file_size :integer +# thumbnail_updated_at :datetime +# attachment_id :integer +# + require 'test_helper' class LearningObjectTest < ActiveSupport::TestCase diff --git a/test/models/like_test.rb b/test/models/like_test.rb index 3599608c1f6d0252408e31ae8063508acf659cf4..3f9bf0015f5f0f891673c02549db929a07f7d801 100644 --- a/test/models/like_test.rb +++ b/test/models/like_test.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: likes +# +# id :integer not null, primary key +# likeable_id :integer +# likeable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class LikeTest < ActiveSupport::TestCase diff --git a/test/models/object_type_test.rb b/test/models/object_type_test.rb index 1c38bb21727897fbf05d25280016f1d6a8bd3047..3c230dbac08b6a22ccbe31d4dedc4fc6300214eb 100644 --- a/test/models/object_type_test.rb +++ b/test/models/object_type_test.rb @@ -1,3 +1,11 @@ +# == Schema Information +# +# Table name: object_types +# +# id :integer not null, primary key +# name :string +# + require 'test_helper' class ObjectTypeTest < ActiveSupport::TestCase diff --git a/test/models/rate_test.rb b/test/models/rate_test.rb index d3206371d58b90815faab622d162d73cdd92bcd4..367e667c0eebdfd1e381cb5d99eb87df43f1fa8e 100644 --- a/test/models/rate_test.rb +++ b/test/models/rate_test.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: rates +# +# id :integer not null, primary key +# approves :boolean +# user_id :integer +# review_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class RateTest < ActiveSupport::TestCase diff --git a/test/models/rating_test.rb b/test/models/rating_test.rb index a5101a2ebc89c678b2e8e9ca84ed399c03fba2c6..b93e91847982c008f47fb461d34f0e4eced3b169 100644 --- a/test/models/rating_test.rb +++ b/test/models/rating_test.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: ratings +# +# id :integer not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# description :string +# + require 'test_helper' class RatingTest < ActiveSupport::TestCase diff --git a/test/models/review_rating_test.rb b/test/models/review_rating_test.rb index 92ce397bbf11379215abe3c02f8cd695b6a0f6be..992c89b612c6798fe2d72bf02949058b32c45bce 100644 --- a/test/models/review_rating_test.rb +++ b/test/models/review_rating_test.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: review_ratings +# +# id :integer not null, primary key +# review_id :integer +# rating_id :integer +# value :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class ReviewRatingTest < ActiveSupport::TestCase diff --git a/test/models/review_test.rb b/test/models/review_test.rb index a5dddfa3a2f07f6c8120b1c86b1f969002d19cd8..df6d552cadaef4201fc80ec11ed0ed8fe7bc69cc 100644 --- a/test/models/review_test.rb +++ b/test/models/review_test.rb @@ -1,3 +1,20 @@ +# == Schema Information +# +# Table name: reviews +# +# id :integer not null, primary key +# name :string +# description :text +# pros :text +# cons :text +# reviewable_id :integer +# reviewable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# rates_count :integer default("0") +# + require 'test_helper' class ReviewTest < ActiveSupport::TestCase diff --git a/test/models/role_test.rb b/test/models/role_test.rb index 51158b48da07bb19ff03df5b85b2aef351ebef6a..ff22856a5adcc14b26eb1db0cfa9429292583cdd 100644 --- a/test/models/role_test.rb +++ b/test/models/role_test.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: roles +# +# id :integer not null, primary key +# name :string +# description :text +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class RoleTest < ActiveSupport::TestCase diff --git a/test/models/score_test.rb b/test/models/score_test.rb index 1f04b2c60f6ae61b384d638779180ad3a0296057..36d87062747df6efe7cc28f5a7a5a117e82d13ff 100644 --- a/test/models/score_test.rb +++ b/test/models/score_test.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: scores +# +# id :integer not null, primary key +# name :string +# code :string +# weight :float +# active :boolean default("true") +# created_at :datetime not null +# updated_at :datetime not null +# score_type :string default("{}"), is an Array +# + require 'test_helper' class ScoreTest < ActiveSupport::TestCase diff --git a/test/models/score_user_category_test.rb b/test/models/score_user_category_test.rb index 1aa74a18e7e7f894b13b8c75dc3215b1d7693013..3eaa66bb8d9cff3ac18c0c73f66283ec3e261135 100644 --- a/test/models/score_user_category_test.rb +++ b/test/models/score_user_category_test.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: score_user_categories +# +# id :integer not null, primary key +# score_id :integer +# user_category_id :integer +# value :float +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class ScoreUserCategoryTest < ActiveSupport::TestCase diff --git a/test/models/share_test.rb b/test/models/share_test.rb index a6b64cd67a4ed99f72eba85148667da19898aaf0..f4eaeb542b9d4b13e511c4366b1c1d8acdfff0be 100644 --- a/test/models/share_test.rb +++ b/test/models/share_test.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: shares +# +# id :integer not null, primary key +# shareable_id :integer +# shareable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class ShareTest < ActiveSupport::TestCase diff --git a/test/models/topic_highlight_test.rb b/test/models/topic_highlight_test.rb index e8c04d66898834960c659a09961e230720ca3c37..dfbe143a77ec26762827006161aff4ce3d9a5af4 100644 --- a/test/models/topic_highlight_test.rb +++ b/test/models/topic_highlight_test.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topic_highlights +# +# id :integer not null, primary key +# topic_id :integer +# learning_object_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class TopicHighlightTest < ActiveSupport::TestCase diff --git a/test/models/topic_relationship_test.rb b/test/models/topic_relationship_test.rb index 71086030dcbc0ea44d31c7cd36d584d92c4decb9..3a9d6b3640f6e256326b92f2cd45217cf374b45d 100644 --- a/test/models/topic_relationship_test.rb +++ b/test/models/topic_relationship_test.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topic_relationships +# +# id :integer not null, primary key +# parent_id :integer +# child_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class TopicRelationshipTest < ActiveSupport::TestCase diff --git a/test/models/topic_test.rb b/test/models/topic_test.rb index 2c9e974d79ed76578324891c65589442ecf6968c..bb50914dd436dff9ac90ab5ed6024541f2904369 100644 --- a/test/models/topic_test.rb +++ b/test/models/topic_test.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: topics +# +# id :integer not null, primary key +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# default :boolean default("false") +# + require 'test_helper' class TopicTest < ActiveSupport::TestCase diff --git a/test/models/user_category_test.rb b/test/models/user_category_test.rb index d057ea32489085a176c12120d074c6cd5b9b69a9..379129a8f7e8a9af849acc9e84941627c2af27eb 100644 --- a/test/models/user_category_test.rb +++ b/test/models/user_category_test.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: user_categories +# +# id :integer not null, primary key +# name :string +# reference :float +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class UserCategoryTest < ActiveSupport::TestCase diff --git a/test/models/user_test.rb b/test/models/user_test.rb index cab668434eedc452fce840879fabd203d3c88a1a..9916390f3c35643ce8e406c199f552fdc9657a93 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1,3 +1,38 @@ +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# email :string default(""), not null +# encrypted_password :string default(""), not null +# reset_password_token :string +# reset_password_sent_at :datetime +# remember_created_at :datetime +# sign_in_count :integer default("0"), not null +# current_sign_in_at :datetime +# last_sign_in_at :datetime +# current_sign_in_ip :string +# last_sign_in_ip :string +# created_at :datetime not null +# updated_at :datetime not null +# provider :string default("email"), not null +# uid :string default(""), not null +# confirmation_token :string +# confirmed_at :datetime +# confirmation_sent_at :datetime +# unconfirmed_email :string +# tokens :text +# name :string +# avatar_file_name :string +# avatar_content_type :string +# avatar_file_size :integer +# avatar_updated_at :datetime +# bookmarks_count :integer default("0") +# user_category_id :integer +# score :float default("0.0") +# follows_count :integer default("0") +# + require 'test_helper' class UserTest < ActiveSupport::TestCase diff --git a/test/models/view_test.rb b/test/models/view_test.rb index 76631e9931f5e2311d9e935309e355aae9258783..201fae5305c3b93f57458e22f71b3c0784719c5a 100644 --- a/test/models/view_test.rb +++ b/test/models/view_test.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: views +# +# id :integer not null, primary key +# viewable_id :integer +# viewable_type :string +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + require 'test_helper' class ViewTest < ActiveSupport::TestCase