Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • portalmec/portalmec
  • rfhferreira/cleanning-portalmec
2 results
Show changes
Commits on Source (14)
Showing
with 1159 additions and 255 deletions
......@@ -25,6 +25,7 @@ Gemfile.lock
/shared/*
dump.rdb
/public/system/*
/db/seeds/assets/*
# ignore server scripts
puma.sh
......@@ -37,4 +38,4 @@ autocomplete-server.service
# ignore configs
/config/database.yml
/config/sidekiq.yml
\ No newline at end of file
/config/sidekiq.yml
......@@ -145,7 +145,11 @@ gem 'activerecord-import'
# social connect
gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem 'omniauth-google-oauth2', '~>0.8.2'
gem 'omniauth-google-oauth2', '0.8.2'
gem 'faraday'
gem 'net-http-persistent'
# get mime type
gem 'mimemagic'
......@@ -172,3 +176,7 @@ gem 'paranoia'
gem 'paper_trail'
gem 'acts_as_list'
gem 'faraday-net_http_persistent', '~> 2.0'
gem 'elasticsearch', '< 7.14'
......@@ -12,101 +12,107 @@ GIT
GIT
remote: https://github.com/kreeti/kt-paperclip.git
revision: ab1016d77336a8d7b9db72eb29b6bd19af4027fc
revision: 7f73b7442743f57fb957b4bb54c1bca11ddd1c72
branch: master
specs:
kt-paperclip (6.4.1)
kt-paperclip (7.1.1)
activemodel (>= 4.2.0)
activesupport (>= 4.2.0)
marcel (~> 1.0.1)
mime-types
mimemagic (~> 0.3.0)
terrapin (~> 0.6.0)
GIT
remote: https://github.com/lynndylanhurley/devise_token_auth.git
revision: 4c5245b88b39c1bb305e0cbdbfc2513eebdeda93
revision: 8f44a8c66fd772b2d33be4ba187c0b1a47caba2a
branch: master
specs:
devise_token_auth (1.2.0)
bcrypt (~> 3.0)
devise (> 3.5.2, < 5)
rails (>= 4.2.0, < 6.2)
rails (>= 4.2.0, < 7.1)
GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.4)
actionpack (= 6.1.4)
activesupport (= 6.1.4)
actioncable (7.0.3)
actionpack (= 7.0.3)
activesupport (= 7.0.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.4)
actionpack (= 6.1.4)
activejob (= 6.1.4)
activerecord (= 6.1.4)
activestorage (= 6.1.4)
activesupport (= 6.1.4)
actionmailbox (7.0.3)
actionpack (= 7.0.3)
activejob (= 7.0.3)
activerecord (= 7.0.3)
activestorage (= 7.0.3)
activesupport (= 7.0.3)
mail (>= 2.7.1)
actionmailer (6.1.4)
actionpack (= 6.1.4)
actionview (= 6.1.4)
activejob (= 6.1.4)
activesupport (= 6.1.4)
net-imap
net-pop
net-smtp
actionmailer (7.0.3)
actionpack (= 7.0.3)
actionview (= 7.0.3)
activejob (= 7.0.3)
activesupport (= 7.0.3)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (6.1.4)
actionview (= 6.1.4)
activesupport (= 6.1.4)
rack (~> 2.0, >= 2.0.9)
actionpack (7.0.3)
actionview (= 7.0.3)
activesupport (= 7.0.3)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.4)
actionpack (= 6.1.4)
activerecord (= 6.1.4)
activestorage (= 6.1.4)
activesupport (= 6.1.4)
actiontext (7.0.3)
actionpack (= 7.0.3)
activerecord (= 7.0.3)
activestorage (= 7.0.3)
activesupport (= 7.0.3)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (6.1.4)
activesupport (= 6.1.4)
actionview (7.0.3)
activesupport (= 7.0.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_model_serializers (0.10.12)
actionpack (>= 4.1, < 6.2)
activemodel (>= 4.1, < 6.2)
active_model_serializers (0.10.13)
actionpack (>= 4.1, < 7.1)
activemodel (>= 4.1, < 7.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (6.1.4)
activesupport (= 6.1.4)
activejob (7.0.3)
activesupport (= 7.0.3)
globalid (>= 0.3.6)
activemodel (6.1.4)
activesupport (= 6.1.4)
activerecord (6.1.4)
activemodel (= 6.1.4)
activesupport (= 6.1.4)
activerecord-import (1.1.0)
activerecord (>= 3.2)
activestorage (6.1.4)
actionpack (= 6.1.4)
activejob (= 6.1.4)
activerecord (= 6.1.4)
activesupport (= 6.1.4)
marcel (~> 1.0.0)
activemodel (7.0.3)
activesupport (= 7.0.3)
activerecord (7.0.3)
activemodel (= 7.0.3)
activesupport (= 7.0.3)
activerecord-import (1.4.0)
activerecord (>= 4.2)
activestorage (7.0.3)
actionpack (= 7.0.3)
activejob (= 7.0.3)
activerecord (= 7.0.3)
activesupport (= 7.0.3)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.4)
activesupport (7.0.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
acts_as_list (1.0.4)
activerecord (>= 4.2)
addressable (2.7.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
annotate (3.1.1)
activerecord (>= 3.2, < 7.0)
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
ansi (1.5.0)
ast (2.4.2)
......@@ -114,16 +120,16 @@ GEM
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
bcrypt (3.1.16)
benchmark-ips (2.9.1)
bcrypt (3.1.18)
benchmark-ips (2.10.0)
better_errors (2.8.3)
coderay (>= 1.0.0)
erubi (>= 1.0.0)
rack (>= 0.9.0)
bindex (0.8.1)
brakeman (5.0.1)
brakeman (5.2.3)
builder (3.2.4)
bullet (6.1.4)
bullet (7.0.2)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
byebug (11.1.3)
......@@ -135,12 +141,12 @@ GEM
coderay (1.1.3)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.1.9)
concurrent-ruby (1.1.10)
connection_pool (2.2.5)
crass (1.0.6)
curb (0.9.11)
curb (1.0.1)
cvss (0.99.0)
dalli (2.7.11)
dalli (3.2.2)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
database_cleaner-active_record (2.0.1)
......@@ -157,8 +163,8 @@ GEM
sqlite3
sys-uname
terminal-table
dead_end (1.1.7)
derailed_benchmarks (2.1.0)
dead_end (4.0.0)
derailed_benchmarks (2.1.1)
benchmark-ips (~> 2)
dead_end
get_process_mem (~> 0)
......@@ -172,254 +178,282 @@ GEM
thor (>= 0.19, < 2)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.8.0)
devise (4.8.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.4.4)
diff-lcs (1.5.0)
digest (3.1.0)
docile (1.4.0)
elasticsearch (7.13.0)
elasticsearch-api (= 7.13.0)
elasticsearch-transport (= 7.13.0)
elasticsearch-api (7.13.0)
elasticsearch (7.13.3)
elasticsearch-api (= 7.13.3)
elasticsearch-transport (= 7.13.3)
elasticsearch-api (7.13.3)
multi_json
elasticsearch-transport (7.13.0)
elasticsearch-transport (7.13.3)
faraday (~> 1)
multi_json
equalizer (0.0.11)
erubi (1.10.0)
erubis (2.7.0)
execjs (2.8.1)
factory_bot (6.2.0)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
faker (2.18.0)
i18n (>= 1.6, < 2)
faraday (1.4.2)
faker (2.21.0)
i18n (>= 1.8.11, < 2)
faraday (1.9.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
multipart-post (>= 1.2, < 3)
faraday-httpclient (< 3)
faraday-multipart (~> 1.0)
faraday-net_http (< 3)
faraday-net_http_persistent (< 3)
faraday-patron (< 3)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.1.0)
faraday-httpclient (2.0.1)
httpclient (>= 2.2)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (2.0.3)
faraday-net_http_persistent (2.0.1)
faraday-net_http
net-http-persistent (~> 4.0)
faraday-patron (2.0.1)
patron (>= 0.4.2)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
feature (1.4.0)
ffi (1.15.1)
ffi-libarchive (1.0.17)
ffi (1.15.5)
ffi-libarchive (1.1.3)
ffi (~> 1.0)
flamegraph (0.9.5)
flay (2.12.1)
erubis (~> 2.7.0)
flay (2.13.0)
erubi (~> 1.10)
path_expander (~> 1.0)
ruby_parser (~> 3.0)
sexp_processor (~> 4.0)
flog (4.6.4)
flog (4.6.5)
path_expander (~> 1.0)
ruby_parser (~> 3.1, > 3.1.0)
sexp_processor (~> 4.8)
get_process_mem (0.2.7)
ffi (~> 1.0)
gitlab (4.17.0)
gitlab (4.18.0)
httparty (~> 0.18)
terminal-table (~> 1.5, >= 1.5.1)
globalid (0.5.1)
terminal-table (>= 1.5.1)
globalid (1.0.0)
activesupport (>= 5.0)
haml (5.2.1)
haml (5.2.2)
temple (>= 0.8.0)
tilt
hashie (4.1.0)
hashie (5.0.0)
heapy (0.2.0)
thor
httparty (0.18.1)
httparty (0.20.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.8.10)
httpclient (2.8.3)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
immigrant (0.3.6)
activerecord (>= 3.0)
json (2.5.1)
json (2.6.2)
jsonapi-renderer (0.2.2)
justify (1.0.2)
jwt (2.2.3)
jwt (2.4.1)
kwalify (0.7.2)
launchy (2.5.0)
addressable (~> 2.7)
logger-colors (1.0.0)
loofah (2.10.0)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.1)
marcel (1.0.2)
memory_profiler (1.0.0)
method_source (1.0.0)
mime-types (3.3.1)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0225)
mimemagic (0.3.10)
mime-types-data (3.2022.0105)
mimemagic (0.4.3)
nokogiri (~> 1)
rake
mina (1.2.3)
mina (1.2.4)
open4 (~> 1.3.4)
rake
mini_histogram (0.3.1)
mini_mime (1.1.0)
mini_portile2 (2.5.3)
minitest (5.14.4)
minitest-reporters (1.4.3)
mini_mime (1.1.2)
minitest (5.16.1)
minitest-reporters (1.5.0)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
multipart-post (2.2.3)
mustache (1.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
net-http-persistent (4.0.1)
connection_pool (~> 2.2)
nio4r (2.5.7)
nokogiri (1.11.7)
mini_portile2 (~> 2.5.0)
net-imap (0.2.3)
digest
net-protocol
strscan
net-pop (0.1.1)
digest
net-protocol
timeout
net-protocol (0.1.3)
timeout
net-smtp (0.3.1)
digest
net-protocol
timeout
nio4r (2.5.8)
nokogiri (1.13.6-x86_64-linux)
racc (~> 1.4)
oauth (0.5.6)
oauth2 (1.4.7)
faraday (>= 0.8, < 2.0)
oauth (0.5.10)
oauth2 (1.4.9)
faraday (>= 0.17.3, < 3.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (2.0.4)
omniauth (1.9.1)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
rack-protection
omniauth-facebook (8.0.0)
omniauth-facebook (9.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-google-oauth2 (1.0.0)
omniauth-google-oauth2 (0.8.2)
jwt (>= 2.0)
oauth2 (~> 1.1)
omniauth (~> 2.0)
omniauth-oauth2 (~> 1.7.1)
omniauth (~> 1.1)
omniauth-oauth2 (>= 1.6)
omniauth-oauth (1.2.0)
oauth
omniauth (>= 1.0, < 3)
omniauth-oauth2 (1.7.1)
oauth2 (~> 1.4)
omniauth-oauth2 (1.7.3)
oauth2 (>= 1.4, < 3)
omniauth (>= 1.9, < 3)
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
open4 (1.3.4)
orm_adapter (0.5.0)
paper_trail (12.0.0)
paper_trail (12.3.0)
activerecord (>= 5.2)
request_store (~> 1.1)
parallel (1.20.1)
paranoia (2.4.3)
activerecord (>= 4.0, < 6.2)
parser (3.0.1.1)
parallel (1.22.1)
paranoia (2.6.0)
activerecord (>= 5.1, < 7.1)
parser (3.1.2.0)
ast (~> 2.4.1)
path_expander (1.1.0)
pg (1.2.3)
patron (0.13.3)
pg (1.4.1)
phantomjs (2.1.1.0)
psych (3.3.2)
psych (4.0.4)
stringio
ptools (1.4.2)
public_activity (1.6.4)
actionpack (>= 3.0.0)
activerecord (>= 3.0)
public_activity (2.0.1)
actionpack (>= 5.0.0)
activerecord (>= 5.0)
i18n (>= 0.5.0)
railties (>= 3.0.0)
public_suffix (4.0.6)
puma (5.3.2)
railties (>= 5.0.0)
public_suffix (4.0.7)
puma (5.6.4)
nio4r (~> 2.0)
pundit (2.1.0)
pundit (2.2.0)
activesupport (>= 3.0.0)
racc (1.5.2)
rack (2.2.3)
rack-attack (6.5.0)
racc (1.6.0)
rack (2.2.3.1)
rack-attack (6.6.1)
rack (>= 1.0, < 3)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-mini-profiler (2.3.2)
rack-mini-profiler (3.0.0)
rack (>= 1.2.0)
rack-protection (2.1.0)
rack-protection (2.2.0)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.1.4)
actioncable (= 6.1.4)
actionmailbox (= 6.1.4)
actionmailer (= 6.1.4)
actionpack (= 6.1.4)
actiontext (= 6.1.4)
actionview (= 6.1.4)
activejob (= 6.1.4)
activemodel (= 6.1.4)
activerecord (= 6.1.4)
activestorage (= 6.1.4)
activesupport (= 6.1.4)
rack-test (2.0.1)
rack (>= 1.3)
rails (7.0.3)
actioncable (= 7.0.3)
actionmailbox (= 7.0.3)
actionmailer (= 7.0.3)
actionpack (= 7.0.3)
actiontext (= 7.0.3)
actionview (= 7.0.3)
activejob (= 7.0.3)
activemodel (= 7.0.3)
activerecord (= 7.0.3)
activestorage (= 7.0.3)
activesupport (= 7.0.3)
bundler (>= 1.15.0)
railties (= 6.1.4)
sprockets-rails (>= 2.0.0)
railties (= 7.0.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-erd (1.6.1)
rails-erd (1.7.1)
activerecord (>= 4.2)
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.3.0)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
railties (6.1.4)
actionpack (= 6.1.4)
activesupport (= 6.1.4)
railties (7.0.3)
actionpack (= 7.0.3)
activesupport (= 7.0.3)
method_source
rake (>= 0.13)
rake (>= 12.2)
thor (~> 1.0)
rainbow (3.0.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
rdoc (6.3.1)
redis (4.2.5)
reek (6.0.4)
rdoc (6.4.0)
psych (>= 4.0.0)
redis (4.7.0)
reek (6.1.1)
kwalify (~> 0.7.0)
parser (~> 3.0.0)
psych (~> 3.1)
parser (~> 3.1.0)
rainbow (>= 2.0, < 4.0)
regexp_parser (2.1.1)
request_store (1.5.0)
regexp_parser (2.5.0)
request_store (1.5.1)
rack (>= 1.4)
resource_kit (0.1.7)
resource_kit (0.1.8)
addressable (>= 2.3.6, < 3.0.0)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
rmagick (4.2.2)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
rmagick (4.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-rails (5.0.1)
rspec-support (~> 3.11.0)
rspec-rails (5.1.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
......@@ -427,30 +461,30 @@ GEM
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.2)
rspec-support (3.11.0)
rspec_api_documentation (6.1.0)
activesupport (>= 3.0.0)
mustache (~> 1.0, >= 0.99.4)
rspec (~> 3.0)
rubocop (1.15.0)
rubocop (1.31.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.5.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.18.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.6.0)
parser (>= 3.0.1.1)
rubocop-ast (1.18.0)
parser (>= 3.1.1.0)
ruby-graphviz (1.2.5)
rexml
ruby-progressbar (1.11.0)
ruby-statistics (2.1.3)
ruby2_keywords (0.0.4)
ruby_parser (3.16.0)
sexp_processor (~> 4.15, >= 4.15.1)
rubycritic (4.6.1)
ruby-statistics (3.0.0)
ruby2_keywords (0.0.5)
ruby_parser (3.19.1)
sexp_processor (~> 4.16)
rubycritic (4.7.0)
flay (~> 2.8)
flog (~> 4.4)
launchy (>= 2.0.0)
......@@ -461,23 +495,22 @@ GEM
simplecov (>= 0.17.0)
tty-which (~> 0.4.0)
virtus (~> 1.0)
rubyzip (2.3.0)
rubyzip (2.3.2)
screencap (0.1.4)
phantomjs
sdoc (2.2.0)
sdoc (2.4.0)
rdoc (>= 5.0)
searchkick (4.4.4)
activemodel (>= 5)
elasticsearch (>= 6)
searchkick (5.0.4)
activemodel (>= 5.2)
hashie
sexp_processor (4.15.3)
sexp_processor (4.16.1)
shoulda (4.0.0)
shoulda-context (~> 2.0)
shoulda-matchers (~> 4.0)
shoulda-context (2.0.0)
shoulda-matchers (4.5.1)
activesupport (>= 4.2.0)
sidekiq (6.2.1)
sidekiq (6.5.1)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
......@@ -486,41 +519,38 @@ GEM
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
sinatra (2.1.0)
simplecov_json_formatter (0.1.4)
sinatra (2.2.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
rack-protection (= 2.2.0)
tilt (~> 2.0)
slim (4.1.0)
temple (>= 0.7.6, < 0.9)
tilt (>= 2.0.6, < 2.1)
spring (2.1.1)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
stackprof (0.2.17)
spring (4.0.0)
sqlite3 (1.4.4)
stackprof (0.2.19)
streamio-ffmpeg (3.0.2)
multi_json (~> 1.8)
stringio (3.0.2)
strscan (3.0.3)
sys-uname (1.2.2)
ffi (~> 1.1)
temple (0.8.2)
terminal-table (1.6.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
terrapin (0.6.0)
climate_control (>= 0.0.3, < 1.0)
thor (1.1.0)
thor (1.2.1)
thread_safe (0.3.6)
tilt (2.0.10)
timeout (0.3.0)
tty-which (0.4.2)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.0.0)
uniform_notifier (1.14.2)
unicode-display_width (2.2.0)
uniform_notifier (1.16.0)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
......@@ -538,10 +568,10 @@ GEM
websocket-extensions (0.1.5)
whenever (1.0.0)
chronic (>= 0.6.3)
zeitwerk (2.4.2)
zeitwerk (2.6.0)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
active_model_serializers
......@@ -562,9 +592,12 @@ DEPENDENCIES
devise
devise_token_auth!
dspace_rest_client!
elasticsearch (< 7.14)
execjs
factory_bot_rails
faker
faraday
faraday-net_http_persistent (~> 2.0)
feature
ffi-libarchive
flamegraph
......@@ -574,8 +607,9 @@ DEPENDENCIES
mimemagic
mina
minitest-reporters
net-http-persistent
omniauth-facebook
omniauth-google-oauth2
omniauth-google-oauth2 (= 0.8.2)
omniauth-twitter
paper_trail
paranoia
......@@ -610,4 +644,4 @@ DEPENDENCIES
whenever
BUNDLED WITH
2.2.15
2.3.15
......@@ -28,8 +28,10 @@ class ApplicationController < ActionController::API
rescue_from Exception do |exception|
logger.fatal "The request raised an exception:"
http_request_headers = request.headers.select{|header_name, header_value| header_name.match("^HTTP.*")}
logger.fatal "#{request.method.inspect} request to #{request.url.inspect} from #{request.remote_ip.inspect} with headers #{http_request_headers.inspect} and params #{params.inspect} gave the following exception:"
logger.fatal exception
logger.fatal exception.backtrace.first(10).join("\n")
logger.fatal exception.backtrace.first(15).join("\n")
unless response_body
render status: :internal_server_error
end
......
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
module ItemsFilter
extend ActiveSupport::Concern
def filter_items(items)
# filter by type
if !params[:item_type].blank?
items = items.where(item_type: params[:item_type])
end
# filter by price
if params[:op] == "lt" # less than
items = items.where("price < ?", params[:price])
elsif params[:op] == "gt" # greater than
items = items.where("price > ?", params[:price])
elsif params[:op] == "eq" # equals
items = items.where(price: params[:price])
end
# filter by the way it's unlocked
if params[:unlock_rule] == "achievement"
items = items.where.not(achievement_id: nil)
elsif params[:unlock_rule] == "purchase"
items = items.where(achievement_id: nil)
end
items
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::AchievementsController < ApplicationController
include ::Paginator
before_action :set_achievement, only: [:show, :update, :destroy]
before_action :authenticate_user!, except: [:index, :show]
before_action :authorize!, only: [:update, :destroy]
# GET /v1/achievements
def index
achievements = paginate Achievement
render json: achievements
end
# GET /v1/achievements/1
def show
render json: @achievement
end
# POST /v1/achievements
def create
@achievement = Achievement.new(achievement_params)
authorize @achievement
if @achievement.save
@achievement.add_requirements(extra_params[:requirements])
render json: @achievement, status: :created
else
render json: @achievement.errors, status: :unprocessable_entity
end
end
# PUT/PATCH /v1/achievements/1
def update
if @achievement.update(achievement_params)
@achievement.update_requirements(extra_params[:requirements])
render json: @achievement, status: :ok
else
render json: @achievement.errors, status: :unprocessable_entity
end
end
# DELETE /v1/achievements/1
def destroy
if @achievement.update(state: 2)
render status: :ok, json: @achievement
else
render json: @achievement.errors, status: :unprocessable_entity
end
end
private
def set_achievement
@achievement ||= Achievement.find_by_id(params[:id])
if @achievement.blank?
render status: :not_found
end
end
def achievement_params
params.require(:achievement).permit(:name, :description, :reward_experience, :reward_points, :state, :repeatable, :resettable)
end
def extra_params
return {} if params[:achievement].nil?
params[:achievement].permit(requirements: [])
end
def authorize!
authorize @achievement
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::ActionCountersController < ApplicationController
include ::Paginator
before_action :set_action_counter, only: :show
def index
action_counters = paginate ActionCounter
render json: action_counters
end
def show
render json: @action_counter
end
private
def set_action_counter
@action_counter ||= ActionCounter.find_by_id(params[:id])
if @action_counter.blank?
render status: :not_found
end
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::ActionsController < ApplicationController
include ::Paginator
before_action :set_action, only: [:show, :update, :destroy]
before_action :authenticate_user!, except: [:index, :show]
before_action :authorize!, only: [:update, :destroy]
# GET /v1/actions
def index
actions = paginate Action
render json: actions
end
# GET /v1/actions/1
def show
render json: @action
end
# POST /v1/actions
def create
@action = Action.new(action_params)
authorize @action
if @action.save
render json: @action, status: :created
else
render json: @action.errors, status: :unprocessable_entity
end
end
# PUT/PATCH /v1/actions/1
def update
if @action.update(action_params)
render json: @action, status: :ok
else
render json: @action.errors, status: :unprocessable_entity
end
end
# DELETE /v1/actions/1
def destroy
@action.destroy
response = { 'status': 'deleted' }
render status: :ok, json: response
end
private
def set_action
@action ||= Action.find_by_id(params[:id])
if @action.blank?
render status: :not_found
end
end
def action_params
params.require(:action_params).permit(:name, :description, :reward_experience)
end
def authorize!
authorize @action
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::ItemsController < ApplicationController
include ::Paginator
include ::ItemsFilter
before_action :set_item, only: [:show, :update, :destroy]
before_action :authenticate_user!, except: [:index, :show]
before_action :authorize!, only: [:update, :destroy]
def index
items = paginate filter_items(policy_scope(Item))
render json: items
end
def show
render json: @item
end
def create
@item = Item.new(item_params)
authorize @item
if @item.save
render json: @item, status: :created
else
render json: @item.errors, status: :unprocessable_entity
end
end
# PUT/PATCH /v1/items/1
def update
if @item.update(item_params)
render json: @item, status: :ok
else
render json: @item.errors, status: :unprocessable_entity
end
end
# DELETE /v1/items/1
def destroy
if @item.update(state: 2)
render status: :ok, json: @item
else
render json: @item.errors, status: :unprocessable_entity
end
end
private
def set_item
@item ||= Item.find_by_id(params[:id])
if @item.blank?
render status: :not_found
end
end
def item_params
params.require(:item).permit(:name, :price, :discount, :description, :state, :item_type, :image, :achievement_id)
end
def authorize!
authorize @item
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::ProgressesController < ApplicationController
include ::Paginator
before_action :set_progress, only: :show
before_action :authenticate_user!, only: :index
def index
progresses = paginate current_user.progresses
render json: progresses, each_serializer: ProgressSerializer
end
def show
render json: @progress, serializer: ProgressSerializer
end
private
def set_progress
@progress ||= Progress.find_by_id(params[:id])
if @progress.blank?
render status: :not_found
end
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::RequirementsController < ApplicationController
include ::Paginator
before_action :set_requirement, only: [:show, :update, :destroy]
before_action :authenticate_user!, except: [:index, :show]
before_action :authorize!, only: [:update, :destroy]
def index
requirements = paginate Requirement
render json: requirements
end
def show
render json: @requirement
end
def create
@requirement = Requirement.new(requirement_params)
authorize @requirement
if @requirement.save
@requirement.add_achievements(extra_params[:achievements])
render json: @requirement, status: :created
else
render json: @requirement.errors, status: :unprocessable_entity
end
end
# PUT/PATCH /v1/requirements/1
def update
if @requirement.update(requirement_params)
@requirement.update_achievements(extra_params[:achievements])
render json: @requirement, status: :ok
else
render json: @requirement.errors, status: :unprocessable_entity
end
end
# DELETE /v1/requirements/1
def destroy
@requirement.destroy
response = { 'status': 'deleted' }
render status: :ok, json: response
end
private
def set_requirement
@requirement ||= Requirement.find_by_id(params[:id])
if @requirement.blank?
render status: :not_found
end
end
def requirement_params
params.require(:requirement).permit(:description, :goal, :repeatable, :action_id)
end
def extra_params
return {} if params[:requirement].nil?
params[:requirement].permit(achievements: [])
end
def authorize!
authorize @requirement
end
end
......@@ -19,48 +19,75 @@
require 'open-uri'
class V1::SessionsController < DeviseTokenAuth::SessionsController
#function to create a new session
def create
# Check
field = (resource_params.keys.map(&:to_sym) & resource_class.authentication_keys).first
#verify if the user exist and is active
if User.find_by_email(resource_params[:email]).present?
if User.find_by_email(resource_params[:email]).confirmed_at.present?
field = (resource_params.keys.map(&:to_sym) & resource_class.authentication_keys).first
@resource = nil
@resource = nil
if field
q_value = get_case_insensitive_field_from_resource_params(field)
if field
q_value = get_case_insensitive_field_from_resource_params(field)
@resource = find_resource(field, q_value)
end
@resource = find_resource(field, q_value)
end
if @resource && valid_params?(field, q_value) && (!@resource.respond_to?(:active_for_authentication?) || @resource.active_for_authentication?)
valid_password = @resource.valid_password?(resource_params[:password])
if (@resource.respond_to?(:valid_for_authentication?) && !@resource.valid_for_authentication? { valid_password }) || !valid_password
return render_create_error_bad_credentials
end
@token = @resource.create_token
@resource.save
#verify the credentials
if @resource && valid_params?(field, q_value) && (!@resource.respond_to?(:active_for_authentication?) || @resource.active_for_authentication?)
valid_password = @resource.valid_password?(resource_params[:password])
if (@resource.respond_to?(:valid_for_authentication?) && !@resource.valid_for_authentication? { valid_password }) || !valid_password
return render_create_error_bad_credentials
end
@token = @resource.create_token
@resource.save
sign_in(:user, @resource, store: false, bypass: false)
yield @resource if block_given?
sign_in(:user, @resource, store: false, bypass: false)
render_create_success
yield @resource if block_given?
elsif @resource && !(!@resource.respond_to?(:active_for_authentication?) || @resource.active_for_authentication?)
# verify if user is to be reactivated
reactivate_user?
if @resource.blocked?
render_create_error_blocked
elsif @resource.banished?
render_create_error_banished
end
render_create_success
elsif @resource && !(!@resource.respond_to?(:active_for_authentication?) || @resource.active_for_authentication?)
# verify if user is to be reactivated
reactivate_user?
if @resource.blocked?
render_create_error_blocked
elsif @resource.banished?
render_create_error_banished
else
render_create_error_bad_credentials
end
#in case of the user is not confirmed, find the user and send an email confirmation
else
return render_create_error_not_confirmed
end
else
render_create_error_bad_credentials
else
return render_create_error_bad_credentials
end
end
def render_create_error_not_confirmed
render json: {
success: false,
errors: [ I18n.t("devise.failure.unconfirmed")],
}, status: 417
end
def render_create_error_banished
render json: {
success: false,
errors: [ I18n.t("devise.sessions.banished")]
}, status: 401
}, status: 406
end
def render_create_error_blocked
......@@ -68,7 +95,7 @@ require 'open-uri'
success: false,
errors: [ I18n.t("devise.sessions.blocked")],
avaliable_at: @resource.reactivated_at
}, status: 401
}, status: 406
end
def reactivate_user?
......
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::UnlockedAchievementsController < ApplicationController
include ::Paginator
before_action :set_achievement, only: :show
before_action :authenticate_user!, only: :index
def index
achievements = paginate current_user.unlocked_achievements
render json: achievements
end
def show
render json: @achievement
end
private
def set_achievement
@achievement ||= UnlockedAchievement.find_by_id(params[:id])
if @achievement.blank?
render status: :not_found
end
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::UserItemsController < ApplicationController
include ::Paginator
include ::ItemsFilter
before_action :set_user_item, only: :show
before_action :authenticate_user!, only: :index
def index
items = paginate filter_items(current_user.items.active)
render json: items
end
def show
render json: @user_item
end
private
def set_user_item
@user_item ||= UserItem.find_by_id(params[:id])
if @user_item.blank?
render status: :not_found
end
end
end
......@@ -22,15 +22,110 @@ class V1::UsersController < ApplicationController
include ::DeletedObjectsController
include ::Paginator
include ::PublisherController
include ::SubjectableController
include ::SubjectableController
include ::ItemsFilter
before_action :set_user, only: [:show, :update, :destroy, :following, :own_reviews, :received_reviews, :followers, :add_teacher, :remove_teacher, :reactivate_user]
before_action :set_user, only: [:show, :update, :destroy, :following, :own_reviews, :received_reviews, :followers, :add_teacher, :remove_teacher, :reactivate_user, :items]
before_action :set_new_user, only: [:teacher_requests, :teacher_request]
before_action :authenticate_user!, only: [:create, :update, :destroy,
:following, :own_reviews, :received_reviews, :followers, :create_teacher_request, :update_teacher_request,
:teacher_requests, :add_teacher, :remove_teacher, :reactivate_user]
before_action :authorize_user, only: [:own_reviews, :received_reviews, :update, :destroy, :teacher_requests, :add_teacher, :remove_teacher]
# gamification
# POST /v1/users/complete_action
def complete_action
# current_user completes an action
# action counters and user progresses for achievements are updated,
# and if an achievement was conquered its rewards are given
quantity = params[:quantity].to_i > 1 ? params[:quantity].to_i : 1
success, response = current_user.complete_action(Action.where(id: params[:action_id]).first, quantity)
status = success ? :ok : :unprocessable_entity
render json: response, status: status
end
def confirm_email
@user = User.find_by_confirm_token(params[:id])
if @user
@user.email_activate
end
end
# POST /v1/users/purchase_item
def purchase_item
# purchases given item for current user
item = Item.find_by(id: params[:item_id])
user_item = UserItem.where(user: current_user, item: item).first
if !user_item.blank?
render json: { "error": "Você já possui este item." }, status: :unprocessable_entity
else
if current_user.points >= item.price - item.discount
current_user.points -= item.price - item.discount
if !current_user.save
render json: current_user.errors, status: :unprocessable_entity
else
current_user.add_user_item(item)
render json: current_user.user_items, status: :ok
end
else
render json: { "error": "Você não possui gemas suficientes para esta compra." }, status: :unprocessable_entity
end
end
end
# POST /v1/users/equip_item
def equip_item
if current_user.equip_item(Item.find_by(id: params[:item_id]))
render json: current_user.user_items, status: :ok
else
render json: current_user.errors, status: :unprocessable_entity
end
end
# POST /v1/users/unequip_item
def unequip_item
if current_user.unequip_item(Item.find_by(id: params[:item_id]))
render json: current_user.user_items, status: :ok
else
render json: current_user.errors, status: :unprocessable_entity
end
end
# POST /v1/users/remove_item
def remove_item
if current_user.remove_item(Item.find_by(id: params[:item_id]))
render json: current_user.user_items, status: :ok
else
render json: current_user.errors, status: :unprocessable_entity
end
end
# GET /v1/users/action_counters
def action_counters
# return action_counters and counters for given user
render json: paginate(current_user.action_counters), status: :ok
end
# GET /v1/users/completed_achievements
def completed_achievements
render json: paginate(current_user.unlocked_achievements), status: :ok
end
# GET /v1/users/:id/items
def items
query = {}
query[:items] = { item_type: params[:item_type] } if Item.item_types.keys.include? params[:item_type]
query[:being_used] = params[:being_used] if ["true", "false"].include? params[:being_used]
items = @user.user_items.includes(:item).where(query)
render json: paginate(items), status: :ok
end
#
# end gamification
# GET /v1/users
# GET /v1/users.json
def index
......@@ -51,6 +146,7 @@ class V1::UsersController < ApplicationController
authorize user
if user.save
UserMailer.welcome_email(user).deliver_now
render json: user, status: :created
else
render json: user.errors, status: :unprocessable_entity
......@@ -139,6 +235,7 @@ class V1::UsersController < ApplicationController
@user.submitter_request = :accepted
@user.roles << Role.where(name: "publisher")
if @user.save
@user.complete_action(Action.find_by_name("Autenticação de Professor"))
TeacherMailer.new_teacher_approved(@user).deliver_now
render status: :ok
else
......@@ -200,6 +297,10 @@ class V1::UsersController < ApplicationController
private
def xp_to_level(x)
(100 + Math.log([x, 900].min, 1.07)).floor
end
def deleted_resource
User
end
......
......@@ -18,7 +18,7 @@
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class ApplicationMailer < ActionMailer::Base
default to: 'plataformaintegrada@mec.gov.br'
#default to: 'plataformaintegrada@mec.gov.br'
default from: 'portalmec@inf.ufpr.br'
#layout 'mailer'
layout 'mailer'
end
class UserMailer < ActionMailer::Base
#set the default email sender
default from: 'portalmec_tec@inf.ufpr.br'
#function to send email to user when he/she is created through the admin panel
def welcome_email (user)
@user = user
mail(to: @user.email, subject: 'Bem vindo ao PortalMec!')
end
#function to send email confirmation to user, this view is located in app/views/user_mailer/email_confirmation.html.erb
def email_confirmation (user)
@user = user
mail(to: @user.email, subject: 'Confirmação de email')
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
# == Schema Information
#
# Table name: achievements
# t.string :name
# t.string :description
# t.integer :reward_experience
# t.integer :reward_points
# t.integer :state
# t.integer :repeatable
# t.boolean :resettable
# t.datetime :created_at
# t.datetime :updated_at
class Achievement < ApplicationRecord
has_many :items
has_many :unlocked_achievements
has_many :users, through: :unlocked_achievements
has_and_belongs_to_many :requirements
enum state: [:inactive, :active, :deleted]
enum repeatable: [:never, :daily, :weekly, :monthly, :yearly]
validates_presence_of :name, :description, :reward_experience, :reward_points, :state, :repeatable
def add_requirements(ids=[])
errors = []
ids.each do |requirement_id|
if !requirement_ids.include?(requirement_id)
requirement = Requirement.where(id: requirement_id).first
if !requirement.blank?
requirements << requirement
else
errors << {error_type:"inexistent", id: requirement_id}
end
else
errors << {error_type:"repeated", id: requirement_id}
end
end
return errors
end
def remove_requirements(ids=[])
ids.each do |requirement_id|
requirement = requirements.where(id: requirement_id).first
if !requirement.blank?
self.requirements.delete(requirement)
end
end
end
def update_requirements(ids)
ids ||= []
add_requirements(ids - requirement_ids)
remove_requirements(requirement_ids - ids)
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
# == Schema Information
#
# Table name: actions
# t.integer "name"
# t.integer "description"
# t.datetime "created_at"
# t.datetime "updated_at"
# t.integer "reward_experience"
# this table has the following foreign keys: requirements | action_counters
class Action < ApplicationRecord
has_many :requirements
has_many :action_counters
has_many :users, through: :action_counters
validates_presence_of :name, :description
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
# == Schema Information
#
# Table name: action_counters
# t.belongs_to :action, index: true
# t.belongs_to :user, index:true
# t.integer :counter, default: 0
# t.datetime "created_at", null: false
# t.datetime "updated_at", null: false
class ActionCounter < ApplicationRecord
belongs_to :action
belongs_to :user
validates_presence_of :user, :action
end