Skip to content
Snippets Groups Projects
Commit 9fccf980 authored by Matheus Agio Nerone's avatar Matheus Agio Nerone
Browse files

Merge branch 'master' into hotfix-add-button-to-delete-learning-object

parents b46fc918 8699fcd9
No related branches found
No related tags found
No related merge requests found
Showing
with 326 additions and 61 deletions
......@@ -22,6 +22,7 @@ Gemfile.lock
/public/assets
/config/orientdb.yml
/config/dspace.yml
# ignore server scripts
puma.sh
start_puma.sh
......@@ -30,3 +31,7 @@ portalmec.service
portalmec-sidekiq.service
sidekiq.sh
autocomplete-server.service
# ignore configs
/config/database.yml
/config/sidekiq.yml
\ No newline at end of file
FROM ruby:2.2.0
RUN apt-get update -qq && apt-get install -y build-essential nodejs
RUN mkdir /app
WORKDIR /tmp
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle install -j 3
WORKDIR /app
CMD ["rails", "server", "-b", "0.0.0.0"]
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
gem 'rails', '4.2.6'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
......@@ -90,6 +90,8 @@ gem 'stackprof'
gem 'font-awesome-rails'
group :development do
gem 'annotate'
gem 'immigrant'
# mute assets in log
......@@ -126,6 +128,7 @@ end
group :test do
gem 'shoulda'
gem 'minitest-reporters'
end
gem 'streamio-ffmpeg', '~> 1.0.0'
......
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.5.1)
actionpack (= 4.2.5.1)
actionview (= 4.2.5.1)
activejob (= 4.2.5.1)
actionmailer (4.2.6)
actionpack (= 4.2.6)
actionview (= 4.2.6)
activejob (= 4.2.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.5.1)
actionview (= 4.2.5.1)
activesupport (= 4.2.5.1)
actionpack (4.2.6)
actionview (= 4.2.6)
activesupport (= 4.2.6)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.5.1)
activesupport (= 4.2.5.1)
actionview (4.2.6)
activesupport (= 4.2.6)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.5.1)
activesupport (= 4.2.5.1)
activejob (4.2.6)
activesupport (= 4.2.6)
globalid (>= 0.3.0)
activemodel (4.2.5.1)
activesupport (= 4.2.5.1)
activemodel (4.2.6)
activesupport (= 4.2.6)
builder (~> 3.1)
activerecord (4.2.5.1)
activemodel (= 4.2.5.1)
activesupport (= 4.2.5.1)
activerecord (4.2.6)
activemodel (= 4.2.6)
activesupport (= 4.2.6)
arel (~> 6.0)
activerecord-import (0.12.0)
activerecord (>= 3.0)
activesupport (4.2.5.1)
activesupport (4.2.6)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.3.8)
ansi (1.5.0)
arel (6.0.3)
ast (2.2.0)
autoprefixer-rails (6.3.3.1)
autoprefixer-rails (6.3.4)
execjs
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
......@@ -175,7 +176,7 @@ GEM
dm-core (~> 1.2.0)
do_sqlite3 (0.10.17)
data_objects (= 0.10.17)
dspace_rest_client (2.2.5)
dspace_rest_client (2.2.6)
activesupport (~> 4.2, >= 4.2.0)
faraday (~> 0.9.2)
json (~> 1.8, >= 1.8.3)
......@@ -265,6 +266,11 @@ GEM
rake
mini_portile2 (2.0.0)
minitest (5.8.4)
minitest-reporters (1.1.8)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
......@@ -310,7 +316,7 @@ GEM
pg (0.18.4)
phantomjs (2.1.1.0)
ptools (1.3.3)
puma (3.1.0)
puma (3.2.0)
pundit (1.1.0)
activesupport (>= 3.0.0)
quiet_assets (1.1.0)
......@@ -323,16 +329,16 @@ GEM
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.5.1)
actionmailer (= 4.2.5.1)
actionpack (= 4.2.5.1)
actionview (= 4.2.5.1)
activejob (= 4.2.5.1)
activemodel (= 4.2.5.1)
activerecord (= 4.2.5.1)
activesupport (= 4.2.5.1)
rails (4.2.6)
actionmailer (= 4.2.6)
actionpack (= 4.2.6)
actionview (= 4.2.6)
activejob (= 4.2.6)
activemodel (= 4.2.6)
activerecord (= 4.2.6)
activesupport (= 4.2.6)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.5.1)
railties (= 4.2.6)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
......@@ -342,14 +348,14 @@ GEM
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.5.1)
actionpack (= 4.2.5.1)
activesupport (= 4.2.5.1)
railties (4.2.6)
actionpack (= 4.2.6)
activesupport (= 4.2.6)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.1.0)
rake (11.1.1)
rake-compiler (0.9.6)
rake-compiler (0.9.7)
rake
rdoc (4.2.2)
json (~> 1.4)
......@@ -359,13 +365,14 @@ GEM
parser (~> 2.3, >= 2.3.0.6)
rainbow (~> 2.0)
ref (2.0.0)
resource_kit (0.1.4)
resource_kit (0.1.5)
addressable (~> 2.3.6)
responders (2.1.1)
responders (2.1.2)
railties (>= 4.2.0, < 5.1)
resumablejs-rails (1.1)
railties (> 3.1, < 5)
rmagick (2.15.4)
ruby-progressbar (1.7.5)
ruby2ruby (2.3.0)
ruby_parser (~> 3.1)
sexp_processor (~> 4.0)
......@@ -504,6 +511,7 @@ DEPENDENCIES
meta-tags
mimemagic
mina
minitest-reporters
omniauth-facebook
omniauth-google-oauth2
omniauth-twitter
......@@ -514,7 +522,7 @@ DEPENDENCIES
quiet_assets
rack-cors
rack-mini-profiler
rails (= 4.2.5.1)
rails (= 4.2.6)
rainbow
rdoc
resumablejs-rails
......
......@@ -18,6 +18,12 @@ After this setup, open the config files and update some vars:
* config/initializers/gitlab.rb: change your gitlab host for bug reports and set env var with private token. ( $ export GITLAB_PORTALMEC_PRIVATE_TOKEN=131237128937128937 )
### Development environment
#### Using docker for development env
You can use docker for your development environment. For that, run:
``` ./bin/docker-setup ```
Now, redis, elasticsearch and postgres are running as services and linked to PortalMEC application. Database migrations were execute and the configs (database.yml, sidekiq.yml was replaced by config/docker/...).
If all development and test vars are set, run:
``` ./bin/setup ```
This command will install the rubygems, create/reset your database schema, seed some default data and import all dspace data.
......@@ -25,7 +31,7 @@ This command will install the rubygems, create/reset your database schema, seed
After this, your application is ready to use and you can access it with:
``` bundle exec rails s ```
### Test environment
### Running tests suite
For tests, TestUnit is used, and to run it:
``` bundle exec rake test ```
......
......@@ -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
......@@ -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.owner?(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.owner?(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?
......@@ -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
......
# == 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
......
# == 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>",
......
# == 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
......
# == 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
......
# == 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
......
# == 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
......
# == 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
......
# == 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
......
# == 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
# == 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
......
# == 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
......
# == 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
......
# == 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
# == 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
......
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