diff --git a/Gemfile b/Gemfile index 60610a767c844961814add11e95f85f14785dd28..41cd58e957692a4233a221458ce2deaaaf34b8ed 100644 --- a/Gemfile +++ b/Gemfile @@ -180,3 +180,5 @@ gem 'acts_as_list' gem 'faraday-net_http_persistent', '~> 2.0' gem 'elasticsearch', '< 7.14' + + diff --git a/Gemfile.lock b/Gemfile.lock index 1b2095412db1cce0a600cfd3520d218f763587cd..1373ff5ab1fbe4443c38cded6da5bd5033b9825e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -111,6 +111,8 @@ GEM activerecord (>= 4.2) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) + airbrussh (1.4.1) + sshkit (>= 1.6.1, != 1.7.0) annotate (3.2.0) activerecord (>= 3.2, < 8.0) rake (>= 10.4, < 14.0) @@ -133,6 +135,13 @@ GEM activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) + capistrano (3.17.1) + airbrussh (>= 1.0.0) + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) + capistrano-rsync-bladrak (1.3.8) + capistrano (>= 3.0.0.pre14, < 4) case_transform (0.2) activesupport choice (0.2.0) @@ -187,13 +196,13 @@ GEM diff-lcs (1.5.0) digest (3.1.0) docile (1.4.0) - elasticsearch (7.13.3) - elasticsearch-api (= 7.13.3) - elasticsearch-transport (= 7.13.3) - elasticsearch-api (7.13.3) + elasticsearch (5.0.5) + elasticsearch-api (= 5.0.5) + elasticsearch-transport (= 5.0.5) + elasticsearch-api (5.0.5) multi_json - elasticsearch-transport (7.13.3) - faraday (~> 1) + elasticsearch-transport (5.0.5) + faraday multi_json equalizer (0.0.11) erubi (1.10.0) @@ -319,10 +328,13 @@ GEM timeout net-protocol (0.1.3) timeout + net-scp (4.0.0) + net-ssh (>= 2.6.5, < 8.0.0) net-smtp (0.3.1) digest net-protocol timeout + net-ssh (7.0.1) nio4r (2.5.8) nokogiri (1.13.6-x86_64-linux) racc (~> 1.4) @@ -530,6 +542,9 @@ GEM tilt (>= 2.0.6, < 2.1) spring (4.0.0) sqlite3 (1.4.4) + sshkit (1.21.3) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) stackprof (0.2.19) streamio-ffmpeg (3.0.2) multi_json (~> 1.8) @@ -583,6 +598,7 @@ DEPENDENCIES brakeman bullet byebug + capistrano-rsync-bladrak (~> 1.3.3) connection_pool curb (>= 0.8.8) dalli diff --git a/app/controllers/v1/complaint_votes_controller.rb b/app/controllers/v1/complaint_votes_controller.rb index af971d16e881423b7631fba62d20653d5c0b4efd..93a0676bab213b4c6c4610c848f34b50e6eb15fd 100644 --- a/app/controllers/v1/complaint_votes_controller.rb +++ b/app/controllers/v1/complaint_votes_controller.rb @@ -92,14 +92,8 @@ class V1::ComplaintVotesController < ApplicationController if d.pros - d.cons > 2 ComplaintVote.where("complainable_id = ?", complaint_vote.complainable_id).destroy_all Complaint.where("complainable_id = ?", complaint_vote.complainable_id).destroy_all + LearningObject.where(id: complaint_vote.complainable_id).update_all(state: LearningObject.states[:deleted]) LearningObject.where(id: complaint_vote.complainable_id).update_all(deleted_at: Time.now) - #Complaint.find_by_complainable_id(complaint_vote.complainable_id).update(state: 2) - #Complaint.find_by_complainable_id(complaint_vote.complainable_id).destroy - #ComplaintVote.find_by_complainable_id(complaint_vote.complainable_id).destroy - #LearningObject.find_by_id(complaint_vote.complainable_id).destroy - # puts "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" - # puts " pros maior que cons, pros = #{d.pros}, cons = #{d.cons}" - # puts "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" elsif d.cons - d.pros > 2 ComplaintVote.where("complainable_id = ?", complaint_vote.complainable_id).destroy_all Complaint.where("complainable_id = ?", complaint_vote.complainable_id).update_all(state: Complaint.states[:rejected]) diff --git a/app/controllers/v1/feed_controller.rb b/app/controllers/v1/feed_controller.rb index 80f6f96d2de328a54d902df29a5353a3559bcbf8..39e8c135bb5c36eec94f9561d0ddb7fc93cb7dda 100644 --- a/app/controllers/v1/feed_controller.rb +++ b/app/controllers/v1/feed_controller.rb @@ -40,7 +40,7 @@ class V1::FeedController < ApplicationController current_user.watching.each do |watching| if !watching.respond_to?(:state) || watching.state == "published" if (watching.class == Submission || watching.class == CuratorAssignment) - query += " ((trackable_type = ? and trackable_id = ?) and (owner_type = 'User' and owner_id = #{current_user.id})" + query += " ( recipient_id != owner_id and (trackable_type = ? and trackable_id = ?) and (owner_type = 'User' and owner_id = #{current_user.id})" values << watching.class.to_s values << watching.id if watching.class == CuratorAssignment diff --git a/app/controllers/v1/learning_objects/chunks_controller.rb b/app/controllers/v1/learning_objects/chunks_controller.rb index f5549de8e5bf579d7468927b536a0ced7b19f251..451300fe1569b2acd1e813f58fc7ab357c73b388 100644 --- a/app/controllers/v1/learning_objects/chunks_controller.rb +++ b/app/controllers/v1/learning_objects/chunks_controller.rb @@ -30,15 +30,18 @@ class V1::LearningObjects::ChunksController < ApplicationController def create save_file! - if last_chunk? - combine_file! - attachment = post_file! - render json: attachment, status: :ok - else + if chunks_params[:cancel] == "true" + FileUtils.rm_rf(chunk_file_directory) render status: :ok + else + if last_chunk? + combine_file! + attachment = post_file! + render json: attachment, status: :ok + else + render status: :ok + end end - rescue - render status: :internal_server_error end private @@ -53,7 +56,7 @@ class V1::LearningObjects::ChunksController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def chunks_params - params.permit(:id, :file, :_chunkNumber, :_totalChunks, :_chunkFilename, :_chunkIdentifier, :_chunkSize, :_currentChunkSize, :_totalSize) + params.permit(:id, :file, :_chunkNumber, :_totalChunks, :_chunkFilename, :_chunkIdentifier, :_chunkSize, :_currentChunkSize, :_totalSize, :cancel) end def post_file! diff --git a/app/controllers/v1/learning_objects_complaints_controller.rb b/app/controllers/v1/learning_objects_complaints_controller.rb index a44b8afe8be401703816537bd218fbd58520fc11..cb32e7a3e4f481509280591f9c1d9d35d3b9d110 100644 --- a/app/controllers/v1/learning_objects_complaints_controller.rb +++ b/app/controllers/v1/learning_objects_complaints_controller.rb @@ -61,8 +61,6 @@ class V1::LearningObjectsComplaintsController < ApplicationController # GET v1/learning_objects_complaints def index - - #select and sum the priority if has two or more complaints complaints_priority = ComplaintReason.joins(:complaints).select("complainable_id, SUM(complaint_reasons.priority) as priorities") .where("complaints.state = 0").group("complainable_id").having("(COUNT(complainable_id) > 1 OR SUM(complaint_reasons.priority) > 20)") diff --git a/app/controllers/v1/submissions_controller.rb b/app/controllers/v1/submissions_controller.rb index f6712d508f6ef08d5c526ea9ac433f256a594425..14d42b33c2c1381f23d94a1e33ac1234ad5ac9f9 100644 --- a/app/controllers/v1/submissions_controller.rb +++ b/app/controllers/v1/submissions_controller.rb @@ -27,7 +27,6 @@ class V1::SubmissionsController < ApplicationController def index - submissions = paginate Submission.where(status: Submission.statuses[:submitted]) render json: submissions @@ -41,7 +40,7 @@ class V1::SubmissionsController < ApplicationController submission_user = Submission.where(submitter_id: params[:user_id]).where(status: 0) all_submission_user = paginate submission_user render json: all_submission_user - end + end def all_users_submissions # show all submissions of all users without from the current user @@ -88,9 +87,10 @@ class V1::SubmissionsController < ApplicationController end @submission.curator = current_user if @submission.save - if @submission.accepted?def user_submissions - render status: :ok - end + if @submission.accepted? + publisher = LearningObjectPublisher.new(DspaceService.create_client) + publisher.publish @submission.learning_object + else @submission.learning_object.destroy end render json: @submission, status: :ok diff --git a/app/controllers/v1/user_progresses_controller.rb b/app/controllers/v1/user_progresses_controller.rb index 9c5473e31d5d668181590fb3a43bf89f5818c191..74d28ace71ee04df2d0d69bbf783f2b3b3d49ffc 100644 --- a/app/controllers/v1/user_progresses_controller.rb +++ b/app/controllers/v1/user_progresses_controller.rb @@ -25,10 +25,9 @@ class V1::UserProgressesController < ApplicationController last_string = p.requirement.description end end - - render json: all_progresses + + all_progresses_paginate = paginate all_progresses + render json: all_progresses_paginate end - - -end \ No newline at end of file +end diff --git a/app/controllers/v1/users_controller.rb b/app/controllers/v1/users_controller.rb index 03a5d728af33d27a7627ec73d4fbc60f9714fc9c..5fdc1d08a35c986ab855241a6c83a5eef6e2bb2a 100644 --- a/app/controllers/v1/users_controller.rb +++ b/app/controllers/v1/users_controller.rb @@ -51,10 +51,12 @@ class V1::UsersController < ApplicationController def confirm_email link = "https://plataformaintegrada.mec.gov.br/confirmacao-de-email" @user = User.find_by_confirm_token(params[:id]) + if @user @user.email_activate redirect_to link end + end # POST /v1/users/purchase_item @@ -176,6 +178,12 @@ class V1::UsersController < ApplicationController render status: :ok, json: response end + def show_top_users + # select id, level from users order by level desc limit 5; + users = paginate User.all.order("level DESC").limit(6) + render json: users + end + # GET /v1/users/teacher_requests # GET /v1/users/teacher_requests.json def teacher_requests diff --git a/app/models/concerns/stateful.rb b/app/models/concerns/stateful.rb index 224a221ae97e9970a02c2056e08846f2efc988a2..ab70fb6a85b1dc8a263586afd4b85e5c30d47719 100644 --- a/app/models/concerns/stateful.rb +++ b/app/models/concerns/stateful.rb @@ -21,6 +21,6 @@ module Stateful extend ActiveSupport::Concern included do - enum state: { draft: 0, published: 1, suspended: 2, submitted: 3 } + enum state: { draft: 0, published: 1, suspended: 2, submitted: 3, deleted: 4 } end end diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index 5bbf2e0157ac37f18c0cad33e238c321fb046c8c..772a7de7c3fd34dcbc5236b16ad9304e60ea2426 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -87,7 +87,7 @@ class ApplicationPolicy end def user_can_publish? - (user_can_curate? && record.submitted?) || (owns? && user.is_partner?) + (user_can_curate? && record.submitted?) || (owns? && user.is_partner?) || (user.is_admin?) end def user_can_curate? diff --git a/config/env_vars.sh b/config/env_vars.sh index 6b66ec625c4a7e25740197be9342578625c3cb80..f13a13512609cd9797941aa3bca3f255bde1be46 100644 --- a/config/env_vars.sh +++ b/config/env_vars.sh @@ -45,7 +45,7 @@ export PORTALMEC_ELASTICSEARCH_HOST=elasticsearchprod export MEMCACHE_SERVERS=localhost ### SMTP -export ACTION_MAILER_HOST=api.portalmec.c3sl.ufpr.br +export ACTION_MAILER_HOST=api.portalmectest.c3sl.ufpr.br export SMTP_ADDRESS=urquell.c3sl.ufpr.br export SMTP_PORT=587 diff --git a/config/routes.rb b/config/routes.rb index 3261438547e8cdfbf002189f5599d64dea45d3b6..b40d696ba8c0477cd944159d46e517d68a75b9ac 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -248,5 +248,6 @@ Rails.application.routes.draw do get 'submissions/all_users_submissions/:user_id', to: 'submissions#all_users_submissions' get 'learning_objects_complaints/queue_user/:user_id', to: 'learning_objects_complaints#queue_user' get 'user_progresses/:user_id', to: 'user_progresses#index' + get '/top_users', to: 'users#show_top_users' end end diff --git a/config/schedule.rb b/config/schedule.rb index 78cb9d05077d875bedc41a70295a32448c14f337..3ed49087f0b78970280c6c6dbd6c9776aa81d870 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -1,4 +1,3 @@ - # Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre # Departamento de Informatica - Universidade Federal do Parana # @@ -56,4 +55,4 @@ end every 5.days do rake 'delete_production_log:delete_log' -end \ No newline at end of file +end diff --git a/db/seeds/complaints.rb b/db/seeds/complaints.rb index 52126af608b7f6810dedad2cd3373c1887cd4802..651df5f4fd9af37cf0abf439b3373abce82e2051 100644 --- a/db/seeds/complaints.rb +++ b/db/seeds/complaints.rb @@ -17,9 +17,9 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -ComplaintReason.create(reason: "Objeto viola direitos autorais", priority: 4) -ComplaintReason.create(reason: "Contém conteúdo ofensivo/abusivo", priority: 5) -ComplaintReason.create(reason: "Esta é uma conta falsa", priority: 3) -ComplaintReason.create(reason: "Isso é um spam", priority: 1) -ComplaintReason.create(reason: "A descrição não corresponde ao seu conteúdo", priority: 2) -ComplaintReason.create(reason: "Esta pesssoa está fingindo ser eu ou alguém que eu conheço", priority: 3) +ComplaintReason.where(reason: "Objeto viola direitos autorais", priority: 4).first_or_create +ComplaintReason.where(reason: "Contém conteúdo ofensivo/abusivo", priority: 5).first_or_create +ComplaintReason.where(reason: "Esta é uma conta falsa", priority: 3).first_or_create +ComplaintReason.where(reason: "Isso é um spam", priority: 1).first_or_create +ComplaintReason.where(reason: "A descrição não corresponde ao seu conteúdo", priority: 2).first_or_create +ComplaintReason.where(reason: "Esta pesssoa está fingindo ser eu ou alguém que eu conheço", priority: 3).first_or_create diff --git a/env_vars.txt b/env_vars.txt new file mode 100644 index 0000000000000000000000000000000000000000..a4548a9415df69b484496db2b5af58d99f96a147 --- /dev/null +++ b/env_vars.txt @@ -0,0 +1,24 @@ +PORTALMEC_DB_HOST=localhost +PORTALMEC_DB_POOL=25 +PORTALMEC_DB_NAME=portalmecapi +PORTALMEC_DB_USERNAME=portalmec +PORTALMEC_DB_PASSWORD=123mudar +PORTALMEC_DSPACE_LOGIN=admin@mecdb3.c3sl.ufpr.br +PORTALMEC_DSPACE_PASSWORD=admin +PORTALMEC_DSPACE_PORT=8443 +PORTALMEC_DSPACE_HOST=mecdb4.c3sl.ufpr.br +PORTALMEC_ELASTICSEARCH_PORT=9200 +PORTALMEC_ELASTICSEARCH_HOST=localhost +MEMCACHE_SERVERS=localhost +ACTION_MAILER_HOST=api.portalmectest.c3sl.ufpr.br +SMTP_ADDRESS=urquell.c3sl.ufpr.br +SMTP_PORT=587 +GITLAB_PORTALMEC_PRIVATE_TOKEN= +RAILS_SERVE_STATIC_FILES=FALSE +RAILS_ENV=production +PORT=3000 +WEB_CONCURRENCY=8 +RAILS_MAX_THREADS=8 +REDIS_HOST=localhost:6379 +GOOGLE_KEY=288460085642-k4veg4fo8kddvjer8b055n9da5qtgha7.apps.googleusercontent.com +GOOGLE_SECRET=C3OFletrmEU3lcY8YOHtnr7z diff --git a/export_env_vars.sh b/export_env_vars.sh index 1cb2df65dda872cc4d875fa4d1763759ee8bfb6b..a54583966e4a451aba60f012dc01e2bfaac19a33 100755 --- a/export_env_vars.sh +++ b/export_env_vars.sh @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with portalmec. If not, see <http://www.gnu.org/licenses/>. -ENV_VARS_PATH=/home/portalmec/portalmec/config/env_vars.sh -EXPORT_PATH=/home/portalmec/portalmec/env_vars.txt +ENV_VARS_PATH=/home/portalmec/portalmec-update/cleanning-portalmec/config/env_vars.sh +EXPORT_PATH=/home/portalmec/portalmec-update/cleanning-portalmec/env_vars.txt grep -o '^[^#]*' $ENV_VARS_PATH | cut -d ' ' -f1 --complement > $EXPORT_PATH