diff --git a/Gemfile b/Gemfile index e1134327f415a64eda8580996b7b45c591415894..1900cee1e7c5610a7b10e10d8bbdd07b776780d9 100644 --- a/Gemfile +++ b/Gemfile @@ -134,4 +134,5 @@ gem 'curb', '~> 0.8.8' # libArchive (Zip, Rar, ...) # C extension is required # For Mac OSX: brew install libarchive && bundle config build.libarchive "--with-opt-dir=/usr/local/opt/libarchive" -gem 'libarchive', '~> 0.1.2' \ No newline at end of file +#gem 'libarchive', '~> 0.1.2', :require => 'libarchive_ruby' +gem 'libarchive-static' diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index c14d3a87d8d3498400c028fc2ceec58cc7c449db..0000000000000000000000000000000000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,425 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - abstract_type (0.0.7) - actionmailer (4.2.0) - actionpack (= 4.2.0) - actionview (= 4.2.0) - activejob (= 4.2.0) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.0) - actionview (= 4.2.0) - activesupport (= 4.2.0) - rack (~> 1.6.0) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - actionview (4.2.0) - activesupport (= 4.2.0) - builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - activejob (4.2.0) - activesupport (= 4.2.0) - globalid (>= 0.3.0) - activemodel (4.2.0) - activesupport (= 4.2.0) - builder (~> 3.1) - activerecord (4.2.0) - activemodel (= 4.2.0) - activesupport (= 4.2.0) - arel (~> 6.0) - activesupport (4.2.0) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - adamantium (0.2.0) - ice_nine (~> 0.11.0) - memoizable (~> 0.4.0) - arel (6.0.3) - ast (2.1.0) - autoprefixer-rails (6.0.3) - execjs - json - axiom-types (0.1.1) - descendants_tracker (~> 0.0.4) - ice_nine (~> 0.11.0) - thread_safe (~> 0.3, >= 0.3.1) - bcrypt (3.1.10) - better_errors (2.1.1) - coderay (>= 1.0.0) - erubis (>= 2.6.6) - rack (>= 0.9.0) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) - bootstrap-sass (3.3.5.1) - autoprefixer-rails (>= 5.0.0.1) - sass (>= 3.3.0) - builder (3.2.2) - bullet (4.14.7) - activesupport (>= 3.0.0) - uniform_notifier (~> 1.9.0) - byebug (6.0.2) - celluloid (0.17.1.2) - bundler - celluloid-essentials - celluloid-extras - celluloid-fsm - celluloid-pool - celluloid-supervision - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - celluloid-essentials (0.20.2.1) - bundler - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - celluloid-extras (0.20.1) - bundler - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - celluloid-fsm (0.20.1) - bundler - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - celluloid-pool (0.20.1) - bundler - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - celluloid-supervision (0.20.1.1) - bundler - dotenv - nenv - rspec-logsplit (>= 0.1.2) - timers (>= 4.1.1) - chart-js-rails (0.0.9) - railties (> 3.1) - chronic (0.10.2) - climate_control (0.0.3) - activesupport (>= 3.0) - cocaine (0.5.7) - climate_control (>= 0.0.3, < 1.0) - coderay (1.1.0) - coercible (1.0.0) - descendants_tracker (~> 0.0.1) - coffee-rails (4.1.0) - coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.9.1.1) - concord (0.1.5) - adamantium (~> 0.2.0) - equalizer (~> 0.0.9) - connection_pool (2.2.0) - curb (0.8.8) - dalli (2.7.4) - debug_inspector (0.0.2) - descendants_tracker (0.0.4) - thread_safe (~> 0.3, >= 0.3.1) - devise (3.5.1) - bcrypt (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) - responders - thread_safe (~> 0.1) - warden (~> 1.2.3) - devise_token_auth (0.1.34) - devise (= 3.5.1) - rails (~> 4.2) - diff-lcs (1.2.5) - domain_name (0.5.24) - unf (>= 0.0.5, < 1.0.0) - dotenv (2.0.2) - dspace_rest_client (1.1.2) - curb (~> 0.8.6) - rest-client (>= 1.7, < 2) - equalizer (0.0.11) - erubis (2.7.0) - execjs (2.6.0) - fast_stack (0.1.0) - rake - rake-compiler - flamegraph (0.1.0) - fast_stack - flay (2.4.0) - ruby_parser (~> 3.0) - sexp_processor (~> 4.0) - flog (4.2.1) - ruby_parser (~> 3.1, > 3.1.0) - sexp_processor (~> 4.4) - globalid (0.3.6) - activesupport (>= 4.1.0) - hitimes (1.2.3) - http-cookie (1.0.2) - domain_name (~> 0.5) - i18n (0.7.0) - ice_nine (0.11.1) - jbuilder (2.3.1) - activesupport (>= 3.0.0, < 5) - multi_json (~> 1.2) - jquery-rails (4.0.5) - rails-dom-testing (~> 1.0) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - jquery-turbolinks (2.1.0) - railties (>= 3.1.0) - turbolinks - jquery-ui-rails (5.0.5) - railties (>= 3.2.16) - json (1.8.3) - kaminari (0.16.3) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) - libv8 (3.16.14.11) - locastyle (0.0.1) - loofah (2.0.3) - nokogiri (>= 1.5.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) - memoizable (0.4.2) - thread_safe (~> 0.3, >= 0.3.1) - mime-types (2.6.2) - mimemagic (0.3.0) - mina (0.3.7) - open4 (~> 1.3.4) - rake - mini_portile (0.6.2) - minitest (5.8.1) - multi_json (1.11.2) - nenv (0.2.0) - netrc (0.10.3) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) - open4 (1.3.4) - orientdb4r (0.5.1) - rest-client (~> 1.7) - orm_adapter (0.5.0) - paperclip (4.3.1) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - cocaine (~> 0.5.5) - mime-types - mimemagic (= 0.3.0) - parser (2.2.2.6) - ast (>= 1.1, < 3.0) - pg (0.18.3) - procto (0.0.2) - puma (2.14.0) - rack (1.6.4) - rack-cors (0.4.0) - rack-mini-profiler (0.9.7) - rack (>= 1.1.3) - rack-protection (1.5.3) - rack - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.0) - actionmailer (= 4.2.0) - actionpack (= 4.2.0) - actionview (= 4.2.0) - activejob (= 4.2.0) - activemodel (= 4.2.0) - activerecord (= 4.2.0) - activesupport (= 4.2.0) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.0) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) - loofah (~> 2.0) - railties (4.2.0) - actionpack (= 4.2.0) - activesupport (= 4.2.0) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (2.0.0) - rake (10.4.2) - rake-compiler (0.9.5) - rake - rdoc (4.2.0) - redis (3.2.1) - redis-namespace (1.5.2) - redis (~> 3.0, >= 3.0.4) - reek (1.6.5) - parser (~> 2.2.0.pre.7) - rainbow (>= 1.99, < 3.0) - unparser (~> 0.2.2) - ref (2.0.0) - responders (2.1.0) - railties (>= 4.2.0, < 5) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rmagick (2.15.4) - rsolr (1.0.12) - builder (>= 2.1.2) - rspec-logsplit (0.1.3) - ruby_parser (3.7.1) - sexp_processor (~> 4.1) - rubycritic (1.4.0) - flay (= 2.4.0) - flog (= 4.2.1) - parser (>= 2.2.0, < 3.0) - reek (= 1.6.5) - virtus (~> 1.0) - sass (3.4.18) - sass-rails (5.0.4) - railties (>= 4.0.0, < 5.0) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - sdoc (0.4.1) - json (~> 1.7, >= 1.7.7) - rdoc (~> 4.0) - select2-rails (4.0.0) - thor (~> 0.14) - sexp_processor (4.6.0) - shoulda (3.5.0) - shoulda-context (~> 1.0, >= 1.0.1) - shoulda-matchers (>= 1.4.1, < 3.0) - shoulda-callback-matchers (1.1.3) - activesupport (>= 3) - shoulda-context (1.2.1) - shoulda-matchers (2.8.0) - activesupport (>= 3.0.0) - sidekiq (3.5.0) - celluloid (~> 0.17.0) - connection_pool (~> 2.2, >= 2.2.0) - json (~> 1.0) - redis (~> 3.2, >= 3.2.1) - redis-namespace (~> 1.5, >= 1.5.2) - sinatra (1.4.6) - rack (~> 1.4) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) - slim (3.0.6) - temple (~> 0.7.3) - tilt (>= 1.3.3, < 2.1) - spring (1.4.0) - sprockets (3.3.5) - rack (> 1, < 3) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) - sqlite3 (1.3.10) - stackprof (0.2.7) - streamio-ffmpeg (1.0.0) - temple (0.7.6) - therubyracer (0.12.2) - libv8 (~> 3.16.14.0) - ref - thor (0.19.1) - thread_safe (0.3.5) - tilt (2.0.1) - timers (4.1.1) - hitimes - turbolinks (2.5.3) - coffee-rails - tzinfo (1.2.2) - thread_safe (~> 0.1) - uglifier (2.7.2) - execjs (>= 0.3.0) - json (>= 1.8.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.1) - uniform_notifier (1.9.0) - unparser (0.2.4) - abstract_type (~> 0.0.7) - adamantium (~> 0.2.0) - concord (~> 0.1.5) - diff-lcs (~> 1.2.5) - equalizer (~> 0.0.9) - parser (~> 2.2.2) - procto (~> 0.0.2) - virtus (1.0.5) - axiom-types (~> 0.1) - coercible (~> 1.0) - descendants_tracker (~> 0.0, >= 0.0.3) - equalizer (~> 0.0, >= 0.0.9) - warden (1.2.3) - rack (>= 1.0) - web-console (2.2.1) - activemodel (>= 4.0) - binding_of_caller (>= 0.7.2) - railties (>= 4.0) - sprockets-rails (>= 2.0, < 4.0) - whenever (0.9.4) - chronic (>= 0.6.3) - -PLATFORMS - ruby - -DEPENDENCIES - bcrypt (~> 3.1.7) - better_errors - bootstrap-sass - bullet - byebug - chart-js-rails - coffee-rails (~> 4.1.0) - curb (~> 0.8.8) - dalli - devise - devise_token_auth - dspace_rest_client (~> 1.1.0) - execjs - flamegraph - jbuilder (~> 2.0) - jquery-rails - jquery-turbolinks - jquery-ui-rails - kaminari - locastyle - mina - orientdb4r - paperclip - pg - puma - rack-cors - rack-mini-profiler - rails (= 4.2.0) - rdoc - rmagick - rsolr (~> 1.0.12) - rubycritic - sass-rails (~> 5.0) - sdoc (~> 0.4.0) - select2-rails - shoulda - shoulda-callback-matchers (~> 1.1.1) - sidekiq - sinatra - slim - spring - sqlite3 - stackprof - streamio-ffmpeg (~> 1.0.0) - therubyracer - turbolinks - uglifier (>= 1.3.0) - web-console (~> 2.0) - whenever diff --git a/app/controllers/management/complaints_controller.rb b/app/controllers/management/complaints_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..1a85550fb2053970bc3b0b70ffc5abf86f4d2182 --- /dev/null +++ b/app/controllers/management/complaints_controller.rb @@ -0,0 +1,29 @@ +class Management::ComplaintsController < ManagementController + include RepositoriesProxy + + def index + + end + + def show + @complaints = complaint_repository.get_complaints + + @complaints.each do |c| + c.user = User.find_by(rid: c.user) + c.object = learning_object_repository.get_by_rid(c.object) + end + end + + def destroy + + object_rid = params["object_rid"] + user_rid = params["user_rid"] + complaint_repository.destroy(user_rid, object_rid) + + respond_to do |format| + format.html { redirect_to :back, notice: 'Complaint was successfully destroyed.' } + end + + end + +end diff --git a/app/controllers/management/statistics_controller.rb b/app/controllers/management/statistics_controller.rb index 761e080cf8cdd2505852223a2af780b4c67fc8d8..de7f7136763003973b109344f725ea8193c1d9f4 100644 --- a/app/controllers/management/statistics_controller.rb +++ b/app/controllers/management/statistics_controller.rb @@ -10,7 +10,7 @@ class Management::StatisticsController < ManagementController end def users - #missing roles + #missing roles @n_users = subject_repository.get_number_of("User") end diff --git a/app/repositories/orient_db/complaint_repository.rb b/app/repositories/orient_db/complaint_repository.rb index b2454f176d9afefb29a4411e005948ea9ab29cf5..6861675192c531c4c27d9f67e381d172afbe6a7c 100644 --- a/app/repositories/orient_db/complaint_repository.rb +++ b/app/repositories/orient_db/complaint_repository.rb @@ -11,18 +11,35 @@ module OrientDb end end - def destroy(object) - if !edge_exists?(odb_class, complaint.user.rid, complaint.object) + def destroy(user_rid,object_rid) + if !edge_exists?(odb_class, user_rid, object_rid) raise "The object has not been reported by you yet." end - connection.command "DELETE EDGE Complaint FROM #{complaint.user.rid} TO #{complaint.object}" + connection.command "DELETE EDGE Complaint FROM #{user_rid} TO #{object_rid}" end def build_object(args={}) Complaint.new(args) end + def get_complaints + result = connection.command "SELECT FROM Complaint" + build_complaint result + end + + + def build_complaint(args) + complaint = Array.new + for i in 0..args["result"].length-1 + unless args.nil? + complaint[i] = Complaint.new(:user => args["result"][i]["out"], :object => args["result"][i]["in"], :message => args["result"][i]["message"], :description =>args["result"][i]["description"]) + end + end + complaint + end + + protected def odb_class diff --git a/app/repositories/orient_db/user_repository.rb b/app/repositories/orient_db/user_repository.rb index 7a904ba1cb44a3d9391054b95662d31878103d9a..5d482f8fee7ebc425650bd85a5c57bc54cbce8d8 100644 --- a/app/repositories/orient_db/user_repository.rb +++ b/app/repositories/orient_db/user_repository.rb @@ -1,5 +1,6 @@ module OrientDb class UserRepository < Base + include OrientDb::Methods::FinderMethods include RepositoriesProxy def create_graph_node(user) @@ -31,6 +32,7 @@ module OrientDb (result.count > 0) end + private def odb_class diff --git a/app/repositories/user_repository_proxy.rb b/app/repositories/user_repository_proxy.rb index 3c43aae345d77ac3c8a83d36c7e89db77213c02b..da98609d8e33944d7a9d092b9b0f2d84dc4f8d31 100644 --- a/app/repositories/user_repository_proxy.rb +++ b/app/repositories/user_repository_proxy.rb @@ -2,6 +2,7 @@ # When some client call UserRepositoryProxy, it will delegate the missing methods for ActiveRecord User model class UserRepositoryProxy + def initialize(orientdb_user_repository) @orientdb_user_repository = orientdb_user_repository end @@ -16,6 +17,10 @@ class UserRepositoryProxy end end + def get_by_rid(rid) + orientdb_user_repository.get_by_rid(rid) + end + def get_graph_id(user) orientdb_user_repository.get_graph_id user end diff --git a/app/views/management/complaints/show.html.erb b/app/views/management/complaints/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..4cbc88e5dba345fd5c48a5fb8079c30ba7f0f1b0 --- /dev/null +++ b/app/views/management/complaints/show.html.erb @@ -0,0 +1,28 @@ +<ol class="ls-breadcrumb"> + <li><%= link_to "InÃcio", management_root_path %></li> + <li>Denúncias</li> +</ol> +<br><br> + + +<h3><b>Total de denúncias: <%= @complaints.count %></b></h3> <BR><BR> + + + +<% @complaints.each do |c| %> + <div class="ls-box-filter"> + Denúncia de <b><%= c.user.name %></b> para o objeto <%= link_to c.object["title"], learning_object_path(c.object["@rid"]) %><BR> + <BR> + <b>Mensagem:</b> <%= c.message %><BR> + <BR> + <b>Descrição:</b> <%= c.description == "" ? "--" : c.description %><BR> + + <div id="suspend", class="ls-btn ls-float-right"> + <%= link_to 'Excluir Denúncia', management_complaints_path(:object_rid => c.object["@rid"], :user_rid => c.user.rid), {method: :delete, data: { confirm: 'Tem certeza que deseja excluir?'}, title: 'Apagar usuário', class: 'ls-color-danger', role: 'option'} %> + </div> + + <div id="suspend", class="ls-btn ls-float-right"> + Suspender conteúdo + </div> + </div> +<%end%> diff --git a/app/views/shared/management/_nav_menu.html.erb b/app/views/shared/management/_nav_menu.html.erb index e86d2e3e0a9865996ce9720b9f482ef1dd3884cd..c48377d76cff06d6be5ebfb486ddf1627368d743 100644 --- a/app/views/shared/management/_nav_menu.html.erb +++ b/app/views/shared/management/_nav_menu.html.erb @@ -22,7 +22,7 @@ <li><%= link_to "Administradores", '#', class: 'ls-submenu-item' %></li> </ul> </li> - <li><%= link_to "Denúncias", '#', class: 'ls-ico-bullhorn' %> + <li><%= link_to "Denúncias", management_complaints_path, class: 'ls-ico-bullhorn' %> <li> </ul> </nav> diff --git a/config/routes.rb b/config/routes.rb index de116f1485583880e37d992ec5234a810baefbbc..702461711c2943047bcd8670b84faea76aa4f278 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,8 @@ Rails.application.routes.draw do namespace :management do root 'welcome#index' + resource :complaints + resources :statistics do collection do get :users @@ -56,7 +58,7 @@ Rails.application.routes.draw do end resources :subjects, only: [:index, :show] - resources :complaints, only: [:create, :destroy] + #resources :complaints, only: [:create, :destroy] resources :users, only: [:show] do collection do