loading
Generated 2023-05-25T19:36:03-03:00

All Files ( 4.01% covered at 0.04 hits/line )

115 files in total.
3289 relevant lines, 132 lines covered and 3157 lines missed. ( 4.01% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/commands/authenticate_user.rb 0.00 % 32 25 0 25 0.00
app/commands/authorize_api_request.rb 0.00 % 37 30 0 30 0.00
app/controllers/admin/api_controller.rb 0.00 % 30 28 0 28 0.00
app/controllers/admin/associates_controller.rb 0.00 % 57 37 0 37 0.00
app/controllers/admin/authentication_controller.rb 0.00 % 19 15 0 15 0.00
app/controllers/admin/cruza_grafos_users_controller.rb 0.00 % 89 65 0 65 0.00
app/controllers/admins_controller.rb 0.00 % 55 44 0 44 0.00
app/controllers/application_controller.rb 0.00 % 47 36 0 36 0.00
app/controllers/associates_controller.rb 0.00 % 37 31 0 31 0.00
app/controllers/contact_controller.rb 0.00 % 42 33 0 33 0.00
app/controllers/contents_controller.rb 0.00 % 129 108 0 108 0.00
app/controllers/cruza_grafos_users_controller.rb 0.00 % 59 41 0 41 0.00
app/controllers/dashboards_controller.rb 0.00 % 6 5 0 5 0.00
app/controllers/exclusive_content_congress_controller.rb 0.00 % 71 60 0 60 0.00
app/controllers/exclusive_content_controller.rb 0.00 % 31 20 0 20 0.00
app/controllers/helpdesks_controller.rb 0.00 % 68 56 0 56 0.00
app/controllers/homes_controller.rb 0.00 % 111 91 0 91 0.00
app/controllers/institucional_persons_controller.rb 0.00 % 89 71 0 71 0.00
app/controllers/pages_controller.rb 0.00 % 65 54 0 54 0.00
app/controllers/payment_controller.rb 0.00 % 342 295 0 295 0.00
app/controllers/projects_controller.rb 0.00 % 67 55 0 55 0.00
app/controllers/sections_controller.rb 0.00 % 77 61 0 61 0.00
app/controllers/static_contents_controller.rb 0.00 % 60 41 0 41 0.00
app/controllers/transition_controller.rb 0.00 % 99 90 0 90 0.00
app/controllers/user_associate_admin_controller.rb 0.00 % 59 51 0 51 0.00
app/controllers/user_associate_controller.rb 0.00 % 86 74 0 74 0.00
app/controllers/users/confirmations_controller.rb 0.00 % 28 2 0 2 0.00
app/controllers/users/omniauth_callbacks_controller.rb 0.00 % 28 2 0 2 0.00
app/controllers/users/passwords_controller.rb 0.00 % 38 15 0 15 0.00
app/controllers/users/registrations_controller.rb 0.00 % 78 53 0 53 0.00
app/controllers/users/sessions_controller.rb 0.00 % 60 37 0 37 0.00
app/controllers/users/unlocks_controller.rb 0.00 % 28 2 0 2 0.00
app/controllers/users_controller.rb 0.00 % 171 134 0 134 0.00
app/facades/associates_facade.rb 0.00 % 81 63 0 63 0.00
app/forms/user_associate_admin_edit_form.rb 0.00 % 58 45 0 45 0.00
app/forms/user_associate_edit_form.rb 0.00 % 54 38 0 38 0.00
app/forms/user_associate_transition_form.rb 0.00 % 50 38 0 38 0.00
app/helpers/admin_associates_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/application_helper.rb 44.44 % 16 9 4 5 0.44
app/helpers/content_helper.rb 43.33 % 56 30 13 17 0.43
app/helpers/helpdesks_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/homes_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/pages_helper.rb 66.67 % 5 3 2 1 0.67
app/helpers/payment_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/projects_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/sections_helper.rb 30.00 % 20 10 3 7 0.30
app/helpers/static_contents_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/transition_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/user_associate_controller_helper.rb 100.00 % 2 1 1 0 1.00
app/inputs/cpf_input.rb 0.00 % 22 17 0 17 0.00
app/inputs/currency_input.rb 0.00 % 22 17 0 17 0.00
app/mailers/application_mailer.rb 0.00 % 4 4 0 4 0.00
app/mailers/contact_mailer.rb 0.00 % 12 10 0 10 0.00
app/mailers/cruza_grafos_mailer.rb 0.00 % 55 47 0 47 0.00
app/mailers/user_mailer.rb 0.00 % 66 56 0 56 0.00
app/models/activity_report.rb 0.00 % 5 5 0 5 0.00
app/models/admin.rb 53.85 % 24 13 7 6 0.54
app/models/application_record.rb 100.00 % 3 2 2 0 1.00
app/models/associate.rb 0.00 % 220 170 0 170 0.00
app/models/association_type.rb 0.00 % 3 3 0 3 0.00
app/models/audit_report.rb 0.00 % 5 5 0 5 0.00
app/models/ckeditor/asset.rb 0.00 % 7 5 0 5 0.00
app/models/ckeditor/attachment_file.rb 0.00 % 7 6 0 6 0.00
app/models/ckeditor/picture.rb 0.00 % 7 6 0 6 0.00
app/models/classroom_course.rb 0.00 % 16 12 0 12 0.00
app/models/classroom_course_info.rb 0.00 % 33 25 0 25 0.00
app/models/concerns/filterable.rb 54.55 % 48 33 18 15 0.70
app/models/concerns/publishable.rb 0.00 % 23 18 0 18 0.00
app/models/concerns/publishable_sections.rb 66.67 % 23 12 8 4 0.67
app/models/congress.rb 0.00 % 18 14 0 14 0.00
app/models/congress_info.rb 0.00 % 19 14 0 14 0.00
app/models/contact.rb 0.00 % 25 18 0 18 0.00
app/models/content.rb 0.00 % 72 58 0 58 0.00
app/models/course.rb 0.00 % 53 47 0 47 0.00
app/models/cruza_grafos_type.rb 0.00 % 3 3 0 3 0.00
app/models/cruza_grafos_user.rb 0.00 % 175 141 0 141 0.00
app/models/curator.rb 0.00 % 5 5 0 5 0.00
app/models/deponent.rb 0.00 % 5 5 0 5 0.00
app/models/director.rb 0.00 % 5 5 0 5 0.00
app/models/file_record.rb 0.00 % 3 3 0 3 0.00
app/models/helpdesk.rb 0.00 % 16 12 0 12 0.00
app/models/helpdesk_info.rb 0.00 % 13 9 0 9 0.00
app/models/home.rb 0.00 % 11 10 0 10 0.00
app/models/home_content.rb 0.00 % 9 7 0 7 0.00
app/models/home_primary_section.rb 100.00 % 4 3 3 0 1.00
app/models/home_secondary_section.rb 100.00 % 6 4 4 0 1.00
app/models/home_section.rb 100.00 % 9 6 6 0 1.00
app/models/institucional_person.rb 0.00 % 11 7 0 7 0.00
app/models/institucional_persons_group.rb 0.00 % 9 5 0 5 0.00
app/models/json_model.rb 0.00 % 15 12 0 12 0.00
app/models/main_menu_option.rb 0.00 % 7 6 0 6 0.00
app/models/news.rb 0.00 % 32 22 0 22 0.00
app/models/news_info.rb 0.00 % 23 18 0 18 0.00
app/models/online_course.rb 0.00 % 20 17 0 17 0.00
app/models/online_course_info.rb 0.00 % 27 21 0 21 0.00
app/models/payment.rb 0.00 % 185 151 0 151 0.00
app/models/person.rb 0.00 % 3 3 0 3 0.00
app/models/project.rb 0.00 % 14 11 0 11 0.00
app/models/project_info.rb 0.00 % 11 8 0 8 0.00
app/models/publication.rb 0.00 % 23 17 0 17 0.00
app/models/publication_info.rb 0.00 % 16 12 0 12 0.00
app/models/recent_documentation.rb 0.00 % 5 5 0 5 0.00
app/models/regulation.rb 0.00 % 5 5 0 5 0.00
app/models/section.rb 100.00 % 11 7 7 0 1.00
app/models/secundary_menu_option.rb 0.00 % 7 6 0 6 0.00
app/models/state.rb 0.00 % 7 6 0 6 0.00
app/models/static_content.rb 0.00 % 15 11 0 11 0.00
app/models/supervisor.rb 0.00 % 5 5 0 5 0.00
app/models/team.rb 0.00 % 5 5 0 5 0.00
app/models/transaction.rb 0.00 % 5 3 0 3 0.00
app/models/user.rb 64.71 % 62 34 22 12 0.65
lib/json_web_token.rb 0.00 % 15 14 0 14 0.00
lib/rails_admin/publish.rb 64.71 % 34 17 11 6 0.65
lib/rails_admin/unpublish.rb 64.71 % 34 17 11 6 0.65
lib/simple_form_extensions/button_components.rb 37.50 % 10 8 3 5 0.38

Controllers ( 0.0% covered at 0.0 hits/line )

31 files in total.
1707 relevant lines, 0 lines covered and 1707 lines missed. ( 0.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/controllers/admin/api_controller.rb 0.00 % 30 28 0 28 0.00
app/controllers/admin/associates_controller.rb 0.00 % 57 37 0 37 0.00
app/controllers/admin/authentication_controller.rb 0.00 % 19 15 0 15 0.00
app/controllers/admin/cruza_grafos_users_controller.rb 0.00 % 89 65 0 65 0.00
app/controllers/admins_controller.rb 0.00 % 55 44 0 44 0.00
app/controllers/application_controller.rb 0.00 % 47 36 0 36 0.00
app/controllers/associates_controller.rb 0.00 % 37 31 0 31 0.00
app/controllers/contact_controller.rb 0.00 % 42 33 0 33 0.00
app/controllers/contents_controller.rb 0.00 % 129 108 0 108 0.00
app/controllers/cruza_grafos_users_controller.rb 0.00 % 59 41 0 41 0.00
app/controllers/dashboards_controller.rb 0.00 % 6 5 0 5 0.00
app/controllers/exclusive_content_congress_controller.rb 0.00 % 71 60 0 60 0.00
app/controllers/exclusive_content_controller.rb 0.00 % 31 20 0 20 0.00
app/controllers/helpdesks_controller.rb 0.00 % 68 56 0 56 0.00
app/controllers/homes_controller.rb 0.00 % 111 91 0 91 0.00
app/controllers/institucional_persons_controller.rb 0.00 % 89 71 0 71 0.00
app/controllers/pages_controller.rb 0.00 % 65 54 0 54 0.00
app/controllers/payment_controller.rb 0.00 % 342 295 0 295 0.00
app/controllers/projects_controller.rb 0.00 % 67 55 0 55 0.00
app/controllers/sections_controller.rb 0.00 % 77 61 0 61 0.00
app/controllers/static_contents_controller.rb 0.00 % 60 41 0 41 0.00
app/controllers/transition_controller.rb 0.00 % 99 90 0 90 0.00
app/controllers/user_associate_admin_controller.rb 0.00 % 59 51 0 51 0.00
app/controllers/user_associate_controller.rb 0.00 % 86 74 0 74 0.00
app/controllers/users/confirmations_controller.rb 0.00 % 28 2 0 2 0.00
app/controllers/users/omniauth_callbacks_controller.rb 0.00 % 28 2 0 2 0.00
app/controllers/users/passwords_controller.rb 0.00 % 38 15 0 15 0.00
app/controllers/users/registrations_controller.rb 0.00 % 78 53 0 53 0.00
app/controllers/users/sessions_controller.rb 0.00 % 60 37 0 37 0.00
app/controllers/users/unlocks_controller.rb 0.00 % 28 2 0 2 0.00
app/controllers/users_controller.rb 0.00 % 171 134 0 134 0.00

Channels ( 100.0% covered at 0.0 hits/line )

0 files in total.
0 relevant lines, 0 lines covered and 0 lines missed. ( 100.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line

Models ( 7.16% covered at 0.08 hits/line )

56 files in total.
1076 relevant lines, 77 lines covered and 999 lines missed. ( 7.16% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/models/activity_report.rb 0.00 % 5 5 0 5 0.00
app/models/admin.rb 53.85 % 24 13 7 6 0.54
app/models/application_record.rb 100.00 % 3 2 2 0 1.00
app/models/associate.rb 0.00 % 220 170 0 170 0.00
app/models/association_type.rb 0.00 % 3 3 0 3 0.00
app/models/audit_report.rb 0.00 % 5 5 0 5 0.00
app/models/ckeditor/asset.rb 0.00 % 7 5 0 5 0.00
app/models/ckeditor/attachment_file.rb 0.00 % 7 6 0 6 0.00
app/models/ckeditor/picture.rb 0.00 % 7 6 0 6 0.00
app/models/classroom_course.rb 0.00 % 16 12 0 12 0.00
app/models/classroom_course_info.rb 0.00 % 33 25 0 25 0.00
app/models/concerns/filterable.rb 54.55 % 48 33 18 15 0.70
app/models/concerns/publishable.rb 0.00 % 23 18 0 18 0.00
app/models/concerns/publishable_sections.rb 66.67 % 23 12 8 4 0.67
app/models/congress.rb 0.00 % 18 14 0 14 0.00
app/models/congress_info.rb 0.00 % 19 14 0 14 0.00
app/models/contact.rb 0.00 % 25 18 0 18 0.00
app/models/content.rb 0.00 % 72 58 0 58 0.00
app/models/course.rb 0.00 % 53 47 0 47 0.00
app/models/cruza_grafos_type.rb 0.00 % 3 3 0 3 0.00
app/models/cruza_grafos_user.rb 0.00 % 175 141 0 141 0.00
app/models/curator.rb 0.00 % 5 5 0 5 0.00
app/models/deponent.rb 0.00 % 5 5 0 5 0.00
app/models/director.rb 0.00 % 5 5 0 5 0.00
app/models/file_record.rb 0.00 % 3 3 0 3 0.00
app/models/helpdesk.rb 0.00 % 16 12 0 12 0.00
app/models/helpdesk_info.rb 0.00 % 13 9 0 9 0.00
app/models/home.rb 0.00 % 11 10 0 10 0.00
app/models/home_content.rb 0.00 % 9 7 0 7 0.00
app/models/home_primary_section.rb 100.00 % 4 3 3 0 1.00
app/models/home_secondary_section.rb 100.00 % 6 4 4 0 1.00
app/models/home_section.rb 100.00 % 9 6 6 0 1.00
app/models/institucional_person.rb 0.00 % 11 7 0 7 0.00
app/models/institucional_persons_group.rb 0.00 % 9 5 0 5 0.00
app/models/json_model.rb 0.00 % 15 12 0 12 0.00
app/models/main_menu_option.rb 0.00 % 7 6 0 6 0.00
app/models/news.rb 0.00 % 32 22 0 22 0.00
app/models/news_info.rb 0.00 % 23 18 0 18 0.00
app/models/online_course.rb 0.00 % 20 17 0 17 0.00
app/models/online_course_info.rb 0.00 % 27 21 0 21 0.00
app/models/payment.rb 0.00 % 185 151 0 151 0.00
app/models/person.rb 0.00 % 3 3 0 3 0.00
app/models/project.rb 0.00 % 14 11 0 11 0.00
app/models/project_info.rb 0.00 % 11 8 0 8 0.00
app/models/publication.rb 0.00 % 23 17 0 17 0.00
app/models/publication_info.rb 0.00 % 16 12 0 12 0.00
app/models/recent_documentation.rb 0.00 % 5 5 0 5 0.00
app/models/regulation.rb 0.00 % 5 5 0 5 0.00
app/models/section.rb 100.00 % 11 7 7 0 1.00
app/models/secundary_menu_option.rb 0.00 % 7 6 0 6 0.00
app/models/state.rb 0.00 % 7 6 0 6 0.00
app/models/static_content.rb 0.00 % 15 11 0 11 0.00
app/models/supervisor.rb 0.00 % 5 5 0 5 0.00
app/models/team.rb 0.00 % 5 5 0 5 0.00
app/models/transaction.rb 0.00 % 5 3 0 3 0.00
app/models/user.rb 64.71 % 62 34 22 12 0.65

Mailers ( 0.0% covered at 0.0 hits/line )

4 files in total.
117 relevant lines, 0 lines covered and 117 lines missed. ( 0.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/mailers/application_mailer.rb 0.00 % 4 4 0 4 0.00
app/mailers/contact_mailer.rb 0.00 % 12 10 0 10 0.00
app/mailers/cruza_grafos_mailer.rb 0.00 % 55 47 0 47 0.00
app/mailers/user_mailer.rb 0.00 % 66 56 0 56 0.00

Helpers ( 50.0% covered at 0.5 hits/line )

12 files in total.
60 relevant lines, 30 lines covered and 30 lines missed. ( 50.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/helpers/admin_associates_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/application_helper.rb 44.44 % 16 9 4 5 0.44
app/helpers/content_helper.rb 43.33 % 56 30 13 17 0.43
app/helpers/helpdesks_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/homes_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/pages_helper.rb 66.67 % 5 3 2 1 0.67
app/helpers/payment_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/projects_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/sections_helper.rb 30.00 % 20 10 3 7 0.30
app/helpers/static_contents_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/transition_helper.rb 100.00 % 2 1 1 0 1.00
app/helpers/user_associate_controller_helper.rb 100.00 % 2 1 1 0 1.00

Jobs ( 100.0% covered at 0.0 hits/line )

0 files in total.
0 relevant lines, 0 lines covered and 0 lines missed. ( 100.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line

Libraries ( 44.64% covered at 0.45 hits/line )

4 files in total.
56 relevant lines, 25 lines covered and 31 lines missed. ( 44.64% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
lib/json_web_token.rb 0.00 % 15 14 0 14 0.00
lib/rails_admin/publish.rb 64.71 % 34 17 11 6 0.65
lib/rails_admin/unpublish.rb 64.71 % 34 17 11 6 0.65
lib/simple_form_extensions/button_components.rb 37.50 % 10 8 3 5 0.38

Ungrouped ( 0.0% covered at 0.0 hits/line )

8 files in total.
273 relevant lines, 0 lines covered and 273 lines missed. ( 0.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
app/commands/authenticate_user.rb 0.00 % 32 25 0 25 0.00
app/commands/authorize_api_request.rb 0.00 % 37 30 0 30 0.00
app/facades/associates_facade.rb 0.00 % 81 63 0 63 0.00
app/forms/user_associate_admin_edit_form.rb 0.00 % 58 45 0 45 0.00
app/forms/user_associate_edit_form.rb 0.00 % 54 38 0 38 0.00
app/forms/user_associate_transition_form.rb 0.00 % 50 38 0 38 0.00
app/inputs/cpf_input.rb 0.00 % 22 17 0 17 0.00
app/inputs/currency_input.rb 0.00 % 22 17 0 17 0.00

app/commands/authenticate_user.rb

0.0% lines covered

25 relevant lines. 0 lines covered and 25 lines missed.
    
  1. class AuthenticateUser
  2. prepend SimpleCommand
  3. def initialize(email, password)
  4. @email = email
  5. @password = password
  6. end
  7. def call
  8. JsonWebToken.encode(user_id: user.id) if user
  9. end
  10. private
  11. attr_accessor :email, :password
  12. def user
  13. user = User.find_by_email(email)
  14. if (!user)
  15. errors.add :user_authentication, 'invalid user'
  16. return nil
  17. end
  18. associate = Associate.where(association_state: 'running').find_by_user_id(user.id)
  19. cruzaGrafos = CruzaGrafosUser.where('user_state=? OR in_trial=?', 'running', 'true' ).find_by_user_id(user.id)
  20. return user if associate && associate.user.valid_password?(password)
  21. return user if cruzaGrafos && cruzaGrafos.user.valid_password?(password)
  22. errors.add :user_authentication, 'invalid credentials'
  23. nil
  24. end
  25. end

app/commands/authorize_api_request.rb

0.0% lines covered

30 relevant lines. 0 lines covered and 30 lines missed.
    
  1. class AuthorizeApiRequest
  2. prepend SimpleCommand
  3. def initialize(headers = {})
  4. @headers = headers
  5. end
  6. def call
  7. user
  8. end
  9. private
  10. attr_reader :headers
  11. def user
  12. begin
  13. @user ||= User.find(decoded_auth_token[:user_id]) if decoded_auth_token
  14. rescue ActiveRecord::RecordNotFound => e
  15. @user = nil
  16. end
  17. @user || errors.add(:token, 'Invalid token') && nil
  18. end
  19. def decoded_auth_token
  20. @decoded_auth_token ||= JsonWebToken.decode(http_auth_header)
  21. end
  22. def http_auth_header
  23. if headers['Authorization'].present?
  24. return headers['Authorization'].split(' ').last
  25. else
  26. errors.add(:token, 'Missing token')
  27. end
  28. nil
  29. end
  30. end

app/controllers/admin/api_controller.rb

0.0% lines covered

28 relevant lines. 0 lines covered and 28 lines missed.
    
  1. class Admin::ApiController < ApplicationController
  2. respond_to :json
  3. before_action :authenticate_request
  4. def validateAssociate
  5. associate = Associate.find_by_cpf(params[:cpf])
  6. if associate
  7. render json: associate.to_json
  8. else
  9. render json: { msg: false }, status: :unauthorized
  10. end
  11. end
  12. def me
  13. render json: {
  14. user_data: {
  15. email: @current_user.email,
  16. full_name: @current_user.name,
  17. id: @current_user.id,
  18. associate: @current_user.associate ? @current_user.associate.id : nil,
  19. cruza_grafos: @current_user.cruza_grafos_user ? @current_user.cruza_grafos_user.id : nil,
  20. cpf: if @current_user.associate
  21. @current_user.associate.cpf
  22. else
  23. @current_user.cruza_grafos_user ? @current_user.cruza_grafos_user.cpf : nil
  24. end,
  25. }
  26. }
  27. end
  28. end

app/controllers/admin/associates_controller.rb

0.0% lines covered

37 relevant lines. 0 lines covered and 37 lines missed.
    
  1. class Admin::AssociatesController < ApplicationController
  2. # before_action :authenticate_admin!
  3. before_action :set_associate, only: %i[show edit update destroy]
  4. # GET /admin_associates
  5. def index
  6. @associates = Associate.all
  7. end
  8. # GET /admin_associates/1
  9. def show; end
  10. # GET /admin_associates/new
  11. def new
  12. @associate = Associate.new
  13. end
  14. # GET /admin_associates/1/edit
  15. def edit; end
  16. # POST /admin_associates
  17. def create
  18. @associate = Associate.new(associate_params)
  19. if @associate.save
  20. redirect_to [:admin, @associate], notice: 'Associate was successfully created.'
  21. else
  22. render :new
  23. end
  24. end
  25. # PATCH/PUT /admin_associates/1
  26. def update
  27. if @associate.update(associate_params)
  28. redirect_to [:admin, @associate], notice: 'Associate was successfully updated.'
  29. else
  30. render :edit
  31. end
  32. end
  33. # DELETE /admin_associates/1
  34. def destroy
  35. @associate.destroy
  36. redirect_to admin_associates_url, notice: 'Admin associate was successfully destroyed.'
  37. end
  38. private
  39. # Use callbacks to share common setup or constraints between actions.
  40. def set_admin_associate
  41. @associate = Associate.find(params[:id])
  42. end
  43. # Only allow a trusted parameter "white list" through.
  44. def admin_associate_params
  45. params.require(:associate).permit(:cpf, :phone, :country, :state, :city, :zipcode, :address_street, :neighborhood, :address_number, :address_complement, :activity_description, :details_file, :accepted_terms, :active, :accepted_terms_at, :approval_payment_date, :valid_until, :association_state, :payment_type, :code_of_ethics_terms, :code_of_ethics_terms_at, :whatsapp)
  46. end
  47. end

app/controllers/admin/authentication_controller.rb

0.0% lines covered

15 relevant lines. 0 lines covered and 15 lines missed.
    
  1. class Admin::AuthenticationController < ApplicationController
  2. skip_before_action :authenticate_request
  3. before_action :authenticate_internal_token
  4. def authenticate
  5. command = AuthenticateUser.call(params[:email], params[:password])
  6. if command.success?
  7. render json: { success: true, auth_token: command.result }
  8. else
  9. render json: { success: false, error: command.errors }, status: :unauthorized
  10. end
  11. end
  12. def authenticate_internal_token
  13. render json: { error: 'Not Authorized' }, status: 401 unless params[:token] == ENV['TOKEN_API']
  14. end
  15. end

app/controllers/admin/cruza_grafos_users_controller.rb

0.0% lines covered

65 relevant lines. 0 lines covered and 65 lines missed.
    
  1. class Admin::CruzaGrafosUsersController < ApplicationController
  2. before_action :set_admin_cruza_grafos_user, only: [:show, :edit, :update, :destroy]
  3. before_action :authenticate_admin!
  4. layout 'admin'
  5. # GET /admin/cruza_grafos_users
  6. def index
  7. @admin_cruza_grafos_users = CruzaGrafosUser.all
  8. respond_to do |format|
  9. format.html
  10. format.xlsx
  11. end
  12. end
  13. # GET /admin/cruza_grafos_users/1
  14. def show
  15. if @admin_cruza_grafos_user
  16. @payments = @admin_cruza_grafos_user.payments
  17. end
  18. end
  19. # GET /admin/cruza_grafos_users/new
  20. def new
  21. @admin_cruza_grafos_user = CruzaGrafosUser.new
  22. end
  23. # GET /admin/cruza_grafos_users/1/edit
  24. def edit
  25. @types = CruzaGrafosType.all
  26. end
  27. # POST /admin/cruza_grafos_users
  28. def create
  29. @admin_cruza_grafos_user = CruzaGrafosUser.new(admin_cruza_grafos_user_params)
  30. if @admin_cruza_grafos_user.save
  31. render @admin_cruza_grafos_user, notice: 'Cruza grafos user was successfully created.'
  32. else
  33. render :new
  34. end
  35. end
  36. # PATCH/PUT /admin/cruza_grafos_users/1
  37. def update
  38. @payments = @admin_cruza_grafos_user.payments
  39. if @admin_cruza_grafos_user.update(admin_cruza_grafos_user_params)
  40. # redirect_to @admin_cruza_grafos_user, notice: 'Cruza grafos user was successfully updated.'
  41. render :show
  42. else
  43. render :edit
  44. end
  45. end
  46. # DELETE /admin/cruza_grafos_users/1
  47. def destroy
  48. @admin_cruza_grafos_user.destroy
  49. redirect_to admin_cruza_grafos_users_url, notice: 'Cruza grafos user was successfully destroyed.'
  50. end
  51. def start; end
  52. def approve_moderation
  53. CruzaGrafosUser.find(params['id']).approve_moderation!
  54. redirect_to admin_cruza_grafos_users_path
  55. end
  56. def reject_moderation
  57. cruzaGrafosUser = CruzaGrafosUser.find(params['id'])
  58. cruzaGrafosUser.motive = params['reason']
  59. cruzaGrafosUser.save
  60. cruzaGrafosUser.reject_moderation!
  61. redirect_to admin_cruza_grafos_users_path
  62. end
  63. def payment_confirm; end
  64. def payment_reject; end
  65. def expire; end
  66. private
  67. # Use callbacks to share common setup or constraints between actions.
  68. def set_admin_cruza_grafos_user
  69. @admin_cruza_grafos_user = CruzaGrafosUser.find(params[:id])
  70. end
  71. # Only allow a trusted parameter "white list" through.
  72. def admin_cruza_grafos_user_params
  73. # params.fetch(:admin_cruza_grafos_user, {})
  74. params.require(:cruza_grafos_user).permit!
  75. end
  76. end

app/controllers/admins_controller.rb

0.0% lines covered

44 relevant lines. 0 lines covered and 44 lines missed.
    
  1. class AdminsController < ApplicationController
  2. respond_to :html
  3. before_action :set_admin, only: %i[show edit update destroy]
  4. layout 'admin'
  5. before_action :authenticate_admin!
  6. def index
  7. @admins = Admin.all
  8. end
  9. def show; end
  10. def edit; end
  11. def new
  12. @admin = Admin.new
  13. end
  14. def create
  15. @admin = Admin.new(admin_params)
  16. if @admin.save
  17. redirect_to admin_path(@admin), notice: 'User was successfully created.'
  18. else
  19. render :new
  20. end
  21. end
  22. def update
  23. if admin_params[:password].blank? && admin_params[:password_confirmation].blank?
  24. admin_params.delete(:password)
  25. admin_params.delete(:password_confirmation)
  26. end
  27. if @admin.update(admin_params)
  28. redirect_to admin_path(@admin), notice: 'User was successfully updated.'
  29. else
  30. render :edit
  31. end
  32. end
  33. def destroy
  34. @admin.destroy
  35. redirect_to admins_path, notice: 'User was successfully destroyed.'
  36. end
  37. private
  38. def set_admin
  39. @admin = Admin.find_by(id: params[:id])
  40. end
  41. def admin_params
  42. params.require(:admin).permit!
  43. end
  44. end

app/controllers/application_controller.rb

0.0% lines covered

36 relevant lines. 0 lines covered and 36 lines missed.
    
  1. class ApplicationController < ActionController::Base
  2. before_action :load_menu_options
  3. before_action :configure_permitted_parameters, if: :devise_controller?
  4. before_action :authenticate_request, if: :json_request
  5. protect_from_forgery if: :json_request # return null session when API call
  6. protect_from_forgery with: :exception, unless: :json_request
  7. rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
  8. add_breadcrumb 'home', '/'
  9. protected
  10. def record_not_found
  11. redirect_to '/404.html', status: 302
  12. end
  13. def load_menu_options
  14. @main_menu_options = MainMenuOption.all
  15. @secundary_menu_options = SecundaryMenuOption.all
  16. end
  17. def configure_permitted_parameters
  18. devise_parameter_sanitizer.permit(
  19. :sign_up, keys: %i[name birthday email country state city institution association_type newsletter active]
  20. )
  21. devise_parameter_sanitizer.permit(:sign_in, keys: %i[login password])
  22. end
  23. def after_sign_in_path_for(resource)
  24. request.env['omniauth.origin'] || stored_location_for(resource) || root_path_for_resource(resource)
  25. end
  26. def root_path_for_resource(resource)
  27. resource.is_a?(Admin) ? admin_homes_path : user_logged_path
  28. end
  29. def json_request
  30. request.format.json?
  31. end
  32. def authenticate_request
  33. @current_user = AuthorizeApiRequest.call(request.headers).result
  34. render json: { error: 'Not Authorized' }, status: 401 unless @current_user
  35. end
  36. end

app/controllers/associates_controller.rb

0.0% lines covered

31 relevant lines. 0 lines covered and 31 lines missed.
    
  1. class AssociatesController < ApplicationController
  2. before_action :authenticate_user!
  3. require 'date'
  4. def new
  5. @associate = Associate.new(current_user.attributes.slice('country', 'state', 'city'))
  6. @association_types = AssociationType.all
  7. end
  8. def create
  9. @associate = Associate.new(associate_params)
  10. @associate.user_id = current_user.id
  11. @associate.payment_type = 'pending'
  12. @associate.accepted_terms_at = DateTime.now
  13. @associate.code_of_ethics_terms_at = DateTime.now
  14. if (!@associate.association_type.nil? && @associate.association_type.description == 'Profissional e/ou estudante de pós-graduação')
  15. @associate.conclusion_date = nil # Campo anulado quando não se é estudante de graduação
  16. end
  17. if @associate.save
  18. @associate.start!
  19. redirect_to user_logged_path
  20. else
  21. @association_types = AssociationType.all
  22. render :new
  23. end
  24. end
  25. def edit; end
  26. def update; end
  27. def destroy; end
  28. def associate_params
  29. params.require(:associate).permit!
  30. end
  31. end

app/controllers/contact_controller.rb

0.0% lines covered

33 relevant lines. 0 lines covered and 33 lines missed.
    
  1. class ContactController < ApplicationController
  2. respond_to :html
  3. def new
  4. @contact = Contact.new
  5. breadcrumb_title = "Fale Conosco"
  6. add_breadcrumb breadcrumb_title
  7. end
  8. def create
  9. recaptcha_valid = verify_recaptcha(action: 'contact', minimum_score: ENV['RECAPTCHA_MINSCORE'].to_i, action: 'create', secret_key: ENV['RECAPTCHA_SECRETKEY'])
  10. @contact = Contact.new(contact_params)
  11. if recaptcha_valid
  12. if @contact.valid?
  13. ContactMailer.mail_message(@contact).deliver_now
  14. flash.now[:notice] = "Mensagem enviada. Obrigado por entrar em contato!"
  15. redirect_to contact_new_url
  16. else
  17. flash.now[:error] = "Ops, não foi possível enviar sua mensagem. Veja se os campos estão preenchidos corretamente e tente mais uma vez."
  18. breadcrumb_title = "Fale Conosco"
  19. add_breadcrumb breadcrumb_title
  20. render :new
  21. end
  22. else
  23. flash.now[:error] = "Ops, não foi possível completar a validação anti-robo. Tente novamente."
  24. breadcrumb_title = "Fale Conosco"
  25. add_breadcrumb breadcrumb_title
  26. render :new
  27. end
  28. end
  29. private
  30. def contact_params
  31. params.require(:contact).permit(:name, :email, :phone, :message, :subject)
  32. end
  33. end

app/controllers/contents_controller.rb

0.0% lines covered

108 relevant lines. 0 lines covered and 108 lines missed.
    
  1. class ContentsController < ApplicationController
  2. before_action :set_content, only: %i[show edit destroy update publish unpublish]
  3. layout 'admin', only: %i[index new create show edit destroy update publish unpublish]
  4. respond_to :html
  5. def index
  6. @contents = klass.fulltext_search(params[:q]).page(params[:page] || 1).per(10)
  7. end
  8. def of_type
  9. type = params[:type]
  10. type = 'news_index' if type == 'news'
  11. redirect_to send("admin_#{type}_path", page: params[:page])
  12. end
  13. def list
  14. @contents = Kaminari.paginate_array(klass.published_and_filtered(admin_signed_in?, params[:filter_selected]))
  15. @contents = @contents.page(params[:page] || 1).per(10)
  16. @filter = klass.filters
  17. add_breadcrumb t("activerecord.models.#{params[:type].underscore}.other")
  18. end
  19. def search
  20. @contents = Content.published(admin_signed_in?).fulltext_search(params[:q]).page(params[:page] || 1).per(5)
  21. end
  22. def exhibit
  23. @content = Content.published(admin_signed_in?).find_by!(slug: params[:slug])
  24. breadcrumb_title = t("activerecord.models.#{content_type.underscore}.other")
  25. breadcrumb_url = '/' + t("activerecord.models.#{content_type.underscore}.slug")
  26. add_breadcrumb breadcrumb_title, breadcrumb_url
  27. respond_with(@content)
  28. end
  29. def show
  30. @content = Content.find_by!(slug: params[:id])
  31. respond_with(@content)
  32. end
  33. def new
  34. @content = klass.new
  35. @sections = Section.all
  36. @tags = klass_info.new
  37. build_content_type
  38. @croped_image_size = klass.croped_image_size
  39. end
  40. def edit
  41. @croped_image_size = klass.croped_image_size
  42. @sections = Section.all
  43. build_content_type
  44. end
  45. def create
  46. @tags = klass_info.new
  47. @content = klass.new(content_params)
  48. # @content.online_course_info.associate_price_cents = content_params[:online_course_info_attributes][:associate_price_cents].to_f * 100
  49. @croped_image_size = klass.croped_image_size
  50. if @content.save
  51. redirect_to index_path
  52. else
  53. build_content_type
  54. if !@content.errors.details[:slug].blank?
  55. @content.errors.messages[:title] = ["Esse titulo já está sendo usado em outra noticia. Não se pode repetir o título pois a URL é gerada dele, e não se pode repetir URL"]
  56. end
  57. render :new
  58. end
  59. end
  60. def update
  61. @croped_image_size = klass.croped_image_size
  62. if @content.update(content_params)
  63. redirect_to index_path
  64. else
  65. render :edit
  66. end
  67. end
  68. def destroy
  69. @content.destroy
  70. redirect_to index_path
  71. end
  72. def publish
  73. @content.update(published: true)
  74. redirect_to index_path
  75. end
  76. def unpublish
  77. @content.update(published: false)
  78. redirect_to index_path
  79. end
  80. private
  81. def build_content_type
  82. return if @content.send("#{content_type.underscore}_info").present?
  83. @content.send("build_#{content_type.underscore}_info")
  84. end
  85. def content_type
  86. return @content.type if @content.present?
  87. params[:type]&.camelize || 'Content'
  88. end
  89. def klass
  90. content_type.constantize
  91. end
  92. def klass_info
  93. "#{content_type}Info".constantize
  94. end
  95. def index_path
  96. if content_type == 'News'
  97. send('admin_news_index_path')
  98. else
  99. send("admin_#{content_type.underscore.pluralize}_path")
  100. end
  101. end
  102. def set_content
  103. @content = klass.find_by(slug: params[:id])
  104. @tags = klass_info.new
  105. end
  106. def content_params
  107. params[:content].permit!
  108. end
  109. end

app/controllers/cruza_grafos_users_controller.rb

0.0% lines covered

41 relevant lines. 0 lines covered and 41 lines missed.
    
  1. class CruzaGrafosUsersController < ApplicationController
  2. before_action :set_cruza_grafos_user, only: [:show, :edit, :update, :destroy]
  3. # GET /cruza_grafos_users
  4. def index
  5. @cruza_grafos_users = CruzaGrafosUser.all
  6. end
  7. # GET /cruza_grafos_users/1
  8. def show
  9. end
  10. # GET /cruza_grafos_users/new
  11. def new
  12. @cruza_grafos_user = CruzaGrafosUser.new
  13. end
  14. # GET /cruza_grafos_users/1/edit
  15. def edit
  16. end
  17. # POST /cruza_grafos_users
  18. def create
  19. @cruza_grafos_user = CruzaGrafosUser.new(cruza_grafos_user_params)
  20. @cruza_grafos_user.user = current_user
  21. @cruza_grafos_user.start
  22. if @cruza_grafos_user.save
  23. redirect_to user_logged_path, notice: 'Cruza grafos user was successfully created.'
  24. else
  25. render :new
  26. end
  27. end
  28. # PATCH/PUT /cruza_grafos_users/1
  29. def update
  30. if @cruza_grafos_user.update(cruza_grafos_user_params)
  31. redirect_to @cruza_grafos_user, notice: 'Cruza grafos user was successfully updated.'
  32. else
  33. render :edit
  34. end
  35. end
  36. # DELETE /cruza_grafos_users/1
  37. def destroy
  38. @cruza_grafos_user.destroy
  39. redirect_to cruza_grafos_users_url, notice: 'Cruza grafos user was successfully destroyed.'
  40. end
  41. private
  42. # Use callbacks to share common setup or constraints between actions.
  43. def set_cruza_grafos_user
  44. @cruza_grafos_user = CruzaGrafosUser.find(params[:id])
  45. end
  46. # Only allow a trusted parameter "white list" through.
  47. def cruza_grafos_user_params
  48. params.require(:cruza_grafos_user).permit!
  49. end
  50. end

app/controllers/dashboards_controller.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class DashboardsController < ApplicationController
  2. before_action :authenticate_admin!
  3. layout 'admin'
  4. def home; end
  5. end

app/controllers/exclusive_content_congress_controller.rb

0.0% lines covered

60 relevant lines. 0 lines covered and 60 lines missed.
    
  1. require 'google/apis/youtube_v3'
  2. class ExclusiveContentCongressController < ExclusiveContentController
  3. respond_to :html
  4. PLAYLISTS = {
  5. 2020 => {'name' => 'Congresso 2020', 'description' => 'O 15º Congresso Internacional de Jornalismo Investigativo, o primeiro a ser realizado em formato virtual, aconteceu entre os dias 10 e 13.set.2020. Desinformação, segurança digital, liberdade de expressão, jornalismo ambiental e polarização foram alguns dos temas abordados na edição de 2020.', 'slug' => '15-congresso-da-abraji', 'thumb' => 'congress-2020/15-congresso-da-abraji.png', 'botao' => 'Assistir Congresso', 'list'=> [
  6. {'name' => 'VII Seminário de Pesquisa','description' => 'O VII Seminário de Pesquisa em Jornalismo Investigativo integrou a programação do 15º Congresso, realizado anualmente pela Abraji. É um espaço para discutir estudos acadêmicos sobre jornalismo investigativo. No evento, foram apresentadas 15 pesquisas inéditas.', 'playlist_id' => 'PLd76UQ8_K_EWquBPFVvWrVwutC4iiDnSm', 'slug' => 'vii-seminario-de-pesquisa', 'thumb' => 'vii-seminario-de-pesquisa.jpg', 'botao' => 'Assistir playlist'},
  7. {'name' => '1º dia do 15º Congresso','description' => 'O 15º Congresso Internacional de Jornalismo Investigativo da Abraji foi realizado virtualmente em 11.set.2020 e 12.set.2020. No primeiro dia, desinformação, segurança digital, liberdade de expressão, terras indígenas, cobertura policial, jurídica e política estiveram em pauta. Entre os convidados, o ministro do STF Alexandre de Moraes, Miguel Nicolelis, Craig Silverman, Patrícia Campos Mello, além de outros grandes nomes.', 'playlist_id' => 'PLd76UQ8_K_EVXveWqO75ca6j-zoyMuEKC', 'slug' => '1-dia-do-15-congresso-da-abraji', 'thumb' => '1-dia-do-15-congresso.jpg', 'botao' => 'Assistir playlist'},
  8. {'name' => '2º dia do 15º Congresso','description' => 'No segundo dia, jornalismo ambiental, modelos de negócio, redes sociais, saúde mental, polarização, Lei de Acesso à informação, podcasts e cobertura da pandemia foram alguns dos temas abordados. Entre os convidados, Jonathan Watts, Renata Lo Prete, Katia Brasil, Fernando Rodrigues, Cécile Prieur, Jason Stanley, entre outros nomes de destaque.', 'playlist_id' => 'PLd76UQ8_K_EUDG13hK_2q1mbcKEtRClUg', 'slug' => '2-dia-do-15-congresso-da-abraji', 'thumb' => '2-dia-do-15-congresso.jpg', 'botao' => 'Assistir playlist'},
  9. {'name' => '2º Domingo de Dados','description' => 'O 2º Domingo de Dados fez parte do 15º Congresso. Nas oficinas de jornalismo de dados, foram trabalhadas linguagens de programação como R, Python e SQL, além de estatística para jornalistas. Grandes investigações baseadas em dados e visualizações, cobertura das eleições e Open Source Intelligence também estiveram em debate. Entre os instrutores, jornalistas, desenvolvedores especializados e pesquisadores de cada tema.', 'playlist_id' => 'PLd76UQ8_K_EU57xBtPLiEBxdwlD9U9hJl', 'slug' => '2-domingo-de-dados', 'thumb' => '2-domingo-de-dados.jpg', 'botao' => 'Assistir playlist'}
  10. ]
  11. }, 2021 => {'name' => 'Congresso 2021', 'description' => 'Prepare-se para assistir ao maior evento de jornalistas do país que aconteceu entre os dias 23 e 29.ago.2021, de forma virtual. O 16º Congresso Internacional de Jornalismo Investigativo foi gratuito e está disponível exclusivamente para associados e associadas da Abraji.', 'slug' => '16-congresso-da-abraji', 'thumb' => 'congress-2021/16-congresso-da-abraji.png', 'botao' => 'Assistir Congresso', 'list'=>[
  12. {'name' => '1º dia do 16º Congresso','description' => 'No primeiro dia do 16º Congresso Internacional de Jornalismo Investigativo, convidados do Brasil e do mundo discutiram temas como liberdade de expressão, jornalismo literário na Amazônia e modelos de negócio. Três oficinas, a cerimônia de homenagem desta edição e a entrevista com Renan Calheiros também marcaram esse 1º dia do evento.', 'playlist_id' => 'PLd76UQ8_K_EVnQU7Wq8ITkIl-RrRMmJIS', 'slug' => '1-dia-do-16-congresso-da-abraji', 'thumb' => '1-dia-do-16-congresso-da-abraji.png', 'botao' => 'Assistir playlist'},
  13. {'name' => '2º dia do 16º Congresso','description' => 'No segundo dia do evento, destacaram-se os debates sobre investigações jornalísticas no governo Bolsonaro, documentários do Frontline, cobertura de educação, assédio virtual nos veículos de imprensa, além da discussão sobre jornalistas assassinados no México e no Brasil.', 'playlist_id' => 'PLd76UQ8_K_EXkNpXiwEn3SGdrBMr25eoZ', 'slug' => '2-dia-do-16-congresso-da-abraji', 'thumb' => '2-dia-do-16-congresso-da-abraji.png', 'botao' => 'Assistir playlist'},
  14. {'name' => '3º dia do 16º Congresso','description' => 'Investigações transnacionais sobre meio ambiente, cobertura jornalística sobre feminicídio e sobre a pandemia de covid-19 no Amazonas, jornalismo investigativo no streaming internacional e como aumentar a diversidade racial na imprensa estiveram entre os assuntos que marcaram o 3º dia do 16º Congresso da Abraji. Nesse dia, o público também pôde conhecer um pouco mais sobre as ferramentas e os projetos da Abraji e de seus parceiros.', 'playlist_id' => 'PLd76UQ8_K_EUzfAR41JTQ_6yk49f8jfwD', 'slug' => '3-dia-do-16-congresso-da-abraji', 'thumb' => '3-dia-do-16-congresso-da-abraji.png', 'botao' => 'Assistir playlist'},
  15. {'name' => '4º dia do 16º Congresso','description' => 'Durante o 4º dia do Congresso da Abraji, palestrantes discutiram investigações de abusos sexuais e de redes de espiritualidade, jornalismo local, assédio judicial, inteligência artificial no jornalismo, entre outros assuntos. Uma mesa com o youtuber e comunicador digital Felipe Neto debateu o que profissionais de imprensa e comunicadores digitais podem aprender uns com os outros.', 'playlist_id' => 'PLd76UQ8_K_EXDwzPvoLkEsyWQUk9_NwEO', 'slug' => '4-dia-do-16-congresso-da-abraji', 'thumb' => '4-dia-do-16-congresso-da-abraji.png', 'botao' => 'Assistir playlist'},
  16. {'name' => '5º dia do 16º Congresso','description' => 'Entre as questões abordadas no último dia, estiveram o desafio das eleições de 2022 para os checadores de fatos e o TSE; como construir uma relação de confiança com o público jovem; erros e acertos da cobertura policial a partir dos casos Lázaro e Jacarezinho; e o contexto de trabalho semelhante enfrentado por mulheres jornalistas no Brasil e na Índia. A entrevista com Fernando Gabeira e o documentário de homenagem a organizações que defendem a liberdade de expressão e de imprensa também estiveram entre os conteúdos que fecharam a programação.', 'playlist_id' => 'PLd76UQ8_K_EXjy1Ubycexg_PZelSXPFdb', 'slug' => '5-dia-do-16-congresso-da-abraji', 'thumb' => '5-dia-do-16-congresso-da-abraji.png', 'botao' => 'Assistir playlist'},
  17. {'name' => 'VIII Seminário de Pesquisa de Jornalismo Investigativo','description' => ' O VIII Seminário de Pesquisa, um espaço criado para discutir estudos acadêmicos sobre jornalismo investigativo, foi realizado no dia 28.ago.2021, integrado à programação do 16º Congresso Internacional de Jornalismo Investigativo. Além da apresentação de artigos científicos e de trabalhos de conclusão de curso (TCCs), a Abraji promoveu debates com especialistas sobre questões que mobilizaram jornalistas e pesquisadores entre 2020 e 2021.', 'playlist_id' => 'PLd76UQ8_K_EWBY_Uo1KcOJv7BG2r3JNTK', 'slug' => 'viii-seminario-de-pesquisa', 'thumb' => 'viii-seminario-de-pesquisa.png', 'botao' => 'Assistir playlist'},
  18. {'name' => '3º Domingo de Dados','description' => ' No dia 29.ago.2021, ocorreu a 3ª edição do Domingo de Dados, voltada para oficinas e debates sobre jornalismo de dados. O evento, que fez parte da programação do 16º Congresso Internacional de Jornalismo Investigativo, incluiu painéis que trabalharam linguagens de programação como R, Python e SQL. Open Source Intelligence e grandes investigações baseadas em dados e visualizações também foram temas abordados no 3º Domingo de Dados.', 'playlist_id' => 'PLd76UQ8_K_EWrsTYJgv_oGmO_IQlg3Tv0', 'slug' => '3-domingo-de-dados', 'thumb' => '3-domingo-de-dados.png', 'botao' => 'Assistir playlist'}
  19. ]
  20. }, 2022 => {'name' => 'Congresso 2022', 'description' => 'Em 2022, pela primeira vez, a Abraji realizou o maior encontro de jornalistas do país de forma mista - on-line e presencial. O 17º Congresso Internacional de Jornalismo Investigativo aconteceu entre os dias 3 e 7.ago.2022. A parte presencial aconteceu em São Paulo, na FAAP (Fundação Armando Alvares Penteado).', 'slug' => '17-congresso-da-abraji', 'thumb' => 'congress-2022/17-congresso-da-abraji.png', 'botao' => 'Assistir Congresso','list'=>[
  21. {'name' => '1º dia do 17º Congresso','description' => 'No primeiro dia do evento, convidados do Brasil e do mundo discutiram temas como direitos humanos, jornalismo no streaming, invasão de privacidade, ameaças a mulheres jornalistas, eleições 2022 e o assassinato do jornalista Dom Phillips e do indigenista Bruno Pereira. Oficinas com dicas de investigação, direito autoral no podcast e investigação no Judiciário também marcaram o primeiro dia do 17º Congresso, realizado de forma on-line.', 'playlist_id' => 'PLd76UQ8_K_EWBFIvvpSsuuXI8yFk0t8B4', 'slug' => '1-dia-do-17-congresso-da-abraji', 'thumb' => '1-dia-do-17-congresso-da-abraji.png', 'botao' => 'Assistir playlist', 'link'=>'https://youtube.com/playlist?list=PLd76UQ8_K_EWBFIvvpSsuuXI8yFk0t8B4'},
  22. {'name' => '2º dia do 17º Congresso','description' => 'Mulheres jornalistas na guerra, big techs e suas responsabilidades, guerra na Rússia e jornalismo independente foram alguns dos assuntos abordados no segundo dia do evento. Também foram realizadas oficinas sobre desinformação eleitoral, dados eleitorais e monitoramento de prefeituras.', 'playlist_id' => 'PLd76UQ8_K_EWrGyl4F0oGDbZ_IBuMgCD2', 'slug' => '2-dia-do-17-congresso-da-abraji', 'thumb' => '17-congresso-da-abraji.png', 'botao' => 'Assistir playlist', 'link'=>'https://youtube.com/playlist?list=PLd76UQ8_K_EWrGyl4F0oGDbZ_IBuMgCD2'},
  23. {'name' => '3º dia do 17º Congresso','description' => 'No primeiro dia da versão presencial, foram discutidas importantes investigações que levaram a grandes escândalos políticos, entre outros assuntos. Confira ainda a cerimônia de homenagem do 17º Congresso.', 'playlist_id' => 'PLd76UQ8_K_EVkvgfJwLbsxpllEW9UT-oH', 'slug' => '4-dia-do-17-congresso-da-abraji', 'thumb' => '3-dia-do-17-congresso-da-abraji.png', 'botao' => 'Assistir playlist', 'link'=>'https://youtube.com/playlist?list=PLd76UQ8_K_EVkvgfJwLbsxpllEW9UT-oH'},
  24. {'name' => '4º dia do 17º Congresso','description' => 'Entre os destaques deste dia, estão a palestra sobre a resistência do jornalismo durante governos autoritários e a sessão que tratou dos bastidores do trabalho que investigou a invasão do Capitólio.', 'playlist_id' => 'PLd76UQ8_K_EUNsJk11dnvMaCEJG-8LUK4', 'slug' => '5-dia-do-17-congresso-da-abraji', 'thumb' => '4-dia-do-17-congresso-da-abraji.png', 'botao' => 'Assistir playlist', 'link'=> 'https://www.youtube.com/playlist?list=PLd76UQ8_K_EUNsJk11dnvMaCEJG-8LUK4'},
  25. {'name' => 'IX Seminário de Pesquisa de Jornalismo Investigativo','description' => 'O IX Seminário de Pesquisa, um espaço criado para discutir estudos acadêmicos sobre jornalismo investigativo, foi realizado nos dias 3 e 4.ago.2022, integrado à programação on-line do 17º Congresso. Além da discussão sobre os artigos científicos, foram apresentados os trabalhos de conclusão de curso (TCCs).', 'playlist_id' => 'PLd76UQ8_K_EX5xxm4i1UVJCRAYol7dnDo', 'slug' => '17-congresso-da-abraji', 'thumb' => 'ix-seminario-de-pesquisa.png', 'botao' => 'Assistir playlist', 'link'=>'https://youtube.com/playlist?list=PLd76UQ8_K_EX5xxm4i1UVJCRAYol7dnDo'}
  26. ]
  27. }, 1 => {'name' => 'Canal de escuta', 'description' => 'Para atender às normas do código de ética interno, a Abraji, em parceria com o SafeSpace, abriu um canal de escuta pelo qual as pessoas associadas podem enviar relatos de assédio, discriminação, bullying, corrupção, fraude, entre outros tipos de má conduta. Esse canal foi idealizado para promover acolhimento e respeito nas relações estabelecidas pela/na Abraji.', 'slug' => 'others', 'thumb' => 'others/safespace.png', 'botao' => 'Acessar tutorial e canal de escuta', 'fileName'=>'abraji-safe-space.pdf'},
  28. 2 => {'name' => 'Lista de transmissão (Whatsapp)', 'description' => 'Que tal receber de forma mais rápida as notícias e notas publicadas pela Abraji, além de informações sobre eventos, cursos, iniciativas e oportunidades na área? Participe da lista de transmissão da Abraji no WhatsApp. Após clicar no botão abaixo, que vai te direcionar para o aplicativo de mensagens, você deverá iniciar uma conversa e salvar o contato em sua agenda para entrar na lista e receber as mensagens compartilhadas.', 'slug' => 'others', 'thumb' => 'others/whatsapp.png', 'botao' => 'Entrar na lista de transmissão', 'link'=>'https://wa.me/5511959788904?text=Eu%20quero%20fazer%20parte%20da%20lista%20de%20transmiss%C3%A3o%20de%20associados/as%20da%20Abraji' }
  29. }.freeze
  30. def list
  31. add_breadcrumb 'Conteúdo Exclusivo'
  32. @playlists = PLAYLISTS.sort_by {|k, v| -k }.to_h
  33. end
  34. def playlists
  35. @year = params[:year].to_i
  36. add_breadcrumb 'Conteúdo Exclusivo', exclusive_content_congress_list_url
  37. add_breadcrumb 'Congresso '+@year.to_s
  38. @playlists = PLAYLISTS[@year]['list']
  39. end
  40. def playlist
  41. @year = params[:year].to_i
  42. @slug = params[:slug]
  43. @playlists = PLAYLISTS[@year]['list']
  44. @playlist = @playlists.select{|key, hash| key["slug"] == @slug }
  45. add_breadcrumb 'Conteúdo Exclusivo', exclusive_content_congress_list_url
  46. add_breadcrumb 'Congresso '+@year.to_s, exclusive_content_congress_playlists_url
  47. add_breadcrumb @playlist[0]['name']
  48. youtube = Google::Apis::YoutubeV3::YouTubeService.new
  49. youtube.key = ENV['YT_KEY']
  50. @video = youtube.list_playlist_items('snippet', playlist_id: @playlist[0]['playlist_id'], max_results: 20)
  51. @playlistsMenu = congressPlaylistsMenu
  52. end
  53. def download
  54. send_file 'app/assets/arquivos/conteudo-exclusivo/'+ params[:filename]
  55. end
  56. private
  57. def congressPlaylistsMenu
  58. PLAYLISTS[@year]['list'].select{|key, hash| key["slug"] != params[:slug] }
  59. end
  60. end

app/controllers/exclusive_content_controller.rb

0.0% lines covered

20 relevant lines. 0 lines covered and 20 lines missed.
    
  1. class ExclusiveContentController < ApplicationController
  2. before_action :authenticate_user!
  3. before_action :redirect_to_home_logged, :if => :is_not_eligible_to_access?
  4. private
  5. #exceptions to access exclusive content:
  6. # Allow access to Domingo de dados page if User institution is "Universidade Positivo" and date now is <= than 30 days from created_at
  7. def is_user_institution_from_universidade_positivo?
  8. current_user.institution == "Universidade Positivo" && is_user_in_30_days_from_created_at? && (request.fullpath == "/congresso-2020/2-domingo-de-dados" || request.fullpath == "/congresso-2020")
  9. end
  10. #rules to access exclusive content
  11. # Disalow access to users that are not associated
  12. def is_user_not_associated?
  13. current_user.associate.nil? || !current_user.associate.running?
  14. end
  15. def is_user_in_30_days_from_created_at?
  16. (Date.today) <= (current_user.created_at + 30.days)
  17. end
  18. #before action: is not elegible to access?
  19. def is_not_eligible_to_access?
  20. is_user_not_associated? && !is_user_institution_from_universidade_positivo?
  21. end
  22. #if not in rules and exceptions redirect to home logged
  23. def redirect_to_home_logged
  24. redirect_to user_logged_url(:show => 'exclusive')
  25. end
  26. end

app/controllers/helpdesks_controller.rb

0.0% lines covered

56 relevant lines. 0 lines covered and 56 lines missed.
    
  1. class HelpdesksController < ApplicationController
  2. before_action :set_helpdesk, only: %i[show edit destroy publish unpublish]
  3. layout 'admin'
  4. before_action :authenticate_admin!
  5. def index
  6. @helpdesks = Helpdesk.all
  7. end
  8. def show; end
  9. def new
  10. @helpdesk = Helpdesk.new
  11. @helpdesk_info = HelpdeskInfo.new
  12. end
  13. def edit; end
  14. def create
  15. @helpdesk = Helpdesk.new(helpdesk_params.except(:helpdesk_infos))
  16. @helpdesk.helpdesk_info = HelpdeskInfo.new(note: helpdesk_params[:helpdesk_infos][:note],
  17. content_type: @helpdesk.type)
  18. if @helpdesk.save
  19. @helpdesk.helpdesk_info.content = @helpdesk
  20. @helpdesk.helpdesk_info.save
  21. redirect_to helpdesk_path(id: @helpdesk.id)
  22. else
  23. render :new
  24. end
  25. end
  26. def update
  27. @helpdesk = Helpdesk.find(params[:helpdesk][:id])
  28. if @helpdesk.update(helpdesk_params.except(:helpdesk_infos))
  29. @helpdesk.helpdesk_info.update_attributes(helpdesk_params[:helpdesk_infos]) if @helpdesk.helpdesk_info.present?
  30. render :show
  31. else
  32. render :edit
  33. end
  34. end
  35. def destroy
  36. @helpdesk.destroy
  37. redirect_to helpdesks_url
  38. end
  39. def publish
  40. @helpdesk.update_attributes(published: true)
  41. redirect_to helpdesks_path
  42. end
  43. def unpublish
  44. @helpdesk.update_attributes(published: false)
  45. redirect_to helpdesks_path
  46. end
  47. private
  48. def set_helpdesk
  49. @helpdesk = Helpdesk.find(params[:id])
  50. end
  51. def helpdesk_params
  52. params.require(:helpdesk).permit(
  53. [:id, :image, :title, :title_summary, :content, section_ids: [], helpdesk_infos: [:note]]
  54. )
  55. end
  56. end

app/controllers/homes_controller.rb

0.0% lines covered

91 relevant lines. 0 lines covered and 91 lines missed.
    
  1. class HomesController < ApplicationController
  2. before_action :set_home, only: %i[exhibit show edit update destroy activate deactivate]
  3. before_action :authenticate_admin!
  4. layout 'admin'
  5. def index
  6. @homes = Home.all
  7. end
  8. def exhibit
  9. render 'pages/home', layout: 'application'
  10. end
  11. def show; end
  12. def new
  13. @home = Home.new
  14. @home.build_home_primary_section
  15. 4.times do |i|
  16. @home.home_primary_section.home_contents.build[i]
  17. @home.home_primary_section.home_contents[i].position = i
  18. end
  19. 3.times do |i|
  20. @home.home_secondary_sections.build
  21. 3.times do |j|
  22. @home.home_secondary_sections[i].home_contents.build[j]
  23. @home.home_secondary_sections[i].home_contents[j].position = j
  24. end
  25. end
  26. end
  27. def edit; end
  28. def create
  29. @home = Home.new(home_params)
  30. 4.times do |i|
  31. @home.home_primary_section.home_contents[i].position = i
  32. end
  33. 3.times do |i|
  34. 3.times do |j|
  35. @home.home_secondary_sections[i].home_contents[j].position = j
  36. end
  37. end
  38. if @home.save
  39. redirect_to admin_homes_path, notice: 'Home was successfully created.'
  40. else
  41. render :new
  42. end
  43. end
  44. def update
  45. if @home.update(home_params)
  46. redirect_to admin_homes_path, notice: 'Home was successfully updated.'
  47. else
  48. render :edit
  49. end
  50. end
  51. def destroy
  52. @home.destroy
  53. redirect_to [:admin, @home], notice: 'Home was successfully destroyed.'
  54. end
  55. def activate
  56. Home.where(active: true).each { |home| home.update(active: false) }
  57. @home.update active: true
  58. redirect_to admin_homes_path, notice: 'Home was successfully activated.'
  59. end
  60. def deactivate
  61. @home.active = false
  62. @home.save
  63. redirect_to admin_homes_path, notice: 'Home was successfully deactivated.'
  64. end
  65. private
  66. def set_home
  67. @home = Home.find_by!(slug: params[:id])
  68. # @home2 = Home.joins(:home_sections).joins(:home_contents).where(slug: params[:id])
  69. # @home.home_primary_section.home_contents = @home.home_primary_section.home_contents.order(:position)
  70. # @home.home_secondary_sections.each do |hsc|
  71. # hsc.home_contents = hsc.home_contents.order(:position)
  72. # end
  73. end
  74. def home_params
  75. params.require(:home).permit(
  76. [
  77. :title, :active, :id, :slug, :top_banner, :top_banner_description, :top_banner_link,
  78. home_primary_section_attributes: [
  79. :id, home_contents_attributes: %i[id section_id title description url image position]
  80. ],
  81. home_secondary_sections_attributes: [
  82. :id, :section_id, home_contents_attributes: %i[id title description url image position]
  83. ]
  84. ]
  85. )
  86. end
  87. def home_secondary_sections_params
  88. home_content_params = []
  89. secondary_secion_attributes = home_params[:home_secondary_sections_attributes].to_h.delete('0')
  90. hss_keys = secondary_secion_attributes[:home_contents_attributes].keys
  91. hss_keys.each_with_index do |_hk, i|
  92. home_content_params << secondary_secion_attributes[:home_contents_attributes][hss_keys[i]]
  93. end
  94. home_content_params
  95. end
  96. end

app/controllers/institucional_persons_controller.rb

0.0% lines covered

71 relevant lines. 0 lines covered and 71 lines missed.
    
  1. class InstitucionalPersonsController < ApplicationController
  2. respond_to :html
  3. before_action :set_institucional_person, only: %i[show edit update destroy publish unpublish]
  4. layout 'admin'
  5. before_action :authenticate_admin!
  6. def index
  7. @institucionalPersons = InstitucionalPerson.order(:order).all
  8. @groups = InstitucionalPersonsGroup.order(order: :asc).all
  9. end
  10. def sort
  11. params[:institucional].each_with_index do |id, index|
  12. InstitucionalPerson.where(id: id.gsub('#','-')).update_all(order: index + 1)
  13. end
  14. head :ok
  15. end
  16. def show; end
  17. def edit;
  18. @institucionalPerson = InstitucionalPerson.published(admin_signed_in?).find_by!(id: params[:id])
  19. @institucionalPersonsGroups = InstitucionalPersonsGroup.all()
  20. end
  21. def exhibit
  22. @institucionalPerson = InstitucionalPerson.published(admin_signed_in?).find_by!(id: params[:id])
  23. breadcrumb_title = @institucionalPerson.name
  24. breadcrumb_url = '/'
  25. add_breadcrumb breadcrumb_title, breadcrumb_url
  26. render layout: 'application'
  27. end
  28. def new
  29. @institucionalPersonPath = admin_institucional_person_index_path
  30. @institucionalPersonsGroups = InstitucionalPersonsGroup.all()
  31. @institucionalPerson = InstitucionalPerson.new
  32. end
  33. def create
  34. @institucionalPersonPath = admin_institucional_person_index_path
  35. @institucionalPersonsGroups = InstitucionalPersonsGroup.all()
  36. @institucionalPerson = InstitucionalPerson.new(institucional_persons_params)
  37. if @institucionalPerson.save
  38. respond_with(@institucionalPerson, :location => admin_institucional_person_index_path)
  39. else
  40. render :new
  41. end
  42. end
  43. def update
  44. @institucionalPersonPath = admin_institucional_person_path
  45. @institucionalPerson = InstitucionalPerson.find_by id: params[:institucional_person][:id]
  46. if @institucionalPerson.update(institucional_persons_params)
  47. # render :show
  48. redirect_to admin_institucional_person_index_path
  49. else
  50. render :new
  51. end
  52. end
  53. def destroy
  54. @institucionalPerson.destroy
  55. redirect_to admin_institucional_person_index_path
  56. end
  57. def publish
  58. @institucionalPerson.update(published: true)
  59. redirect_to admin_institucional_person_path
  60. end
  61. def unpublish
  62. @institucionalPerson.update(published: false)
  63. redirect_to admin_institucional_person_path
  64. end
  65. private
  66. def set_institucional_person
  67. @institucionalPerson = InstitucionalPerson.find_by(id: params[:id])
  68. end
  69. def institucional_persons_params
  70. params.require(:institucional_person).permit([:name], [:description], [:photo], [:role], [:institucional_persons_group_id], [:id])
  71. end
  72. end

app/controllers/pages_controller.rb

0.0% lines covered

54 relevant lines. 0 lines covered and 54 lines missed.
    
  1. require 'google/apis/youtube_v3'
  2. class PagesController < ApplicationController
  3. respond_to :html
  4. def home
  5. @home = Home.find_by(active: true)
  6. end
  7. def institutional
  8. @groups = InstitucionalPersonsGroup.order(order: :asc).all
  9. add_breadcrumb 'Institucional'
  10. end
  11. def institutional_transparence
  12. @recent_documentation = RecentDocumentation.all
  13. @activity_reports = ActivityReport.all
  14. @audit_reports = AuditReport.all
  15. add_breadcrumb 'Institucional', '/institucional'
  16. add_breadcrumb 'Transparência'
  17. end
  18. def institutional_patrimonial_fund
  19. @deponents = Deponent.all
  20. @regulations = Regulation.all
  21. groupId = InstitucionalPersonsGroup.find_by_name('conselho curador').id
  22. @curators = InstitucionalPerson.where(institucional_persons_group_id: groupId, published: true).order(order: :asc)
  23. add_breadcrumb 'Institucional', '/institucional'
  24. add_breadcrumb 'Fundo Patrimonial'
  25. end
  26. def institutional_documentaries
  27. add_breadcrumb 'Institucional', '/institucional'
  28. add_breadcrumb 'Documentários dos Homenageados'
  29. youtube = Google::Apis::YoutubeV3::YouTubeService.new
  30. youtube.key = ENV['YT_KEY']
  31. @video = youtube.list_playlist_items('snippet', playlist_id: 'PLd76UQ8_K_EXbKb3HDah2ans4rWE8EG9J', max_results: 20)
  32. end
  33. def institutional_privacy_policy
  34. add_breadcrumb 'Institucional', '/institucional'
  35. add_breadcrumb 'Política de Privacidade'
  36. end
  37. def institutional_codigo_de_conduta_etica
  38. add_breadcrumb 'Institucional', '/institucional'
  39. add_breadcrumb 'Código de conduta ética'
  40. @page_content = StaticContent.find_by(slug:request.fullpath.gsub("/institucional/",""))
  41. end
  42. def cruza_grafos_terms_of_use
  43. add_breadcrumb 'CruzaGrafos', '/cruzagrafos'
  44. add_breadcrumb 'Termos de Uso'
  45. end
  46. def cruza_grafos_privacy_policy
  47. add_breadcrumb 'CruzaGrafos', '/cruzagrafos'
  48. add_breadcrumb 'Política de Privacidade'
  49. end
  50. def protecao_legal_e_litigancia
  51. add_breadcrumb 'Proteção Legal e Litigância'
  52. @page_content = StaticContent.find_by(slug:request.fullpath.tr('/', '')).content
  53. end
  54. end

app/controllers/payment_controller.rb

0.0% lines covered

295 relevant lines. 0 lines covered and 295 lines missed.
    
  1. class PaymentController < ApplicationController
  2. before_action :authenticate_user!, only: [:pay_association_logged_user]
  3. skip_before_action :verify_authenticity_token, only: :notification
  4. before_action :set_headers
  5. def new
  6. @user = params[:userId]
  7. @payment = Payment.new
  8. end
  9. def create
  10. @payment = Payment.new(payment_params)
  11. if @payment.save
  12. redirect_to admin_user_path(@payment), notice: 'Payment was successfully created.'
  13. else
  14. render :new
  15. end
  16. end
  17. def manual_pay
  18. @payment = Payment.find(params['id'])
  19. if (@payment.payable.valid?)
  20. @payment.manual_pay!
  21. end
  22. redirect_to admin_user_path(@payment.user), flash: { error: @payment.payable.errors.messages }
  23. end
  24. def change_payment_value
  25. payment = Payment.find(params['id'])
  26. payment.price_cents = payment_value_params.to_f*100
  27. payment.save
  28. redirect_to admin_user_path(payment.user)
  29. end
  30. def covid_voucher
  31. payment = Payment.find_by(user_id: current_user.id, status: "nil", payable_type: "Associate")
  32. payment.name = 'association covid voucher'
  33. payment.price_cents = 100
  34. payment.save
  35. redirect_to user_logged_path
  36. end
  37. def pay_association_logged_user
  38. # -- Valida o Código de Éticas
  39. form_code_of_ethics_terms_value = 0
  40. if !params()['associate'].nil?
  41. form_code_of_ethics_terms_value = params()['associate']['code_of_ethics_terms']
  42. end
  43. need_ethics = AssociatesFacade.accept_code_ethics(current_user.id, form_code_of_ethics_terms_value)
  44. # --
  45. if(need_ethics==false)
  46. session()[:need_ethics] = "0"
  47. status = pay_association(current_user.id)
  48. if (!status)
  49. redirect_to user_logged_path
  50. end
  51. else
  52. session()[:need_ethics] = "1"
  53. redirect_to user_logged_path
  54. end
  55. end
  56. def pay_association_by_link
  57. user_id = params[:user_id]
  58. if(AssociatesFacade.has_accepted_ethics(user_id))
  59. if !user_id.empty?
  60. status = pay_association(user_id)
  61. if (!status)
  62. redirect_to user_logged_path
  63. end
  64. end
  65. else
  66. redirect_to new_user_session_path + "?need_ethics=1"
  67. end
  68. end
  69. def pay_cruza_grafo_link
  70. current_user = User.find_by_id(params[:user_id])
  71. status = pay_cruza_grafo()
  72. if (!status)
  73. redirect_to user_logged_path
  74. end
  75. end
  76. def pay_cruza_grafo
  77. if (params[:type_id])
  78. cg_type = CruzaGrafosType.find(params[:type_id])
  79. else
  80. cg_type = CruzaGrafosType.find(type_params[:type_id])
  81. end
  82. cruza_grafos_user = current_user.cruza_grafos_user
  83. cruza_grafos_user.cruza_grafos_type = cg_type
  84. cruza_grafos_user.save
  85. payment = Payment.find_by(user_id: current_user.id, status: "nil", payable_type: "CruzaGrafosUser")
  86. if(!payment)
  87. cruza_grafos_user.create_cruza_grafo_payment cg_type
  88. payment = Payment.find_by(user_id: current_user.id, status: "nil", payable_type: "CruzaGrafosUser")
  89. else
  90. payment.price_cents = cg_type.price_cents
  91. payment.price_currency = cg_type.price_currency
  92. payment.name = 'Cruza Grafos - ' + cg_type.description
  93. payment.save
  94. end
  95. pag_seguro_payment = PagSeguro::PaymentRequest.new
  96. pag_seguro_payment.reference = payment.id
  97. pag_seguro_payment.notification_url = payment_notification_url
  98. # EMAIL TESTE DE RETORNO
  99. # pag_seguro_payment.notification_url = 'http://chuffi.synology.me:3000/payment/notification'
  100. pag_seguro_payment.redirect_url = user_return_url
  101. pag_seguro_payment.items << {
  102. id: cruza_grafos_user.id,
  103. description: 'Cruza Grafos - ' + cg_type.description,
  104. amount: payment.price_cents.to_f/100.0,
  105. weight: 0
  106. }
  107. response = pag_seguro_payment.register
  108. if response.errors.any?
  109. raise response.errors.join("\n")
  110. else
  111. redirect_to response.url
  112. end
  113. end
  114. def notification
  115. puts("PAGSEGURO-TRANSACTION")
  116. transactionXML = PagSeguro::Transaction.find_by_notification_code(params[:notificationCode])
  117. if transactionXML.errors.empty?
  118. payment = Payment.find(transactionXML.reference)
  119. transaction = create_transaction(payment, transactionXML)
  120. if payment.payable_type == "Associate"
  121. handle_associate_payment_notification(payment, transaction)
  122. elsif payment.payable_type == "CruzaGrafosUser"
  123. handle_grafos_payment_notification(payment, transaction)
  124. end
  125. end
  126. render body: nil, status: 200
  127. # render nothing: true, status: 200
  128. end
  129. def handle_associate_payment_notification(payment, transaction)
  130. case transaction.statusId
  131. when 1 #Aguardando pagamento
  132. if payment.may_start?
  133. payment.start!
  134. payment.payable.pay!
  135. end
  136. when 2 #Em análise
  137. if payment.may_analyze?
  138. payment.analyze!
  139. end
  140. when 3 #Paga
  141. if payment.may_pay?
  142. payment.pay_date = Time.now
  143. payment.pay!
  144. if payment.payable.may_pay?
  145. payment.payable.pay!
  146. end
  147. payment.payable.paid!
  148. end
  149. when 4 #Disponível
  150. if payment.may_finish?
  151. payment.finish!
  152. if payment.payable.may_pay?
  153. payment.payable.pay!
  154. end
  155. if payment.payable.may_paid?
  156. payment.payable.paid!
  157. end
  158. end
  159. when 5 #Em disputa
  160. if payment.may_dispute?
  161. payment.dispute!
  162. end
  163. when 6 #Devolvida
  164. if payment.may_return?
  165. payment.return!
  166. payment.payable.not_paid!
  167. end
  168. when 7 #Cancelada
  169. if payment.may_cancel?
  170. payment.cancel!
  171. payment.payable.not_paid!
  172. end
  173. end
  174. # console.debug(transaction.inspect)
  175. # binding.pry()
  176. end
  177. def handle_grafos_payment_notification(payment, transaction)
  178. case transaction.statusId
  179. when 1 #Aguardando pagamento
  180. if payment.may_start?
  181. payment.start!
  182. payment.payable.user_paid!
  183. end
  184. when 2 #Em análise
  185. if payment.may_analyze?
  186. payment.analyze!
  187. end
  188. when 3 #Paga
  189. if payment.may_pay?
  190. payment.pay_date = Time.now
  191. if !payment.pay!
  192. puts payment.errors.inspect
  193. end
  194. if payment.payable.may_user_paid?
  195. payment.payable.user_paid!
  196. end
  197. payment.payable.payment_confirm!
  198. end
  199. when 4 #Disponível
  200. if payment.may_finish?
  201. payment.finish!
  202. if payment.payable.may_user_paid?
  203. payment.payable.user_paid!
  204. end
  205. if payment.payable.may_ payment_confirm?
  206. payment.payable.payment_confirm!
  207. end
  208. end
  209. when 5 #Em disputa
  210. if payment.may_dispute?
  211. payment.dispute!
  212. end
  213. when 6 #Devolvida
  214. if payment.may_return?
  215. payment.return!
  216. payment.payable.not_paid!
  217. end
  218. when 7 #Cancelada
  219. if payment.may_cancel?
  220. payment.cancel!
  221. payment.payable.not_paid!
  222. end
  223. end
  224. end
  225. def create_transaction(payment, transactionXML)
  226. transaction = Transaction.new
  227. transaction.payment = payment
  228. transaction.code = transactionXML.code
  229. transaction.paymentLink = transactionXML.payment_link
  230. transaction.typeId = transactionXML.type_id
  231. transaction.statusId = transactionXML.status.id
  232. transaction.paymentMethodTypeId = transactionXML.payment_method.type_id
  233. transaction.paymentMethodCode = transactionXML.payment_method.code
  234. transaction.grossamount = transactionXML.gross_amount
  235. transaction.discountAmount = transactionXML.discount_amount
  236. transaction.netAmount = transactionXML.net_amount
  237. transaction.extraAmount = transactionXML.extra_amount
  238. transaction.installments = transactionXML.installments
  239. transaction.escrowEndDate = transactionXML.escrow_end_date
  240. transaction.creditor_fees = transactionXML.creditor_fees.to_json
  241. transaction.items = transactionXML.items.to_json
  242. transaction.sender = transactionXML.sender.to_json
  243. transaction.shipping = transactionXML.shipping.to_json
  244. # raise transaction.errors.inspect unless transaction.valid?
  245. if !transaction.save
  246. puts transaction.errors.inspect
  247. end
  248. return transaction
  249. end
  250. def set_headers
  251. headers['Access-Control-Allow-Origin'] = '*'
  252. headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
  253. headers['Access-Control-Request-Method'] = '*'
  254. headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
  255. end
  256. def receipt
  257. @payment = Payment.find(params[:id])
  258. @transaction= Transaction.find_by(payment_id: params[:id])
  259. x = @payment.user_id
  260. @user = User.find_by(id: x)
  261. @associate = Associate.find_by(user_id: x)
  262. y = @associate.association_type_id
  263. @association_types = AssociationType.find(y)
  264. render :receipt, layout: false
  265. end
  266. private
  267. def payment_params
  268. params.require(:payment).permit!
  269. end
  270. def type_params
  271. params.require(:type).permit!
  272. end
  273. def payment_value_params
  274. params.require(:value)
  275. end
  276. def pay_association(user_id)
  277. associate = Associate.find_by(user_id: user_id)
  278. payment = Payment.find_by(user_id: user_id, status: "nil", payable_type: "Associate")
  279. if (associate.nil?)
  280. return false
  281. end
  282. if(!payment)
  283. associate.create_association_payment
  284. payment = Payment.find_by(user_id: user_id, status: "nil", payable_type: "Associate")
  285. end
  286. pag_seguro_payment = PagSeguro::PaymentRequest.new
  287. pag_seguro_payment.reference = payment.id
  288. pag_seguro_payment.notification_url = payment_notification_url
  289. # pag_seguro_payment.notification_url = 'http://chuffi.synology.me:3000/payment/notification'
  290. pag_seguro_payment.redirect_url = user_return_url
  291. pag_seguro_payment.items << {
  292. id: associate.association_type.id,
  293. description: payment.payable_type,
  294. amount: payment.price_cents.to_f/100.0,
  295. weight: 0
  296. }
  297. response = pag_seguro_payment.register
  298. if response.errors.any?
  299. raise response.errors.join("\n")
  300. else
  301. redirect_to response.url
  302. end
  303. end
  304. end

app/controllers/projects_controller.rb

0.0% lines covered

55 relevant lines. 0 lines covered and 55 lines missed.
    
  1. class ProjectsController < ApplicationController
  2. before_action :set_project, only: %i[show edit destroy publish unpublish]
  3. layout 'admin'
  4. before_action :authenticate_admin!
  5. def index
  6. @projects = Project.all
  7. end
  8. def show; end
  9. def new
  10. @project = Project.new
  11. @project_info = ProjectInfo.new
  12. end
  13. def edit; end
  14. def create
  15. @project = Project.new(project_params.except(:project_infos))
  16. @project.section_ids = params[:project]['section_ids']
  17. @project.project_info = ProjectInfo.new(link: project_params[:project_infos][:link],
  18. content_type: @project.type)
  19. if @project.save
  20. @project.project_info.content = @project
  21. @project.project_info.save
  22. redirect_to project_path(id: @project.id)
  23. else
  24. render :new
  25. end
  26. end
  27. def update
  28. @project = Project.find(params[:project][:id])
  29. if @project.update(project_params.except(:project_infos))
  30. @project.project_info.update_attributes(project_params[:project_infos]) if @project.project_info.present?
  31. render :show
  32. else
  33. render :edit
  34. end
  35. end
  36. def destroy
  37. @project.destroy
  38. redirect_to projects_url
  39. end
  40. def publish
  41. @project.update_attributes(published: true)
  42. redirect_to projects_path
  43. end
  44. def unpublish
  45. @project.update_attributes(published: false)
  46. redirect_to projects_path
  47. end
  48. private
  49. def set_project
  50. @project = Project.find(params[:id])
  51. end
  52. def project_params
  53. params.require(:project).permit([:image, :title, :title_summary, :content, section_ids: [], project_infos: [:link]])
  54. end
  55. end

app/controllers/sections_controller.rb

0.0% lines covered

61 relevant lines. 0 lines covered and 61 lines missed.
    
  1. class SectionsController < ApplicationController
  2. respond_to :html
  3. before_action :set_section, only: %i[show edit update destroy publish unpublish]
  4. layout 'admin'
  5. #before_action :authenticate_admin!
  6. def index
  7. @sections = Section.all
  8. end
  9. def show; end
  10. def edit; end
  11. def exhibit
  12. @section = Section.published(admin_signed_in?).find_by!(slug: params[:slug])
  13. @news = News.section_contents(@section)
  14. @publications = Publication.section_contents(@section)
  15. @congresses = Congress.section_contents(@section)
  16. @helpdesks = Helpdesk.section_contents(@section)
  17. @projects = Project.section_contents(@section)
  18. @classroomcourses = ClassroomCourse.section_contents(@section)
  19. @onlinecourses = OnlineCourse.section_contents(@section)
  20. breadcrumb_title = @section.name
  21. breadcrumb_url = '/' + @section.slug
  22. add_breadcrumb breadcrumb_title, breadcrumb_url
  23. render layout: 'application'
  24. end
  25. def new
  26. @section = Section.new
  27. end
  28. def create
  29. @section = Section.new(section_params)
  30. if @section.save
  31. respond_with(@section)
  32. else
  33. render :new
  34. end
  35. end
  36. def update
  37. @section = Section.find_by id: params[:section][:id]
  38. if @section.update(section_params)
  39. render :show
  40. else
  41. render :new
  42. end
  43. end
  44. def destroy
  45. @section.destroy
  46. end
  47. def publish
  48. @section.update(published: true)
  49. redirect_to admin_sections_path
  50. end
  51. def unpublish
  52. @section.update(published: false)
  53. redirect_to admin_sections_path
  54. end
  55. private
  56. def set_section
  57. @section = Section.find_by(slug: params[:id])
  58. end
  59. def section_params
  60. params.require(:section).permit([:name], [:description], [:banner], [:css_class], [:id])
  61. end
  62. end

app/controllers/static_contents_controller.rb

0.0% lines covered

41 relevant lines. 0 lines covered and 41 lines missed.
    
  1. class StaticContentsController < ApplicationController
  2. respond_to :html
  3. before_action :set_static_content, only: [:show, :edit, :update, :destroy]
  4. layout 'admin'
  5. # GET /static_contents
  6. def index
  7. @static_contents = StaticContent.all
  8. end
  9. # GET /static_contents/1
  10. def show
  11. end
  12. # GET /static_contents/new
  13. def new
  14. @static_content = StaticContent.new
  15. end
  16. # GET /static_contents/1/edit
  17. def edit
  18. end
  19. # POST /static_contents
  20. def create
  21. @static_content = StaticContent.new(static_content_params)
  22. if @static_content.save
  23. render :show, notice: 'Static content was successfully created.'
  24. else
  25. render :new
  26. end
  27. end
  28. # PATCH/PUT /static_contents/1
  29. def update
  30. if @static_content.update(static_content_params)
  31. render :show, notice: 'Static content was successfully updated.'
  32. else
  33. render :edit
  34. end
  35. end
  36. # DELETE /static_contents/1
  37. def destroy
  38. @static_content.destroy
  39. redirect_to static_contents_url, notice: 'Static content was successfully destroyed.'
  40. end
  41. private
  42. # Use callbacks to share common setup or constraints between actions.
  43. def set_static_content
  44. @static_content = StaticContent.find_by(slug: params[:id])
  45. end
  46. # Only allow a trusted parameter "white list" through.
  47. def static_content_params
  48. params.require(:static_content).permit(:title, :content)
  49. end
  50. end

app/controllers/transition_controller.rb

0.0% lines covered

90 relevant lines. 0 lines covered and 90 lines missed.
    
  1. class TransitionController < ApplicationController
  2. def email_validation
  3. @errors = false
  4. if(params[:email])
  5. if(!params[:email].blank?)
  6. user = User.find_by_email(params[:email])
  7. if(user && user.updated_at < Time.new(2020, 5, 13))
  8. redirect_to controller: 'transition', action: 'update_info', id: user.id
  9. else
  10. @errors = true
  11. render :email_validation
  12. end
  13. else
  14. @errors = true
  15. render :email_validation
  16. end
  17. end
  18. end
  19. def update_info
  20. @association_types = AssociationType.all
  21. if(!params[:id].blank?)
  22. @user_associate_form = UserAssociateTransitionForm.new_with_user(User.find(params[:id]))
  23. clean_empty_old_fields
  24. else
  25. redirect_to root_path
  26. end
  27. end
  28. def save_info
  29. @association_types = AssociationType.all
  30. @user_associate_form = UserAssociateTransitionForm.new(user_associate_form_whitelist)
  31. @user_associate_form.user = User.find(params[:id])
  32. if @user_associate_form.valid?
  33. messages = @user_associate_form.save
  34. if messages == true
  35. redirect_to root_path
  36. else
  37. messages.each do |error|
  38. @user_associate_form.errors.add(error[0], error[1][0])
  39. end
  40. render :update_info
  41. end
  42. else
  43. @user_associate_form.errors.each do |attribute, message|
  44. end
  45. render :update_info
  46. end
  47. end
  48. private
  49. def user_associate_form_whitelist
  50. flatten_date_array params[:user_associate_transition_form], :birthday
  51. params.require(:user_associate_transition_form).permit!
  52. end
  53. def flatten_date_array parameters, *attributes
  54. attributes.each do |attribute|
  55. parameters[attribute] = Date.new *(1..3).map { |e| parameters.delete("#{attribute}(#{e}i)").to_i}
  56. end
  57. end
  58. def email_form_whitelist
  59. params.require(:email)
  60. end
  61. def clean_empty_old_fields
  62. if(@user_associate_form.phone == '00000000000')
  63. @user_associate_form.phone = ''
  64. end
  65. if(@user_associate_form.country == '-')
  66. @user_associate_form.country = ''
  67. end
  68. if(@user_associate_form.state == '-')
  69. @user_associate_form.state = ''
  70. end
  71. if(@user_associate_form.city == '-')
  72. @user_associate_form.city = ''
  73. end
  74. if(@user_associate_form.zipcode == '-')
  75. @user_associate_form.zipcode = ''
  76. end
  77. if(@user_associate_form.address_street == '-')
  78. @user_associate_form.address_street = ''
  79. end
  80. if(@user_associate_form.neighborhood == '-')
  81. @user_associate_form.neighborhood = ''
  82. end
  83. if(@user_associate_form.address_number == '-')
  84. @user_associate_form.address_number = ''
  85. end
  86. if(@user_associate_form.activity_description == '-')
  87. @user_associate_form.activity_description = ''
  88. end
  89. end
  90. end

app/controllers/user_associate_admin_controller.rb

0.0% lines covered

51 relevant lines. 0 lines covered and 51 lines missed.
    
  1. class UserAssociateAdminController < ApplicationController
  2. before_action :authenticate_admin!
  3. layout 'admin'
  4. def edit
  5. @association_types = AssociationType.all
  6. if(params[:id])
  7. @user_associate_form = UserAssociateAdminEditForm.new_with_user(User.find(params[:id]))
  8. else
  9. @user_associate_form = UserAssociateAdminEditForm.new_with_user(current_user)
  10. end
  11. end
  12. def update
  13. @association_types = AssociationType.all
  14. @user_associate_form = UserAssociateAdminEditForm.new(user_associate_form_whitelist)
  15. @user_associate_form.user = User.find(params[:id])
  16. @user_associate_form.admin = current_admin
  17. if @user_associate_form.valid?
  18. if @user_associate_form.save
  19. redirect_to admin_users_path
  20. else
  21. @user_associate_form.errors.each do |attribute, message|
  22. end
  23. render :edit
  24. end
  25. else
  26. @user_associate_form.errors.each do |attribute, message|
  27. end
  28. render :edit
  29. end
  30. end
  31. private
  32. def user_associate_form_whitelist
  33. if(params[:user_associate_admin_edit_form]["valid_until(3i)"])
  34. flatten_date_array params[:user_associate_admin_edit_form], :birthday, :valid_until, :approval_payment_date, :conclusion_date
  35. else
  36. flatten_date_array params[:user_associate_admin_edit_form], :birthday
  37. end
  38. flatten_datetime_array params[:user_associate_admin_edit_form], :code_of_ethics_terms_at, :accepted_terms_at
  39. params.require(:user_associate_admin_edit_form).permit!
  40. end
  41. def flatten_datetime_array parameters, *attributes
  42. attributes.each do |attribute|
  43. parameters[attribute] = DateTime.new *(1..5).map { |e| parameters.delete("#{attribute}(#{e}i)").to_i}
  44. end
  45. end
  46. def flatten_date_array parameters, *attributes
  47. attributes.each do |attribute|
  48. parameters[attribute] = Date.new *(1..3).map { |e| parameters.delete("#{attribute}(#{e}i)").to_i}
  49. end
  50. end
  51. end

app/controllers/user_associate_controller.rb

0.0% lines covered

74 relevant lines. 0 lines covered and 74 lines missed.
    
  1. class UserAssociateController < ApplicationController
  2. before_action :authenticate_user!
  3. def home_logged
  4. @user = current_user
  5. @associate = Associate.where(user: current_user).first
  6. @types = CruzaGrafosType.all
  7. @need_ethics = session()[:need_ethics]
  8. if(!@associate.nil? && @associate.code_of_ethics_terms)
  9. @need_ethics = "0"
  10. end
  11. end
  12. def payment
  13. @associate = Associate.where(user_id: current_user.name).first
  14. @payments = Kaminari.paginate_array(Payment.filtered(current_user, params[:filter_selected]))
  15. @payments = @payments.page(params[:page] || 1).per(10)
  16. @filter = Payment.filters.map{ |name| [ t("activerecord.models.payment.filter.#{name}"), name] }
  17. end
  18. def return
  19. @associate = Associate.where(user_id: current_user.name).first
  20. end
  21. def get_association_payment
  22. if Associate.where(user_id: current_user.name).first.isAssociationValid
  23. flash[:notice] = "Sua associação ainda é valida"
  24. render :action => :home_logged
  25. else
  26. redirect_to :payment_create_path
  27. end
  28. end
  29. def edit
  30. @association_types = AssociationType.all
  31. if(!params[:id].blank?)
  32. @user_associate_form = UserAssociateEditForm.new_with_user(User.find(params[:id]))
  33. else
  34. @user_associate_form = UserAssociateEditForm.new_with_user(current_user)
  35. end
  36. # @cpf_inalterado = @user_associate_form.cpf
  37. end
  38. def update
  39. @association_types = AssociationType.all
  40. @user_associate_form = UserAssociateEditForm.new(user_associate_form_whitelist)
  41. @user_associate_form.user = User.find(params[:id])
  42. if !@user_associate_form.user.associate.nil? && @user_associate_form.details_file.nil?
  43. @user_associate_form.details_file = @user_associate_form.user.associate.details_file
  44. end
  45. if !@user_associate_form.user.associate.nil? && @user_associate_form.association_type.nil?
  46. @user_associate_form.association_type = AssociationType.find(params[:user_associate_edit_form][:association_type_id])
  47. end
  48. if @user_associate_form.valid?
  49. if @user_associate_form.save
  50. redirect_to user_logged_path
  51. else
  52. @user_associate_form.errors.add(:cpf, 'CFP Já cadastrados')
  53. render :edit
  54. end
  55. else
  56. @user_associate_form.errors.each do |attribute, message|
  57. end
  58. render :edit
  59. end
  60. end
  61. private
  62. def user_associate_form_whitelist
  63. if params[:user_associate_edit_form]["conclusion_date(2i)"].blank?
  64. flatten_date_array params[:user_associate_edit_form], :birthday
  65. else
  66. flatten_date_array params[:user_associate_edit_form], :birthday, :conclusion_date
  67. end
  68. params.require(:user_associate_edit_form).permit!
  69. end
  70. def flatten_date_array parameters, *attributes
  71. attributes.each do |attribute|
  72. parameters[attribute] = Date.new *(1..3).map { |e| parameters.delete("#{attribute}(#{e}i)").to_i}
  73. end
  74. end
  75. end

app/controllers/users/confirmations_controller.rb

0.0% lines covered

2 relevant lines. 0 lines covered and 2 lines missed.
    
  1. class Users::ConfirmationsController < Devise::ConfirmationsController
  2. # GET /resource/confirmation/new
  3. # def new
  4. # super
  5. # end
  6. # POST /resource/confirmation
  7. # def create
  8. # super
  9. # end
  10. # GET /resource/confirmation?confirmation_token=abcdef
  11. # def show
  12. # super
  13. # end
  14. # protected
  15. # The path used after resending confirmation instructions.
  16. # def after_resending_confirmation_instructions_path_for(resource_name)
  17. # super(resource_name)
  18. # end
  19. # The path used after confirmation.
  20. # def after_confirmation_path_for(resource_name, resource)
  21. # super(resource_name, resource)
  22. # end
  23. end

app/controllers/users/omniauth_callbacks_controller.rb

0.0% lines covered

2 relevant lines. 0 lines covered and 2 lines missed.
    
  1. class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  2. # You should configure your model like this:
  3. # devise :omniauthable, omniauth_providers: [:twitter]
  4. # You should also create an action method in this controller like this:
  5. # def twitter
  6. # end
  7. # More info at:
  8. # https://github.com/plataformatec/devise#omniauth
  9. # GET|POST /resource/auth/twitter
  10. # def passthru
  11. # super
  12. # end
  13. # GET|POST /users/auth/twitter/callback
  14. # def failure
  15. # super
  16. # end
  17. # protected
  18. # The path used when OmniAuth fails
  19. # def after_omniauth_failure_path_for(scope)
  20. # super(scope)
  21. # end
  22. end

app/controllers/users/passwords_controller.rb

0.0% lines covered

15 relevant lines. 0 lines covered and 15 lines missed.
    
  1. class Users::PasswordsController < Devise::PasswordsController
  2. # GET /resource/password/new
  3. # def new
  4. # super
  5. # end
  6. # POST /resource/password
  7. def create
  8. recaptcha_valid = verify_recaptcha(action: 'changePassword', minimum_score: ENV['RECAPTCHA_MINSCORE'].to_i, action: 'create', secret_key: ENV['RECAPTCHA_SECRETKEY'])
  9. if recaptcha_valid
  10. super
  11. else
  12. flash.now[:error] = "Ops, não foi possível completar a validação anti-robo."
  13. respond_with resource, location: new_user_password_path(resource_name)
  14. end
  15. end
  16. # GET /resource/password/edit?reset_password_token=abcdef
  17. # def edit
  18. # super
  19. # end
  20. # PUT /resource/password
  21. # def update
  22. # super
  23. # end
  24. # protected
  25. # def after_resetting_password_path_for(resource)
  26. # super(resource)
  27. # end
  28. # The path used after sending reset password instructions
  29. protected
  30. def after_sending_reset_password_instructions_path_for(resource_name)
  31. "#{new_user_password_url}?modal=show"
  32. end
  33. end

app/controllers/users/registrations_controller.rb

0.0% lines covered

53 relevant lines. 0 lines covered and 53 lines missed.
    
  1. class Users::RegistrationsController < Devise::RegistrationsController
  2. before_action :configure_sign_up_params, only: [:create]
  3. before_action :configure_account_update_params, only: [:update]
  4. # GET /resource/sign_up
  5. def new
  6. add_breadcrumb 'registrar-se'
  7. @states = State.all
  8. @statesArray = []
  9. @states.each do |n|
  10. @statesArray << n.sigla
  11. end
  12. super
  13. end
  14. # POST /resource
  15. def create
  16. @user = User.new(params['user'].permit!)
  17. recaptcha_valid = verify_recaptcha(model: @user, action: 'registration', minimum_score: ENV['RECAPTCHA_MINSCORE'].to_i, action: 'create',secret_key: ENV['RECAPTCHA_SECRETKEY'])
  18. if recaptcha_valid
  19. super
  20. else
  21. flash.now[:error] = "Ops, não foi possível completar a validação anti-robo."
  22. respond_with resource, location: new_registration_path(resource_name)
  23. end
  24. end
  25. # GET /resource/edit
  26. def edit
  27. @association_types = AssociationType.all
  28. super
  29. end
  30. # PUT /resource
  31. def update
  32. super
  33. end
  34. # DELETE /resource
  35. def destroy
  36. super
  37. end
  38. # GET /resource/cancel
  39. # Forces the session data which is usually expired after sign
  40. # in to be expired now. This is useful if the user wants to
  41. # cancel oauth signing in/up in the middle of the process,
  42. # removing all OAuth session data.
  43. def cancel
  44. super
  45. end
  46. protected
  47. # If you have extra params to permit, append them to the sanitizer.
  48. def configure_sign_up_params
  49. devise_parameter_sanitizer.permit(:sign_up, keys: %i[attribute name birthday email password password_confirmation country state city institution association_type newsletter])
  50. end
  51. # If you have extra params to permit, append them to the sanitizer.
  52. def configure_account_update_params
  53. devise_parameter_sanitizer.permit(:account_update, keys: %i[attribute name birthday email password password_confirmation country state city institution association_type newsletter])
  54. end
  55. # The path used after sign up.
  56. def after_sign_up_path_for(resource)
  57. if params[:f] == 'associate'
  58. new_associate_path
  59. else
  60. user_logged_path
  61. end
  62. end
  63. # The path used after sign up for inactive accounts.
  64. def after_inactive_sign_up_path_for(resource)
  65. super(resource)
  66. end
  67. end

app/controllers/users/sessions_controller.rb

0.0% lines covered

37 relevant lines. 0 lines covered and 37 lines missed.
    
  1. class Users::SessionsController < Devise::SessionsController
  2. # before_action :configure_sign_in_params, only: [:create]
  3. # GET /resource/sign_in
  4. def new
  5. @need_ethics = params()['need_ethics']
  6. if(@need_ethics == "1")
  7. flash.now[:error] = t("devise.sessions.pay_need_ethics")
  8. end
  9. super
  10. end
  11. # POST /resource/sign_in
  12. def create
  13. recaptcha_valid = verify_recaptcha(action: 'login', minimum_score: ENV['RECAPTCHA_MINSCORE'].to_i, action: 'create', secret_key: ENV['RECAPTCHA_SECRETKEY'])
  14. if recaptcha_valid
  15. super
  16. else
  17. flash.now[:error] = "Ops, não foi possível completar a validação anti-robo."
  18. respond_with resource, location: new_user_session_path
  19. end
  20. end
  21. # def create
  22. # if validate_antirobot(params[:token], params[:tUsuario])
  23. # super
  24. # else
  25. # flash.now[:error] = "Ops, não foi possível completar a validação anti-robo."
  26. # respond_with resource, location: new_user_session_path
  27. # end
  28. # end
  29. # DELETE /resource/sign_out
  30. def destroy
  31. super
  32. end
  33. protected
  34. def after_sign_in_path_for(resource)
  35. if params[:f] == 'associate'
  36. new_associate_path
  37. else
  38. user_logged_path
  39. end
  40. if resource.is_a?(User) && !resource.active?
  41. sign_out resource
  42. flash.now[:error] = 'Essa conta está desativada'
  43. root_path
  44. new_user_session_path
  45. else
  46. super
  47. end
  48. end
  49. # If you have extra params to permit, append them to the sanitizer.
  50. # def configure_sign_in_params
  51. # devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
  52. # end
  53. end

app/controllers/users/unlocks_controller.rb

0.0% lines covered

2 relevant lines. 0 lines covered and 2 lines missed.
    
  1. class Users::UnlocksController < Devise::UnlocksController
  2. # GET /resource/unlock/new
  3. # def new
  4. # super
  5. # end
  6. # POST /resource/unlock
  7. # def create
  8. # super
  9. # end
  10. # GET /resource/unlock?unlock_token=abcdef
  11. # def show
  12. # super
  13. # end
  14. # protected
  15. # The path used after sending unlock password instructions
  16. # def after_sending_unlock_instructions_path_for(resource)
  17. # super(resource)
  18. # end
  19. # The path used after unlocking the resource
  20. # def after_unlock_path_for(resource)
  21. # super(resource)
  22. # end
  23. end

app/controllers/users_controller.rb

0.0% lines covered

134 relevant lines. 0 lines covered and 134 lines missed.
    
  1. class UsersController < ApplicationController
  2. skip_before_action :verify_authenticity_token, :only => [:multiple_update]
  3. before_action :set_user, only: %i[show edit update destroy]
  4. before_action :authenticate_admin!
  5. layout 'admin'
  6. TRANSLATE_FILTER_LABEL = {
  7. 'name_likeness' => 'Nome',
  8. 'email_likeness' => 'Email',
  9. 'cpf_value' => 'CPF',
  10. 'state_likeness' => 'Estado',
  11. 'city_likeness' => 'Cidade',
  12. 'association_state_value' => 'Estado da associacao',
  13. 'association_type_id_value' => 'Perfil de Pagamento',
  14. 'birthday_start' => 'Aniversario de',
  15. 'birthday_end' => 'Aniversario para',
  16. 'created_at_start' => 'Data de Inscricao de',
  17. 'created_at_end' => 'Data de Inscricao para',
  18. 'valid_until_start' => 'Data de Vencimento de',
  19. 'valid_until_end' => 'Data de Vencimento para',
  20. }.freeze
  21. # GET /users
  22. def index
  23. @array = []
  24. @filtros = ""
  25. @association_types = AssociationType.all
  26. if params[:q].present?
  27. @users = User.fulltext_search(params[:q])
  28. elsif params[:filter_by].present?
  29. @users = User.filter_by(params[:filter_by][:user])
  30. params[:filter_by][:user].each do |_filter_name, filter_value|
  31. next if filter_value.blank?
  32. if( (_filter_name.include? "_start") || (_filter_name.include? "_end"))
  33. @filtros = "#{@filtros}, [#{TRANSLATE_FILTER_LABEL[_filter_name]}: #{DateTime.strptime(filter_value, '%Y-%m-%d').strftime("%d/%m/%Y") }]"
  34. else
  35. @filtros = "#{@filtros}, [#{TRANSLATE_FILTER_LABEL[_filter_name]}: #{filter_value}]"
  36. @array << [_filter_name, filter_value]
  37. end
  38. end
  39. params[:filter_by][:associate].each do |_filter_name, filter_value|
  40. next if filter_value.blank?
  41. @associates = Associate.filter_by(params[:filter_by][:associate])
  42. @users = @users.where(id: @associates.map(&:user_id))
  43. names = []
  44. if ( _filter_name == 'association_type_id_value')
  45. AssociationType.where(id: filter_value).each do |associationType|
  46. names << associationType.description
  47. end
  48. @filtros = "#{@filtros}, [#{TRANSLATE_FILTER_LABEL[_filter_name]}: #{names}]"
  49. elsif( _filter_name == 'association_state_value')
  50. filter_value.each do |name|
  51. names << t('activerecord.models.associate.'+name).titleize
  52. end
  53. @filtros = "#{@filtros}, [#{TRANSLATE_FILTER_LABEL[_filter_name]}: #{names}]"
  54. elsif( (_filter_name.include? "_start") || (_filter_name.include? "_end"))
  55. @filtros = "#{@filtros}, [#{TRANSLATE_FILTER_LABEL[_filter_name]}: #{DateTime.strptime(filter_value, '%Y-%m-%d').strftime("%d/%m/%Y") }]"
  56. else
  57. @filtros = "#{@filtros}, [#{TRANSLATE_FILTER_LABEL[_filter_name]}: #{filter_value}]"
  58. end
  59. @array << [_filter_name, filter_value]
  60. # break
  61. end
  62. else
  63. @users = User.all
  64. end
  65. @users_paginate = @users.page(params[:page] || 1).per(50)
  66. @users_length = @users.count
  67. respond_to do |format|
  68. format.html
  69. format.xlsx
  70. end
  71. end
  72. # GET /users/1
  73. def show
  74. if @user.associate
  75. @payments = @user.payments
  76. end
  77. end
  78. # GET /users/new
  79. def new
  80. @user = User.new
  81. @singular_table_name = User.new
  82. end
  83. # GET /users/1/edit
  84. def edit; end
  85. # POST /users
  86. def create
  87. @user = User.new(user_params)
  88. if @user.save
  89. redirect_to admin_user_path(@user), notice: 'User was successfully created.'
  90. else
  91. render :new
  92. end
  93. end
  94. # PATCH/PUT /users/1
  95. def update
  96. if @user.update(user_params)
  97. redirect_to admin_user_path(@user), notice: 'User was successfully updated.'
  98. else
  99. render :edit
  100. end
  101. end
  102. # DELETE /users/1
  103. def destroy
  104. @user.destroy
  105. redirect_to admin_users_path, notice: 'User was successfully destroyed.'
  106. end
  107. def associate_start
  108. User.find(params['id']).associate.start!
  109. redirect_to admin_users_path
  110. end
  111. def associate_approve
  112. User.find(params['id']).associate.approve!
  113. redirect_to admin_users_path
  114. end
  115. def associate_reject
  116. user = User.find(params['id'])
  117. user.associate.motive = params['reason']
  118. user.associate.save
  119. user.associate.reject!
  120. redirect_to admin_users_path
  121. end
  122. def associate_paid
  123. associate = User.find(params['id']).associate
  124. payment = associate.payments.where(payable_type: "Associate").where(payable_id: associate.id).where(status: 'awaiting_payment').first()
  125. payment.manual_pay!
  126. # @associate.payment_type = 'paid'
  127. # associate.paid!
  128. # payment = associate.payments.where(payable_type: "Associate").where(payable_id:
  129. # payment.pay_date = Time.now
  130. redirect_to admin_users_path
  131. end
  132. def associate_expire
  133. User.find(params['id']).associate.expire!
  134. redirect_to admin_users_path
  135. end
  136. private
  137. # Use callbacks to share common setup or constraints between actions.
  138. def set_user
  139. @user = User.find(params[:id])
  140. end
  141. # Only allow a trusted parameter "white list" through.
  142. def user_params
  143. params.require(:user).permit(
  144. :name, :birthday, :email, :institution, :newsletter, :active, :password,
  145. :password_confirmation, :country, :state, :city, :active
  146. # :password_confirmation, :country, :state, :city, :association_type
  147. )
  148. end
  149. end

app/facades/associates_facade.rb

0.0% lines covered

63 relevant lines. 0 lines covered and 63 lines missed.
    
  1. class AssociatesFacade
  2. def self.has_accepted_ethics(userid)
  3. associate = Associate.where(user_id: userid).first()
  4. return (associate.code_of_ethics_terms)
  5. end
  6. def self.accept_code_ethics(userid, accepted)
  7. need_ethics = false
  8. if(AssociatesFacade.has_accepted_ethics(userid) == false)
  9. if(accepted == "1")
  10. associate = Associate.where(user_id: userid).first()
  11. associate.code_of_ethics_terms = true
  12. associate.code_of_ethics_terms_at = DateTime.now
  13. associate.save
  14. need_ethics = false
  15. else
  16. need_ethics = true
  17. end
  18. end
  19. return need_ethics
  20. end
  21. def self.expire_associates
  22. puts( Time.now.to_s+ "--START DO JOB DE ASSOCIADOS")
  23. Associate.where(association_state: 'running', :valid_until => (Time.now - 30.days)..(Time.now + 30.days))
  24. .or(Associate.where(association_state: 'expired', :valid_until => (Time.now - 10.days)..Time.now))
  25. .each do |associate|
  26. puts("Email:" + associate.user.email + " Validade: "+associate.valid_until.to_date.to_s)
  27. case
  28. when (associate.valid_until.to_date - 30.days) == Date.today
  29. associate.will_expired_actions
  30. puts("Enviado lembrete de 30 dias restantes")
  31. when (associate.valid_until.to_date - 10.days) == Date.today
  32. associate.send_will_expired_email(10)
  33. puts( "Enviado lembrete de 10 dias restantes")
  34. when (associate.valid_until.to_date - 5.days) == Date.today
  35. associate.send_will_expired_email(5)
  36. puts( "Enviado lembrete de 5 dias restantes")
  37. when (associate.valid_until.to_date <= Date.today && associate.association_state == 'running')
  38. associate.expire
  39. puts( "Enviado lembrete de associacao expirada")
  40. when (associate.valid_until.to_date + 5.days) == Date.today
  41. associate.send_expired_email(5)
  42. puts( "Enviado lembrete de 5 dias de associação expirada")
  43. when (associate.valid_until.to_date + 10.days) == Date.today
  44. associate.send_expired_email(10)
  45. puts("Enviado lembrete de 10 dias de associação expirada")
  46. else
  47. puts("Nenhuma ação feita")
  48. end
  49. end
  50. puts( Time.now.to_s+ "--START DO JOB DE USUARIO CRUZA GRAFO")
  51. CruzaGrafosUser.where(user_state: 'running', valid_until: Time.now)
  52. .each do |cruzaGrafoUser|
  53. puts("Email:" + cruzaGrafoUser.user.email + " Validade: "+cruzaGrafoUser.valid_until.to_date.to_s)
  54. cruzaGrafoUser.expire
  55. end
  56. CruzaGrafosUser.where(in_trial: true, valid_until: Time.now)
  57. .each do |cruzaGrafoUser|
  58. puts("Email:" + cruzaGrafoUser.user.email + "Trial finalizado ")
  59. cruzaGrafoUser.expireTrial
  60. end
  61. puts("JOB EXECUTADO")
  62. end
  63. end

app/forms/user_associate_admin_edit_form.rb

0.0% lines covered

45 relevant lines. 0 lines covered and 45 lines missed.
    
  1. class UserAssociateAdminEditForm
  2. include ActiveModel::Model
  3. USER_ATTRIBUTES = [:name, :birthday, :country, :state, :city, :institution, :newsletter, :active, :email]
  4. ASSOCIATE_ATTRIBUTES = [:country, :state, :city, :zipcode, :address_street, :neighborhood, :address_number,
  5. :address_complement, :activity_description, :phone, :cpf,
  6. :details_file, :accepted_terms, :approval_payment_date, :valid_until,
  7. :association_type_id, :conclusion_date, :acting_medium, :color_or_race,
  8. :gender, :code_of_ethics_terms, :code_of_ethics_terms_at, :accepted_terms_at, :whatsapp]
  9. attr_accessor *(USER_ATTRIBUTES + ASSOCIATE_ATTRIBUTES)
  10. attr_accessor :user, :admin
  11. validates :name, :birthday, :country, :state, :city, :email, presence: true
  12. validates :phone, :zipcode, :address_street, :neighborhood, :address_number, :approval_payment_date, :valid_until,
  13. :association_type_id, :code_of_ethics_terms, :color_or_race, presence: true, if: :associate
  14. validates :code_of_ethics_terms, acceptance: { message: "Este associado ainda não deu aceite neste termo"}, if: :associate
  15. validate :cpf_uniqueness, if: :associate
  16. validates_cpf_format_of :cpf, if: :associate
  17. def cpf_uniqueness
  18. if (associate.cpf != self.cpf)
  19. if (Associate.where(cpf: self.cpf).first)
  20. errors.add(:cpf, 'Este cpf já está cadastrado na nossa base')
  21. end
  22. end
  23. end
  24. def self.new_with_user(user)
  25. attrs = user.attributes.slice(*USER_ATTRIBUTES.map(&:to_s))
  26. attrs = attrs.merge(user.associate.attributes.slice(*ASSOCIATE_ATTRIBUTES.map(&:to_s))) if user.associate.present?
  27. user_associate = new(attrs)
  28. user_associate.user = user
  29. user_associate
  30. end
  31. def associate
  32. user.try(:associate)
  33. end
  34. def save
  35. if !valid?
  36. return false
  37. end
  38. if user.associate.blank?
  39. return user.update(instance_values.slice(*USER_ATTRIBUTES.map(&:to_s)))
  40. else
  41. return (user.update(instance_values.slice(*USER_ATTRIBUTES.map(&:to_s))) &&
  42. user.associate.update(instance_values.slice(*ASSOCIATE_ATTRIBUTES.map(&:to_s))))
  43. end
  44. end
  45. end

app/forms/user_associate_edit_form.rb

0.0% lines covered

38 relevant lines. 0 lines covered and 38 lines missed.
    
  1. class UserAssociateEditForm
  2. include ActiveModel::Model
  3. include ActiveModel::Dirty
  4. # include UsersHelper
  5. define_attribute_methods :cpf
  6. USER_ATTRIBUTES = [:name, :birthday, :country, :state, :city, :institution, :newsletter]
  7. ASSOCIATE_ATTRIBUTES = [:country, :state, :city, :zipcode, :address_street, :neighborhood, :address_number,
  8. :address_complement, :activity_description, :phone, :cpf, :association_type,
  9. :conclusion_date, :details_file, :association_type_id, :color_or_race, :gender, :code_of_ethics_terms, :code_of_ethics_terms_at, :acting_medium, :whatsapp]
  10. # mount_uploader :details_file, FileUploader
  11. attr_accessor *(USER_ATTRIBUTES + ASSOCIATE_ATTRIBUTES)
  12. attr_accessor :user
  13. validates :name, :birthday, :country, :state, :city, presence: true
  14. validates :phone, :zipcode, :address_street, :code_of_ethics_terms, :neighborhood, :address_number, :association_type_id, :color_or_race, presence: true, if: :associate
  15. validates :code_of_ethics_terms, acceptance: { message: "Este associado ainda não deu aceite neste termo"}, if: :associate
  16. validates_cpf_format_of :cpf, if: :associate
  17. validates_presence_of :conclusion_date, :if => lambda { |o| o.association_type_id == '2a3ee51c-434a-40e6-a96c-622b36c6a596' }
  18. def self.new_with_user(user)
  19. attrs = user.attributes.slice(*USER_ATTRIBUTES.map(&:to_s))
  20. attrs = attrs.merge(user.associate.attributes.slice(*ASSOCIATE_ATTRIBUTES.map(&:to_s))) if user.associate.present?
  21. user_associate = new(attrs)
  22. user_associate.details_file = user.associate.details_file if user.associate.present?
  23. user_associate.association_type = user.associate.association_type if user.associate.present?
  24. user_associate.user = user
  25. user_associate
  26. end
  27. def associate
  28. user.try(:associate)
  29. end
  30. def save
  31. return unless valid?
  32. user.update(instance_values.slice(*USER_ATTRIBUTES.map(&:to_s)))
  33. return true if user.associate.blank?
  34. if !user.associate.update(instance_values.slice(*ASSOCIATE_ATTRIBUTES.map(&:to_s)))
  35. return false
  36. else
  37. return true
  38. end
  39. end
  40. end

app/forms/user_associate_transition_form.rb

0.0% lines covered

38 relevant lines. 0 lines covered and 38 lines missed.
    
  1. class UserAssociateTransitionForm
  2. include ActiveModel::Model
  3. include ActiveModel::Dirty
  4. define_attribute_methods :cpf
  5. USER_ATTRIBUTES = [:name, :birthday, :country, :state, :city, :institution, :newsletter, :email, :password ,:password_confirmation]
  6. ASSOCIATE_ATTRIBUTES = [:country, :state, :city, :zipcode, :address_street, :neighborhood, :address_number,
  7. :address_complement, :activity_description, :phone, :cpf, :color_or_race, :gender, :acting_medium]
  8. attr_accessor *(USER_ATTRIBUTES + ASSOCIATE_ATTRIBUTES)
  9. attr_accessor :user
  10. validates :name, :birthday, :country, :state, :city, :email, presence: true
  11. validates :phone, :zipcode, :address_street, :neighborhood, :address_number, :activity_description, :color_or_race, presence: true, if: :associate
  12. validates :password, confirmation: true
  13. validates :password_confirmation, presence: true
  14. validates :password, length: { in: 6..20 }
  15. validates_cpf_format_of :cpf, if: :associate
  16. def self.new_with_user(user)
  17. attrs = user.attributes.slice(*USER_ATTRIBUTES.map(&:to_s))
  18. attrs = attrs.merge(user.associate.attributes.slice(*ASSOCIATE_ATTRIBUTES.map(&:to_s))) if user.associate.present?
  19. user_associate = new(attrs)
  20. user_associate.user = user
  21. user_associate
  22. end
  23. def associate
  24. user.try(:associate)
  25. end
  26. def save
  27. return unless valid?
  28. if !user.update(instance_values.slice(*USER_ATTRIBUTES.map(&:to_s)))
  29. return user.errors.messages
  30. end
  31. return true if user.associate.blank?
  32. if !user.associate.update(instance_values.slice(*ASSOCIATE_ATTRIBUTES.map(&:to_s)))
  33. return user.associate.errors.messages
  34. else
  35. return true
  36. end
  37. end
  38. end

app/helpers/admin_associates_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 module AdminAssociatesHelper
  2. end

app/helpers/application_helper.rb

44.44% lines covered

9 relevant lines. 4 lines covered and 5 lines missed.
    
  1. 1 module ApplicationHelper
  2. 1 def contains_errors(record)
  3. return unless record.present? && record.errors.present?
  4. content_tag(:div, 'Revise os problemas em vermelho abaixo:', class: 'alert alert-danger')
  5. end
  6. 1 def no_cache_image
  7. r = Random.new
  8. r.rand(100...10_000)
  9. end
  10. 1 def youtube_video(url)
  11. render :partial => 'layouts/site/video', :locals => { :url => url }
  12. end
  13. end

app/helpers/content_helper.rb

43.33% lines covered

30 relevant lines. 13 lines covered and 17 lines missed.
    
  1. 1 module ContentHelper
  2. 1 def content_type
  3. params[:type]
  4. end
  5. 1 def content_type_name
  6. t("activerecord.models.#{content_type}.one")
  7. end
  8. 1 def content_type_name_plural
  9. t("activerecord.models.#{content_type}.other")
  10. end
  11. 1 def content_type_path(content)
  12. send("admin_#{content_type}_path", content)
  13. end
  14. 1 def new_content_type_path
  15. send("new_admin_#{content_type}_path")
  16. end
  17. 1 def edit_content_type_path(content)
  18. send("edit_admin_#{content_type}_path", content)
  19. end
  20. 1 def unpublish_content_type_path(content)
  21. send("unpublish_admin_#{content_type}_path", content)
  22. end
  23. 1 def publish_content_type_path(content)
  24. send("publish_admin_#{content_type}_path", content)
  25. end
  26. # if content list comes from search or content
  27. 1 def search_context
  28. return true if params[:action] == 'search'
  29. end
  30. # create social share url
  31. 1 def make_social_url(_conent_type, content_slug)
  32. url_to_share = 'http://www.abraji.org.br/'
  33. return url_to_share + content_slug if _conent_type.empty?
  34. url_to_share + _conent_type + '/' + content_slug
  35. end
  36. 1 def card_css_class(content)
  37. content.image.present? ? ' card-image' : ' card-noimage'
  38. end
  39. 1 def exhibit_path(content)
  40. return unless content.try(:type)
  41. type = content.type.underscore
  42. type = 'course' if type.include?('course')
  43. send("exhibit_#{type}_path", content.slug)
  44. end
  45. end

app/helpers/helpdesks_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 module HelpdesksHelper
  2. end

app/helpers/homes_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 module HomesHelper
  2. end

app/helpers/pages_helper.rb

66.67% lines covered

3 relevant lines. 2 lines covered and 1 lines missed.
    
  1. 1 module PagesHelper
  2. 1 def hello_world(text)
  3. content_tag(:h1, text, class: 'alguma')
  4. end
  5. end

app/helpers/payment_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 module PaymentHelper
  2. end

app/helpers/projects_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 module ProjectsHelper
  2. end

app/helpers/sections_helper.rb

30.0% lines covered

10 relevant lines. 3 lines covered and 7 lines missed.
    
  1. 1 module SectionsHelper
  2. 1 def published?(section)
  3. section.published
  4. end
  5. 1 def card_columns(count)
  6. case count
  7. when 1
  8. 'col-sm-6'
  9. when 2
  10. 'col-sm-6'
  11. when 3
  12. 'col-sm-4'
  13. when 4
  14. 'col-sm-3'
  15. else
  16. 'col-sm-3'
  17. end
  18. end
  19. end

app/helpers/static_contents_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 module StaticContentsHelper
  2. end

app/helpers/transition_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 module TransitionHelper
  2. end

app/helpers/user_associate_controller_helper.rb

100.0% lines covered

1 relevant lines. 1 lines covered and 0 lines missed.
    
  1. 1 module UserAssociateControllerHelper
  2. end

app/inputs/cpf_input.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. class CpfInput < SimpleForm::Inputs::Base
  2. def input(wrapper_options)
  3. currency = options.delete(:currency) || default_currency
  4. merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
  5. content_tag(:div, input_group(currency, merged_input_options), class: 'input-group')
  6. end
  7. private
  8. def input_group(currency, merged_input_options)
  9. "#{currency_addon(currency)} #{@builder.text_field(attribute_name, merged_input_options)}".html_safe
  10. end
  11. def currency_addon(currency)
  12. content_tag(:span, currency, class: 'input-group-addon')
  13. end
  14. def default_currency
  15. '$'
  16. end
  17. end

app/inputs/currency_input.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. class CurrencyInput < SimpleForm::Inputs::Base
  2. def input(wrapper_options)
  3. currency = options.delete(:currency) || default_currency
  4. merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
  5. content_tag(:div, input_group(currency, merged_input_options), class: 'input-group')
  6. end
  7. private
  8. def input_group(currency, merged_input_options)
  9. "#{currency_addon(currency)} #{@builder.text_field(attribute_name, merged_input_options)}".html_safe
  10. end
  11. def currency_addon(currency)
  12. content_tag(:span, currency, class: 'input-group-addon')
  13. end
  14. def default_currency
  15. '$'
  16. end
  17. end

app/mailers/application_mailer.rb

0.0% lines covered

4 relevant lines. 0 lines covered and 4 lines missed.
    
  1. class ApplicationMailer < ActionMailer::Base
  2. default from: 'from@example.com'
  3. layout 'mailer'
  4. end

app/mailers/contact_mailer.rb

0.0% lines covered

10 relevant lines. 0 lines covered and 10 lines missed.
    
  1. class ContactMailer < ApplicationMailer
  2. def mail_message(contact)
  3. @contact = contact
  4. email_to = contact.subject_to_email_enum.find { |key, email| key == contact.subject }
  5. subject_selected = contact.subject_enum.find { |label, value| value == contact.subject }
  6. email_from = contact.email
  7. subject = "[Fale Conosco: abraji.org.br] " + subject_selected[0]
  8. mail to:email_to[1], :reply_to => email_from, subject: subject
  9. end
  10. end

app/mailers/cruza_grafos_mailer.rb

0.0% lines covered

47 relevant lines. 0 lines covered and 47 lines missed.
    
  1. class CruzaGrafosMailer < ApplicationMailer
  2. def moderate(user)
  3. @user = user
  4. mail to: (ENV['EMAIL_MODERACAO']+', '+ ENV['EMAIL_FINANCEIRO']), subject: "Novo pedido de inscrição no Cruza Grafos de #{@user.name}."
  5. end
  6. def wait_moderation(user)
  7. @user = user
  8. mail to: @user.email, subject: 'Pedido de inscrição no Cruza Grafos'
  9. end
  10. def approved(user)
  11. @user = user
  12. mail to: @user.email, subject: 'Sua inscrição no Cruza Grafos foi aprovada'
  13. end
  14. def reject(user)
  15. @user = user
  16. @motive = user.cruza_grafos_user.motive
  17. mail to: @user.email, subject: 'Sobre seu pedido de inscrição no Cruza Grafos à Abraji'
  18. end
  19. def paid(user)
  20. @user = user
  21. mail to: ENV['EMAIL_FINANCEIRO'], subject: "A inscrição no Cruza Grafos do #{@user.name} teve o pagamento aprovado."
  22. end
  23. def paidUser(user)
  24. @user = user
  25. mail to: @user.email, subject: "Seu pagamento da inscrição no Cruza Grafos da Abraji foi aprovado."
  26. end
  27. def will_expired(user, time)
  28. @user = user
  29. @time = time
  30. if time == 5 || time == 10 || time == 30
  31. subject = subject = 'Sua inscrição no Cruza Grafos irá expirar em '+time.to_s+' dias.'
  32. else
  33. subject = 'Sua inscrição no Cruza Grafos irá expirar.'
  34. end
  35. mail to: @user.email, subject: subject
  36. end
  37. def expired(user, time)
  38. @user = user
  39. @time = time
  40. if time == 5 || time == 10
  41. subject = 'Sua inscrição no Cruza Grafos expirou faz '+time.to_s+' dias.'
  42. else
  43. subject = 'Sua inscrição no Cruza Grafos expirou.'
  44. end
  45. mail to: @user.email, subject: subject
  46. end
  47. end

app/mailers/user_mailer.rb

0.0% lines covered

56 relevant lines. 0 lines covered and 56 lines missed.
    
  1. class UserMailer < ApplicationMailer
  2. def moderate(user)
  3. @user = user
  4. mail to: (ENV['EMAIL_MODERACAO']+', '+ ENV['EMAIL_FINANCEIRO']), subject: "Novo pedido de Moderação de #{@user.name}."
  5. end
  6. def paid(user)
  7. @user = user
  8. mail to: ENV['EMAIL_FINANCEIRO'], subject: "Associação do #{@user.name} teve o pagamento aprovado."
  9. end
  10. def paidUser(user)
  11. @user = user
  12. mail to: @user.email, subject: "Seu pagamento de Associação da Abraji foi aprovado."
  13. end
  14. def wait_moderation(user)
  15. @user = user
  16. mail to: @user.email, subject: 'Pedido de associação'
  17. end
  18. def approved(user)
  19. @user = user
  20. mail to: @user.email, subject: 'Sua associação à Abraji foi aprovada'
  21. end
  22. def reject(user)
  23. @user = user
  24. @motive = user.associate.motive
  25. mail to: @user.email, subject: 'Sobre seu pedido de associação à Abraji'
  26. end
  27. def welcome(user)
  28. @user = user
  29. mail to: @user.email, subject: "Bem vindo #{@user.name} à Abraji"
  30. end
  31. def associated(user)
  32. @user = user
  33. mail to: @user.email, subject: 'Cofirmação de associação da Abraji'
  34. end
  35. def will_expired(user, time, assocTypeChange = false)
  36. @user = user
  37. @time = time
  38. @assocTypeChange = assocTypeChange
  39. if time == 5 || time == 10 || time == 30
  40. subject = subject = 'Sua associação Abraji irá expirar em '+time.to_s+' dias.'
  41. else
  42. subject = 'Sua associação Abraji irá expirar.'
  43. end
  44. mail to: @user.email, subject: subject
  45. end
  46. def expired(user, time)
  47. @user = user
  48. @time = time
  49. if time == 5 || time == 10
  50. subject = 'Sua associação Abraji expirou faz '+time.to_s+' dias.'
  51. else
  52. subject = 'Sua associação Abraji expirou.'
  53. end
  54. mail to: @user.email, subject: subject
  55. end
  56. end

app/models/activity_report.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class ActivityReport < FileRecord
  2. def self.json_file_path
  3. 'institutional/transparence/relatorio_de_atividades.json'
  4. end
  5. end

app/models/admin.rb

53.85% lines covered

13 relevant lines. 7 lines covered and 6 lines missed.
    
  1. 1 class Admin < ApplicationRecord
  2. #include RailsAdmin::Admin
  3. # Include default devise modules. Others available are:
  4. # :confirmable, :lockable, :registerable, :timeoutable and :omniauthable
  5. 1 devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
  6. 1 validates :name, presence: true
  7. 1 validates :username, presence: true, uniqueness: { case_sensitive: false }
  8. 1 attr_writer :login
  9. 1 def login
  10. @login || username
  11. end
  12. 1 def self.find_for_database_authentication(warden_conditions)
  13. conditions = warden_conditions.dup
  14. return find_by(conditions.to_h) if conditions.key?(:username) || conditions.key?(:email)
  15. login = conditions.delete(:login)
  16. return unless login
  17. where(conditions.to_h).find_by(['lower(username) = :value OR lower(email) = :value', { value: login.downcase }])
  18. end
  19. end

app/models/application_record.rb

100.0% lines covered

2 relevant lines. 2 lines covered and 0 lines missed.
    
  1. 1 class ApplicationRecord < ActiveRecord::Base
  2. 1 self.abstract_class = true
  3. end

app/models/associate.rb

0.0% lines covered

170 relevant lines. 0 lines covered and 170 lines missed.
    
  1. class Associate < ApplicationRecord
  2. include AASM
  3. default_scope -> { order(accepted_terms_at: :desc) }
  4. before_save :remove_mask, :if => [:cpf, :phone]
  5. before_validation :remove_mask , :if => [:cpf]
  6. has_many :payments, as: :payable, dependent: :destroy
  7. PAYMENT_TYPES = %w[pending professional_unique professional_parcel student_unique student_parcel].freeze
  8. belongs_to :user, dependent: :destroy
  9. belongs_to :association_type
  10. FILTER_DATE_SCOPES = %i[valid_until].freeze
  11. FILTER_VALUE_SCOPES = %i[cpf association_state association_type_id].freeze
  12. include Concerns::Filterable
  13. COLOR_OR_RACE_ENUM = {
  14. 'Branca' => 'white',
  15. 'Parda' => 'parda',
  16. 'Preta' => 'black',
  17. 'Amarela' => 'yellow',
  18. 'Indígena' => 'indigenous'
  19. }.freeze
  20. def color_or_race_list
  21. COLOR_OR_RACE_ENUM
  22. end
  23. GENDER_ENUM = {
  24. 'Feminino' => 'female',
  25. 'Masculino' => 'male',
  26. 'Não-binário' => 'non-binary',
  27. 'Transgênero' => 'transgender'
  28. }.freeze
  29. def gender_list
  30. GENDER_ENUM
  31. end
  32. mount_uploader :details_file, FileUploader
  33. validates :phone, :country, :cpf, :state, :city, :zipcode, :address_street, :neighborhood, :address_number,
  34. :activity_description, :accepted_terms, :code_of_ethics_terms, :details_file, :association_type, :color_or_race, presence: true
  35. validates_cpf_format_of :cpf, if: -> {self.country == "BR"}
  36. validates_uniqueness_of :cpf, message: "O CPF já foi cadastrado!"
  37. validates :payment_type, inclusion: { in: PAYMENT_TYPES }
  38. aasm column: 'association_state' do
  39. state :nil, initial: true #estado inicial da criação
  40. state :new_associate, after_enter: :send_moderator_email #Estado inicial do associado (pendente de moderação)
  41. state :approved, after_enter: :approved_actions #Associado moderado e aprovado (pendente de pagamento)
  42. state :awaiting_payment, after_enter: :awaiting_payment_actions #Associado inicia o pagamento (pendente aprovação do pagamento)
  43. state :running, after_enter: :running_actions #Associado pagou (pendente chegar na data de expiração)
  44. state :rejected, after_enter: :send_reject_email #Associado moderado e rejeitado
  45. state :expired, after_enter: :expired_actions
  46. event :start do
  47. transitions from: [:nil], to: :new_associate
  48. end
  49. event :approve do
  50. transitions from: [:new_associate, :rejected], to: :approved
  51. end
  52. event :reject do
  53. transitions from: %i[new_associate approved running], to: :rejected
  54. end
  55. event :pay do
  56. transitions from: [:approved, :expired], to: :awaiting_payment
  57. end
  58. event :not_paid do
  59. transitions from: [:awaiting_payment], to: :approved
  60. end
  61. event :paid do
  62. transitions from: [:awaiting_payment, :expired, :running], to: :running
  63. end
  64. event :expire do
  65. transitions from: [:running], to: :expired
  66. end
  67. event :manual_paid do
  68. transitions from: %i[nil new_associate awaiting_payment approved running rejected expired], to: :running
  69. end
  70. end
  71. def send_moderator_email
  72. begin
  73. # Send to moderator
  74. UserMailer.moderate(user).deliver
  75. # Send to user
  76. UserMailer.wait_moderation(user).deliver
  77. rescue => e
  78. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  79. end
  80. end
  81. def approved_actions
  82. # grava data da moderação
  83. self.moderate_date = Time.now
  84. self.save
  85. create_association_payment
  86. # enviar email
  87. send_approved_email
  88. end
  89. def create_association_payment
  90. # criar pagamento
  91. payment = Payment.new
  92. payment.user = self.user
  93. payment.payable = self
  94. payment.name = 'new_association '+self.association_type.description
  95. payment.price_cents = self.association_type.annuity_cents
  96. payment.price_currency = self.association_type.annuity_currency
  97. payment.payable_type = "Associate"# can only be Associate or Course for the polymorph
  98. # raise payment.errors.inspect unless payment.valid?
  99. payment.save
  100. end
  101. def send_approved_email
  102. begin
  103. UserMailer.approved(user).deliver
  104. rescue => e
  105. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  106. end
  107. end
  108. def awaiting_payment_actions; end
  109. def running_actions; end
  110. def send_reject_email
  111. self.moderate_date = Time.now
  112. self.save
  113. begin
  114. UserMailer.reject(user).deliver
  115. rescue => e
  116. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  117. end
  118. end
  119. def expired_actions
  120. if !self.save
  121. Rails.logger.error 'Problema ao expirar associção. Error message: ' + self.errors.messages.to_s
  122. Rails.logger.error 'Expiração forçada'
  123. self.save(validate: false)
  124. end
  125. send_expired_email(0)
  126. end
  127. def will_expired_actions
  128. if self.association_type.description == "Estudante de graduação" && Date.today > self.conclusion_date
  129. self.association_type = AssociationType.find_by(description: "Profissional e/ou estudante de pós-graduação")
  130. if !self.save
  131. Rails.logger.error 'Problema ao mudar tipo de associção. Error message: ' + self.errors.messages.to_s
  132. Rails.logger.error 'Expiração forçada'
  133. self.save(validate: false)
  134. end
  135. create_association_payment
  136. send_will_expired_email(30, true)
  137. else
  138. create_association_payment
  139. send_will_expired_email(30)
  140. end
  141. end
  142. def send_will_expired_email(days, assocTypeChange = false)
  143. begin
  144. UserMailer.will_expired(user, days, assocTypeChange).deliver
  145. rescue => e
  146. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  147. end
  148. end
  149. def send_expired_email(days)
  150. begin
  151. UserMailer.expired(user, days).deliver
  152. rescue => e
  153. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  154. end
  155. end
  156. def isAssociationValid
  157. end
  158. def remove_mask
  159. self.cpf = self.cpf.gsub(/[^a-zA-Z0-9]/, '')
  160. self.phone = self.phone.gsub(/[^0-9]/, '')
  161. end
  162. def valid_for_covid_voucher
  163. if Date.today.year == 2020
  164. # if self.user.email.include?("covid") && Date.today.year == 2020
  165. if Payment.where(payable: self, status: 'paid', created_at: Date.new(2019, 1, 1).beginning_of_year..Date.new(2019, 1, 1).end_of_year).empty?
  166. return false
  167. else
  168. return true
  169. end
  170. else
  171. return false
  172. end
  173. end
  174. def covid_voucher_active
  175. Payment.find_by(payable: self, payable_type: "Associate", name:'association covid voucher')
  176. end
  177. end

app/models/association_type.rb

0.0% lines covered

3 relevant lines. 0 lines covered and 3 lines missed.
    
  1. class AssociationType < ApplicationRecord
  2. has_one :associate
  3. end

app/models/audit_report.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class AuditReport < FileRecord
  2. def self.json_file_path
  3. 'institutional/transparence/relatorio_de_auditorias.json'
  4. end
  5. end

app/models/ckeditor/asset.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class Ckeditor::Asset < ApplicationRecord
  2. include Ckeditor::Orm::ActiveRecord::AssetBase
  3. delegate :url, :current_path, :content_type, to: :data
  4. validates :data, presence: true
  5. end

app/models/ckeditor/attachment_file.rb

0.0% lines covered

6 relevant lines. 0 lines covered and 6 lines missed.
    
  1. class Ckeditor::AttachmentFile < Ckeditor::Asset
  2. mount_uploader :data, CkeditorAttachmentFileUploader, mount_on: :data_file_name
  3. def url_thumb
  4. @url_thumb ||= Ckeditor::Utils.filethumb(filename)
  5. end
  6. end

app/models/ckeditor/picture.rb

0.0% lines covered

6 relevant lines. 0 lines covered and 6 lines missed.
    
  1. class Ckeditor::Picture < Ckeditor::Asset
  2. mount_uploader :data, CkeditorPictureUploader, mount_on: :data_file_name
  3. def url_content
  4. url(:content)
  5. end
  6. end

app/models/classroom_course.rb

0.0% lines covered

12 relevant lines. 0 lines covered and 12 lines missed.
    
  1. class ClassroomCourse < Content
  2. include RailsAdmin::ClassroomCourse
  3. accepts_nested_attributes_for :classroom_course_info, allow_destroy: true
  4. delegate :registration_phase, :duration, :number_of_students, :details_file,
  5. :highlighted, :address, :date, :price, :contact_phone_number,
  6. :contact_email, to: :classroom_course_info, allow_nil: true
  7. validates :classroom_course_info, presence: true
  8. attr_accessor :details_file_cachess
  9. def self.section_contents(section)
  10. section.contents.where(type: 'ClassroomCourse').limit(1)
  11. end
  12. end

app/models/classroom_course_info.rb

0.0% lines covered

25 relevant lines. 0 lines covered and 25 lines missed.
    
  1. class ClassroomCourseInfo < ApplicationRecord
  2. include RailsAdmin::ClassroomCourseInfo
  3. belongs_to :content, inverse_of: :classroom_course_info
  4. mount_uploader :details_file, FileUploader
  5. after_initialize :init
  6. def init
  7. self.contact_email ||= 'cursos@abraji.org.br'
  8. self.contact_phone_number ||= '+55 11 3159-0344'
  9. end
  10. REGISTRATION_PHASE_ENUM = {
  11. 'Pré-Inscrição' => 'pre-register',
  12. 'Inscrições Abertas' => 'open',
  13. 'Encerrado' => 'closed'
  14. }.freeze
  15. def registration_phase_enum
  16. REGISTRATION_PHASE_ENUM
  17. end
  18. def title
  19. 'editar dados do curso'
  20. end
  21. validates :contact_email, presence: true
  22. validates :contact_phone_number, presence: true
  23. validates :duration, presence: true
  24. validates :number_of_students, presence: true
  25. end

app/models/concerns/filterable.rb

54.55% lines covered

33 relevant lines. 18 lines covered and 15 lines missed.
    
  1. 1 module Concerns::Filterable
  2. 1 extend ActiveSupport::Concern
  3. 1 def self.included(base)
  4. 1 base.scope :filter_by_field_start, ->(field, start_time) { where("#{field} >= ?", start_time) }
  5. 1 base.scope :filter_by_field_end, ->(field, end_time) { where("#{field} <= ?", end_time) }
  6. 1 base.scope :filter_by_field_likeness, ->(field, text) { where("#{field} ilike ?", "%#{text}%") }
  7. 1 base.scope :filter_by_field_truthness, ->(field) { where(field => true) }
  8. 1 base.scope :filter_by_field_value, ->(field, value) { where(field => value) }
  9. 1 if defined?(base::FILTER_DATE_SCOPES)
  10. 1 base::FILTER_DATE_SCOPES.to_a.each do |field|
  11. 2 base.scope :"filter_by_#{field}_start", ->(start_time) { filter_by_field_start(field, start_time) }
  12. 2 base.scope :"filter_by_#{field}_end", ->(end_time) { filter_by_field_end(field, end_time) }
  13. end
  14. end
  15. 1 if defined?(base::FILTER_TEXT_SCOPES)
  16. 1 base::FILTER_TEXT_SCOPES.to_a.each do |field|
  17. 4 base.scope :"filter_by_#{field}_likeness", ->(text) { filter_by_field_likeness(field, text) }
  18. end
  19. end
  20. 1 if defined?(base::FILTER_TRUTHY_SCOPES)
  21. base::FILTER_TRUTHY_SCOPES.to_a.each do |field|
  22. base.scope :"filter_by_#{field}_truthness", -> () { filter_by_field_truthness(field) }
  23. end
  24. end
  25. 1 if defined?(base::FILTER_VALUE_SCOPES)
  26. base::FILTER_VALUE_SCOPES.to_a.each do |field|
  27. base.scope :"filter_by_#{field}_value", ->(value) { filter_by_field_value(field, value) }
  28. end
  29. end
  30. 1 base.scope :filter_by, ->(params) {
  31. result = where(nil)
  32. filter_scopes = []
  33. filter_scopes += base::FILTER_DATE_SCOPES.collect { |x| (x.to_s + '_start').to_sym } if defined?(base::FILTER_DATE_SCOPES)
  34. filter_scopes += base::FILTER_DATE_SCOPES.collect { |x| (x.to_s + '_end').to_sym } if defined?(base::FILTER_DATE_SCOPES)
  35. filter_scopes += base::FILTER_TEXT_SCOPES.collect { |x| (x.to_s + '_likeness').to_sym } if defined?(base::FILTER_TEXT_SCOPES)
  36. filter_scopes += base::FILTER_TRUTHY_SCOPES.collect { |x| (x.to_s + '_truthness').to_sym } if defined?(base::FILTER_TRUTHY_SCOPES)
  37. filter_scopes += base::FILTER_VALUE_SCOPES.collect { |x| (x.to_s + '_value').to_sym } if defined?(base::FILTER_VALUE_SCOPES)
  38. params.each do |filter_name, filter_value|
  39. next if !filter_scopes.include?(filter_name.to_sym) || filter_value.blank?
  40. result = result.send("filter_by_#{filter_name}", filter_value)
  41. end
  42. result
  43. }
  44. end
  45. end

app/models/concerns/publishable.rb

0.0% lines covered

18 relevant lines. 0 lines covered and 18 lines missed.
    
  1. module Concerns::Publishable
  2. extend ActiveSupport::Concern
  3. included do
  4. scope :published, ->(admin) { admin ? where(nil) : where("(published = true AND publish_date < ?) OR (published = true AND publish_date IS NULL)", Time.now) }
  5. end
  6. def publish
  7. update published: true
  8. end
  9. def unpublish
  10. update published: false
  11. end
  12. def slug_value
  13. respond_to?(:title) ? title : name
  14. end
  15. def slug_value_changed?
  16. respond_to?(:title) ? title_changed? : name_changed?
  17. end
  18. end

app/models/concerns/publishable_sections.rb

66.67% lines covered

12 relevant lines. 8 lines covered and 4 lines missed.
    
  1. 1 module Concerns::PublishableSections
  2. 1 extend ActiveSupport::Concern
  3. 1 included do
  4. 1 scope :published, ->(admin) { admin ? where(nil) : where('published = true') }
  5. end
  6. 1 def publish
  7. update published: true
  8. end
  9. 1 def unpublish
  10. update published: false
  11. end
  12. 1 def slug_value
  13. respond_to?(:title) ? title : name
  14. end
  15. 1 def slug_value_changed?
  16. respond_to?(:title) ? title_changed? : name_changed?
  17. end
  18. end

app/models/congress.rb

0.0% lines covered

14 relevant lines. 0 lines covered and 14 lines missed.
    
  1. class Congress < Content
  2. include RailsAdmin::Congress
  3. accepts_nested_attributes_for :congress_info, allow_destroy: true
  4. delegate :videos, :link, to: :congress_info, allow_nil: true
  5. def self.filters
  6. [['Todos os congressos', 'all']] + super()
  7. end
  8. def self.croped_image_size
  9. { 'width': 674, 'height': 282 }
  10. end
  11. def self.section_contents(section)
  12. section.contents.where(type: 'Congress').limit(4)
  13. end
  14. end

app/models/congress_info.rb

0.0% lines covered

14 relevant lines. 0 lines covered and 14 lines missed.
    
  1. class CongressInfo < ApplicationRecord
  2. include RailsAdmin::CongressInfo
  3. belongs_to :content, inverse_of: :congress_info
  4. validates :content, presence: true
  5. def title
  6. 'editar dados do congresso'
  7. end
  8. def videos_s=(string)
  9. self.videos = string.split(',')
  10. end
  11. def videos_s
  12. videos.join(',')
  13. end
  14. end

app/models/contact.rb

0.0% lines covered

18 relevant lines. 0 lines covered and 18 lines missed.
    
  1. class Contact
  2. include ActiveModel::Model
  3. attr_accessor :name
  4. attr_accessor :email
  5. attr_accessor :phone
  6. attr_accessor :message
  7. attr_accessor :subject
  8. validates :name, :email, :phone, :message, :subject, presence: true
  9. validates :email, format: { with: URI::MailTo::EMAIL_REGEXP }
  10. SUBJECT_LIST = [['Tornar-se associado','tornar-se-associado'],['Regularizar minha associação','regularizar-minha-associacao'],['Fazer uma doação','fazer-uma-doacao'],['Informações sobre cursos','informacoes-sobre-cursos'],['Informações sobre o Congresso','informacoes-sobre-o-congresso'],['Pedidos de informação e entrevistas','pedidos-de-informacao-e-entrevista'],['Outro','outro']].freeze
  11. SUBJECT_TO_EMAIL_LIST = [['tornar-se-associado','abraji@abraji.org.br'],['regularizar-minha-associacao','financeiro@abraji.org.br'],['fazer-uma-doacao','financeiro@abraji.org.br'],['informacoes-sobre-cursos','cursos@abraji.org.br'],['informacoes-sobre-o-congresso','contato@abraji.org.br'],['pedidos-de-informacao-e-entrevista','abraji@abraji.org.br'],['outro','abraji@abraji.org.br']].freeze
  12. def subject_enum
  13. SUBJECT_LIST
  14. end
  15. def subject_to_email_enum
  16. SUBJECT_TO_EMAIL_LIST
  17. end
  18. end

app/models/content.rb

0.0% lines covered

58 relevant lines. 0 lines covered and 58 lines missed.
    
  1. class Content < ApplicationRecord
  2. default_scope -> { order(created_at: :desc) }
  3. include Sluggi::Slugged
  4. include Concerns::Publishable
  5. include PgSearch
  6. mount_base64_uploader :image, ImageUploader, file_name: ->(c) {
  7. return Random.rand(100...999_999) if c.title.blank?
  8. c.title.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '')+Time.now.nsec.to_s
  9. }
  10. validates :title, presence: true, uniqueness: { case_sensitive: false, scope: :type }
  11. validates :slug, presence: true, uniqueness: { case_sensitive: false, scope: :type }
  12. validates :content, presence: true
  13. before_save :set_summary_fields
  14. has_and_belongs_to_many :sections, inverse_of: :contents
  15. has_one :classroom_course_info, dependent: :destroy, inverse_of: :content
  16. has_one :congress_info, dependent: :destroy, inverse_of: :content
  17. has_one :online_course_info, dependent: :destroy, inverse_of: :content
  18. has_one :helpdesk_info, dependent: :destroy, inverse_of: :content
  19. has_one :news_info, dependent: :destroy, inverse_of: :content
  20. has_one :project_info, dependent: :destroy, inverse_of: :content
  21. has_one :publication_info, dependent: :destroy, inverse_of: :content
  22. has_many :payments, as: :payable, dependent: :destroy
  23. def self.filters
  24. Section.all.map { |section| [section.name, section.slug] }
  25. end
  26. # section filter
  27. def self.published_and_filtered(admin, filter)
  28. all_contents = published(admin)
  29. if Section.where(slug: filter).exists?
  30. section = Section.find_by(slug: filter)
  31. return all_contents & section.contents
  32. end
  33. all_contents
  34. end
  35. # each letter represents a weight while searching
  36. pg_search_scope :any_word_search, against: {
  37. title: 'A', title_summary: 'B', content: 'C'
  38. }, using: { tsearch: { prefix: true, any_word: true } }
  39. pg_search_scope :exact_search, against: {
  40. title: 'A', title_summary: 'B', content: 'C'
  41. }, using: { tsearch: { prefix: true, any_word: false } }
  42. def self.fulltext_search(text)
  43. return all if text.blank?
  44. ['"', "'"].any? { |quotation| text.include?(quotation) } ? exact_search(text) : any_word_search(text)
  45. end
  46. def extra_info?
  47. send("#{type.underscore}_info").present?
  48. end
  49. def css_class
  50. return '' if sections.blank?
  51. sections.length > 1 ? 'noclass' : sections.first.css_class
  52. end
  53. def set_summary_fields
  54. self.title_summary = title if title_summary.blank?
  55. self.content_summary = content if content_summary.blank?
  56. end
  57. def self.croped_image_size
  58. { 'width': 674, 'height': 282 }
  59. end
  60. end

app/models/course.rb

0.0% lines covered

47 relevant lines. 0 lines covered and 47 lines missed.
    
  1. class Course
  2. def self.published(admin)
  3. online_courses = OnlineCourse.published(admin)
  4. classroom_courses = ClassroomCourse.published(admin)
  5. classroom_highlighted = sort_courses(classroom_courses.select(&:highlighted))
  6. online_open_inscription = filter_course_phase(online_courses, 'open')
  7. online_pre_inscription = filter_course_phase(online_courses, 'pre-register')
  8. online_close_inscription = filter_course_phase(online_courses, 'closed')
  9. classroom_unhighlighted = sort_courses(classroom_courses.reject(&:highlighted))
  10. classroom_highlighted + online_open_inscription + online_pre_inscription +
  11. online_close_inscription + classroom_unhighlighted
  12. end
  13. def self.sort_courses(courses)
  14. courses.sort_by { |h| h[:created_at] }.reverse
  15. end
  16. def self.filter_course_phase(courses, phase)
  17. sort_courses(courses.select { |course| course.registration_phase == phase })
  18. end
  19. def self.filters
  20. {
  21. 'Todos os cursos' => 'all',
  22. 'Cursos presenciais' => 'classroom',
  23. 'Cursos On-Line' => 'online',
  24. 'Cursos On-Line - Inscrições Abertas' => 'online_open_inscription',
  25. 'Cursos On-Line - Pré Incrição' => 'online_pre_inscription',
  26. 'Cursos On-Line - Inscrições Encerradas' => 'online_close_inscription'
  27. }
  28. end
  29. def self.published_and_filtered(admin, filter)
  30. all_courses = published(admin)
  31. return all_courses unless %w[
  32. classroom online online_open_inscription online_pre_inscription online_close_inscription
  33. ].include?(filter)
  34. return all_courses.select { |course| course.is_a?(ClassroomCourse) } if filter == 'classroom'
  35. online_courses = all_courses.select { |course| course.is_a?(OnlineCourse) }
  36. case filter
  37. when 'online_open_inscription'
  38. online_courses.select { |course| course.registration_phase == 'open' }
  39. when 'online_pre_inscription'
  40. online_courses.select { |course| course.registration_phase == 'pre-register' }
  41. when 'online_close_inscription'
  42. online_courses.select { |course| course.registration_phase == 'closed' }
  43. else
  44. online_courses
  45. end
  46. end
  47. end

app/models/cruza_grafos_type.rb

0.0% lines covered

3 relevant lines. 0 lines covered and 3 lines missed.
    
  1. class CruzaGrafosType < ApplicationRecord
  2. has_one :cruza_grafos_user
  3. end

app/models/cruza_grafos_user.rb

0.0% lines covered

141 relevant lines. 0 lines covered and 141 lines missed.
    
  1. class CruzaGrafosUser < ApplicationRecord
  2. include AASM
  3. belongs_to :user
  4. belongs_to :cruza_grafos_type, optional: true
  5. has_many :payments, as: :payable, dependent: :destroy
  6. mount_uploader :details_file, FileUploader
  7. validates :company, :professional_attachment, :how_did_you_know, :why_interested, :cpf_cnpj,
  8. :work_company_link, :social_media_link, :terms_of_use, :privacy_policy, presence: true
  9. before_save :remove_mask, :if => [:cpf_cnpj]
  10. before_validation :remove_mask , :if => [:cpf_cnpj]
  11. validates_uniqueness_of :cpf_cnpj
  12. validate :cpf_cnpf_presence_validation
  13. def cpf_cnpf_presence_validation
  14. if !CPF.valid?(cpf_cnpj) && !CNPJ.valid?(cpf_cnpj)
  15. errors.add(:cpf_cnpj, "cpf/cnpj inválidos")
  16. end
  17. end
  18. def remove_mask
  19. self.cpf_cnpj = self.cpf_cnpj.gsub(/[^a-zA-Z0-9]/, '')
  20. end
  21. def create_cruza_grafo_payment cg_type
  22. # criar pagamento
  23. payment = Payment.new
  24. payment.user = self.user
  25. payment.payable = self
  26. payment.name = 'Cruza Grafos - ' + cg_type.description
  27. payment.price_cents = cg_type.price_cents
  28. payment.price_currency = cg_type.price_currency
  29. payment.payable_type = "CruzaGrafosUser"# can only be Associate or Course for the polymorph
  30. # raise payment.errors.inspect unless payment.valid?
  31. payment.save
  32. end
  33. def useTrial
  34. return if self.used_trial
  35. self.used_trial = true
  36. self.in_trial = true
  37. self.valid_until = Date.today + 30.days
  38. if !self.save
  39. puts self.errors.message
  40. end
  41. end
  42. def expireTrial
  43. return unless self.in_trial
  44. self.used_trial = true
  45. self.in_trial = false
  46. self.valid_until = Date.today
  47. if !self.save
  48. puts self.errors.message
  49. end
  50. end
  51. aasm column: 'user_state' do
  52. state :nil, initial: true #estado inicial da criação
  53. state :waiting_moderation, after_enter: :waiting_moderation_actions #assim que concluido o cadastro, ja vai pra moderação
  54. state :waiting_pay_user, after_enter: :waiting_pay_user_actions #depois de moderado fica a espera do pagamento
  55. state :waiting_pay_confirm, after_enter: :waiting_pay_confirm_actions # apos pagamento espera confirmação do pagamento
  56. state :running, after_enter: :running_actions #pagamento confirmado começa a contar o serviço
  57. state :rejected_moderation, after_enter: :reject_moderation_actions #se a moderação for negada
  58. state :rejected_payment, after_enter: :reject_payment_actions #se a moderação for negada
  59. state :expired, after_enter: :expired_actions # quando o tempo pago expira
  60. event :start do # assim que o usuario completa o cadastro ele ja vai para moderação
  61. transitions from: [:nil, :rejected_moderation], to: :waiting_moderation
  62. end
  63. event :approve_moderation do # a moderação foi aprovada - agora falta o usuario pagar
  64. transitions from: [:waiting_moderation, :rejected_payment], to: :waiting_pay_user
  65. end
  66. event :reject_moderation do # moderação rejeiada
  67. transitions from: %i[waiting_moderation], to: :rejected_moderation
  68. end
  69. event :user_paid do # o usuario pagou e vai ter que esperar confirmação
  70. transitions from: [:waiting_pay_user], to: :waiting_pay_confirm
  71. end
  72. event :payment_confirm do # pagamento confirmado
  73. transitions from: [:waiting_pay_confirm, :expired], to: :running
  74. end
  75. event :payment_reject do # pagamento rejeitado
  76. transitions from: [:waiting_pay_confirm], to: :rejected_payment
  77. end
  78. event :not_paid do
  79. transitions from: [:running], to: :waiting_pay_user
  80. end
  81. event :expire do # serviço expirado
  82. transitions from: [:running], to: :expired
  83. end
  84. event :manual_paid do
  85. transitions from: %i[nil waiting_moderation waiting_pay_user waiting_pay_confirm running expired], to: :running
  86. end
  87. end
  88. def waiting_moderation_actions
  89. begin
  90. # Send to moderator
  91. CruzaGrafosMailer.moderate(user).deliver
  92. # Send to user
  93. CruzaGrafosMailer.wait_moderation(user).deliver
  94. rescue => e
  95. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  96. end
  97. end
  98. def waiting_pay_user_actions
  99. useTrial
  100. # grava data da moderação
  101. self.moderate_date = Time.now
  102. self.save
  103. add_cg_payment
  104. # enviar email
  105. begin
  106. CruzaGrafosMailer.approved(user).deliver
  107. rescue => e
  108. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  109. end
  110. end
  111. def waiting_pay_confirm_actions; end
  112. def running_actions
  113. # para casos de pagamento manual faz o check de expiração do trial
  114. expireTrial
  115. self.approval_payment_date = Time.now
  116. #TODO enviar email??
  117. end
  118. def reject_moderation_actions
  119. self.moderate_date = Time.now
  120. self.save
  121. begin
  122. CruzaGrafosMailer.reject(user).deliver
  123. rescue => e
  124. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  125. end
  126. end
  127. def rejected_payment_actions; end
  128. def expired_actions
  129. if !self.save
  130. Rails.logger.error 'Problema ao expirar inscrição Cruza Grafo. Error message: ' + self.errors.messages.to_s
  131. Rails.logger.error 'Expiração forçada'
  132. self.save(validate: false)
  133. else
  134. add_cg_payment
  135. begin
  136. CruzaGrafosMailer.expired(user, 0).deliver
  137. rescue => e
  138. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  139. end
  140. end
  141. end
  142. def add_cg_payment
  143. #expira qualquer pagamento antigo de CG
  144. Payment.where(user_id: self.user.id, payable_type: "CruzaGrafosUser").update_all( status: "expired")
  145. # cria um pagamento inicial qualquer
  146. cg_type = CruzaGrafosType.first
  147. self.cruza_grafos_type = cg_type
  148. self.save
  149. self.create_cruza_grafo_payment cg_type
  150. end
  151. end

app/models/curator.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class Curator < Person
  2. def self.json_file_path
  3. 'institutional/conselho_curador.json'
  4. end
  5. end

app/models/deponent.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class Deponent < Person
  2. def self.json_file_path
  3. 'institutional/fund/depoimentos.json'
  4. end
  5. end

app/models/director.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class Director < Person
  2. def self.json_file_path
  3. 'institutional/diretoria.json'
  4. end
  5. end

app/models/file_record.rb

0.0% lines covered

3 relevant lines. 0 lines covered and 3 lines missed.
    
  1. class FileRecord < JsonModel
  2. attr_accessor :name, :url, :active
  3. end

app/models/helpdesk.rb

0.0% lines covered

12 relevant lines. 0 lines covered and 12 lines missed.
    
  1. class Helpdesk < Content
  2. include RailsAdmin::Helpdesk
  3. accepts_nested_attributes_for :helpdesk_info, allow_destroy: true
  4. delegate :note, :details_file, to: :helpdesk_info, allow_nil: true
  5. attr_accessor :details_file_cache
  6. def self.filters
  7. [['Todos os Helpsesks', 'all']] + super()
  8. end
  9. def self.section_contents(section)
  10. section.contents.where(type: 'Helpdesk').limit(4)
  11. end
  12. end

app/models/helpdesk_info.rb

0.0% lines covered

9 relevant lines. 0 lines covered and 9 lines missed.
    
  1. class HelpdeskInfo < ApplicationRecord
  2. include RailsAdmin::HelpdeskInfo
  3. belongs_to :content, inverse_of: :helpdesk_info
  4. mount_uploader :details_file, FileUploader
  5. validates :content, presence: true
  6. def title
  7. 'editar dados do helpdesk'
  8. end
  9. end

app/models/home.rb

0.0% lines covered

10 relevant lines. 0 lines covered and 10 lines missed.
    
  1. class Home < ApplicationRecord
  2. include Sluggi::Slugged
  3. include Concerns::Publishable
  4. has_one :home_primary_section, class_name: 'HomePrimarySection', inverse_of: :home, dependent: :destroy
  5. has_many :home_secondary_sections, class_name: 'HomeSecondarySection', inverse_of: :home, dependent: :destroy
  6. accepts_nested_attributes_for :home_primary_section
  7. accepts_nested_attributes_for :home_secondary_sections
  8. mount_base64_uploader :top_banner, ImageUploader, file_name: ->(hc) { hc.title.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '')+Time.now.nsec.to_s }
  9. validates :title, :home_primary_section, :home_secondary_sections, presence: true
  10. end

app/models/home_content.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. class HomeContent < ApplicationRecord
  2. default_scope -> { order(created_at: :asc) }
  3. belongs_to :home_section, inverse_of: :home_contents
  4. belongs_to :section, optional: true
  5. mount_base64_uploader :image, ImageUploader, file_name: ->(hc) { hc.title.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '')+Time.now.nsec.to_s }
  6. validates :title, :url, :description, presence: true
  7. end

app/models/home_primary_section.rb

100.0% lines covered

3 relevant lines. 3 lines covered and 0 lines missed.
    
  1. 1 class HomePrimarySection < HomeSection
  2. 1 belongs_to :home, inverse_of: :home_primary_section
  3. 1 accepts_nested_attributes_for :home_contents
  4. end

app/models/home_secondary_section.rb

100.0% lines covered

4 relevant lines. 4 lines covered and 0 lines missed.
    
  1. 1 class HomeSecondarySection < HomeSection
  2. 1 belongs_to :home, inverse_of: :home_secondary_sections
  3. 1 accepts_nested_attributes_for :home_contents
  4. 1 validates :section, presence: true
  5. end

app/models/home_section.rb

100.0% lines covered

6 relevant lines. 6 lines covered and 0 lines missed.
    
  1. 1 class HomeSection < ApplicationRecord
  2. 1 default_scope -> { order(created_at: :asc) }
  3. 1 belongs_to :home
  4. 1 belongs_to :section, optional: true
  5. 1 has_many :home_contents, inverse_of: :home_section, dependent: :destroy
  6. 1 accepts_nested_attributes_for :home_contents
  7. end

app/models/institucional_person.rb

0.0% lines covered

7 relevant lines. 0 lines covered and 7 lines missed.
    
  1. class InstitucionalPerson < ApplicationRecord
  2. include Concerns::Publishable
  3. self.table_name = "institucional_persons"
  4. mount_base64_uploader :photo, ImageUploader, file_name: ->(hc) { hc.name.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '')+Time.now.nsec.to_s }
  5. belongs_to :institucional_persons_group, inverse_of: :institucional_persons
  6. validates :name, :description, :photo, :institucional_persons_group_id, presence: true
  7. end

app/models/institucional_persons_group.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class InstitucionalPersonsGroup < ApplicationRecord
  2. self.table_name = "institucional_persons_groups"
  3. has_many :institucional_persons, inverse_of: :institucional_persons_group
  4. validates :name, presence: true
  5. end

app/models/json_model.rb

0.0% lines covered

12 relevant lines. 0 lines covered and 12 lines missed.
    
  1. class JsonModel
  2. include ActiveModel::Model
  3. def self.all
  4. load_data(json_file_path).map { |attrs| new(attrs) }
  5. end
  6. def self.load_data(relative_path)
  7. JSON.parse File.read("app/assets/data/#{relative_path}")
  8. end
  9. def self.json_file_path
  10. raise NotImplementedError
  11. end
  12. end

app/models/main_menu_option.rb

0.0% lines covered

6 relevant lines. 0 lines covered and 6 lines missed.
    
  1. class MainMenuOption < JsonModel
  2. attr_accessor :session, :slug, :active, :subsessions
  3. def self.json_file_path
  4. 'main_menu.json'
  5. end
  6. end

app/models/news.rb

0.0% lines covered

22 relevant lines. 0 lines covered and 22 lines missed.
    
  1. class News < Content
  2. include RailsAdmin::News
  3. accepts_nested_attributes_for :news_info, allow_destroy: true
  4. delegate :author, :published_at, to: :news_info, allow_nil: true
  5. validates :news_info, presence: true
  6. def self.filters
  7. [['Todos as Notícias', 'all']] + super() + [
  8. %w[Clipping clipping], ['Notas Abraji', 'abraji-notes'], %w[Congresso congress]
  9. ]
  10. end
  11. # def self.croped_image_size
  12. # { 'width': 218, 'height': 218 }
  13. # end
  14. def self.published_and_filtered(admin, filter)
  15. return published_by_tags(admin, filter) if published_by_tags(admin, filter).exists?
  16. super(admin, filter)
  17. end
  18. def self.published_by_tags(admin, filter)
  19. return where(id: nil) if filter.blank?
  20. joins(:news_info).where("news_infos.tags @> '{#{filter}}'").published(admin)
  21. end
  22. def self.section_contents(section)
  23. section.contents.where(type: 'News').limit(4)
  24. end
  25. end

app/models/news_info.rb

0.0% lines covered

18 relevant lines. 0 lines covered and 18 lines missed.
    
  1. class NewsInfo < ApplicationRecord
  2. include RailsAdmin::NewsInfo
  3. belongs_to :content, inverse_of: :news_info
  4. TAGS_ENUM = {
  5. 'Clipping' => 'clipping',
  6. 'Congresso' => 'congress',
  7. 'Notas da Abraji' => 'abraji-notes'
  8. }.freeze
  9. def tags_enum
  10. TAGS_ENUM
  11. end
  12. validates :content, presence: true
  13. validates :author, presence: true
  14. validates :published_at, presence: true
  15. def title
  16. 'editar dados da notícia'
  17. end
  18. end

app/models/online_course.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. class OnlineCourse < Content
  2. include RailsAdmin::OnlineCourse
  3. accepts_nested_attributes_for :online_course_info, allow_destroy: true
  4. delegate :registration_phase, :duration, :start_date, :number_of_students,
  5. :non_associate_price, :associate_price, :registration_url, :price,
  6. to: :online_course_info, allow_nil: true
  7. validates :online_course_info, presence: true
  8. def self.section_contents(section)
  9. @onlinecourse = section.contents.joins(:online_course_info)
  10. .where(%q("online_course_infos"."registration_phase" = 'pre-register'))
  11. .limit(3)
  12. return @onlinecourse if @onlinecourse.count == 3
  13. @onlinecourse += section.contents.joins(:online_course_info)
  14. .where(%q("online_course_infos"."registration_phase" = 'open'))
  15. .limit(3 - @onlinecourse.count)
  16. end
  17. end

app/models/online_course_info.rb

0.0% lines covered

21 relevant lines. 0 lines covered and 21 lines missed.
    
  1. class OnlineCourseInfo < ApplicationRecord
  2. include RailsAdmin::OnlineCourseInfo
  3. belongs_to :content, inverse_of: :online_course_info
  4. REGISTRATION_PHASE_ENUM = {
  5. 'Pré-Inscrição' => 'pre-register',
  6. 'Inscrições Abertas' => 'open',
  7. 'Encerrado' => 'closed'
  8. }.freeze
  9. def registration_phase_enum
  10. REGISTRATION_PHASE_ENUM
  11. end
  12. def title
  13. 'editar dados do curso'
  14. end
  15. validates :registration_phase, presence: true
  16. monetize :associate_price_cents, currency: :brl, numericality: { greater_than_or_equal_to: 0 }, disable_validation: true
  17. monetize :non_associate_price_cents, currency: :brl, numericality: { greater_than_or_equal_to: 0 }
  18. def price(user)
  19. user.associate.present? ? associate_price : non_associate_price
  20. end
  21. end

app/models/payment.rb

0.0% lines covered

151 relevant lines. 0 lines covered and 151 lines missed.
    
  1. class Payment < ApplicationRecord
  2. include AASM
  3. PAYMENT_STATES = %w[nil awaiting_payment in_analyze paid manual_paid avaliable in_dispute returned canceled].freeze
  4. PAYMENT_TYPE = %w[Associate Course CruzaGrafosUser].freeze
  5. belongs_to :user
  6. belongs_to :payable, polymorphic: true, optional: true
  7. has_many :transactions, dependent: :destroy
  8. validates :status, inclusion: { in: PAYMENT_STATES }
  9. validates :payable_type, inclusion: { in: PAYMENT_TYPE }
  10. validates :payable_id, presence: true
  11. monetize :price_cents, currency: :brl, numericality: { greater_than_or_equal_to: 0 }
  12. def self.filters
  13. PAYMENT_TYPE + %w[all]
  14. end
  15. def self.filtered(user, filter)
  16. if filter == 'all'
  17. return Payment.where(user: user)
  18. else
  19. return Payment.where(user: user, payable_type: filter)
  20. end
  21. end
  22. aasm column: 'status' do
  23. state :nil, initial: true
  24. state :awaiting_payment, after_enter: :awaiting_payment_actions
  25. state :in_analyze, after_enter: :in_analyze_actions
  26. state :paid, after_enter: :paid_actions
  27. state :manual_paid
  28. state :available, after_enter: :available_actions
  29. state :in_dispute, after_enter: :in_dispute_actions
  30. state :returned, after_enter: :returned_actions
  31. state :canceled, after_enter: :canceled_actions
  32. event :start do
  33. transitions from: :nil, to: :awaiting_payment
  34. end
  35. event :pay do
  36. transitions from: %i[nil in_analyze awaiting_payment in_dispute canceled], to: :paid
  37. end
  38. event :manual_pay do
  39. transitions from: %i[nil in_analyze awaiting_payment in_dispute canceled manual_paid], to: :manual_paid, guard: :manual_paid_actions?
  40. end
  41. event :analyze do
  42. transitions from: [:awaiting_payment], to: :in_analyze
  43. end
  44. event :cancel do
  45. transitions from: %i[in_analyze awaiting_payment], to: :canceled
  46. end
  47. event :dispute do
  48. transitions from: %i[paid available], to: :in_dispute
  49. end
  50. event :return do
  51. transitions from: %i[paid available in_dispute], to: :returned
  52. end
  53. event :finish do
  54. transitions from: %i[awaiting_payment paid in_dispute], to: :available
  55. end
  56. end
  57. def awaiting_payment_actions; end
  58. def in_analyze_actions; end
  59. def paid_actions
  60. self.pay_date = Time.now
  61. self.origin = 'pagseguro'
  62. self.save()
  63. if self.payable_type == "Associate"
  64. associate_payment
  65. elsif self.payable_type == "CruzaGrafosUser"
  66. grafos_payment
  67. end
  68. end
  69. def associate_payment
  70. user.associate.approval_payment_date = Time.now
  71. #se ele pagou antes de expirar soma um ano ao dia de expiração
  72. if user.associate.running?
  73. user.associate.valid_until = user.associate.valid_until + 1.years
  74. else # se não, vai valer por 1 anos a partir de agora
  75. user.associate.valid_until = Date.today + 1.years
  76. end
  77. user.associate.save()
  78. if user.associate.may_paid?
  79. user.associate.paid!
  80. else
  81. Rails.logger.error 'Problema pagar associado:' + user.associate.errors.messages.to_s
  82. end
  83. begin
  84. UserMailer.paid(user).deliver
  85. UserMailer.paidUser(user).deliver
  86. rescue => e
  87. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  88. end
  89. end
  90. def grafos_payment
  91. user.cruza_grafos_user.approval_payment_date = Time.now
  92. #se ele pagou antes de expirar soma um ano ao dia de expiração
  93. if user.cruza_grafos_user.running?
  94. user.cruza_grafos_user.valid_until = user.associate.valid_until + 30.days
  95. else # se não, vai valer por 30 dias a partir de agora
  96. user.cruza_grafos_user.valid_until = Date.today + 30.days
  97. end
  98. user.cruza_grafos_user.save()
  99. if user.cruza_grafos_user.may_payment_confirm?
  100. user.cruza_grafos_user.payment_confirm!
  101. else
  102. Rails.logger.error 'Problema pagar CG_user:' + user.cruza_grafos_user.errors.messages.to_s
  103. end
  104. begin
  105. CruzaGrafosMailer.paid(user).deliver
  106. CruzaGrafosMailer.paidUser(user).deliver
  107. rescue => e
  108. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  109. end
  110. end
  111. def manual_paid_actions?
  112. self.pay_date = Date.today
  113. self.origin = 'manual-payment'
  114. if self.payable_type == "CruzaGrafosUser"
  115. if user.cruza_grafos_user.running?
  116. user.cruza_grafos_user.valid_until = user.cruza_grafos_user.valid_until + user.cruza_grafos_user.cruza_grafos_type.days
  117. else # se não, vai valer por x dias a partir de agora
  118. user.cruza_grafos_user.valid_until = Date.today + user.cruza_grafos_user.cruza_grafos_type.days
  119. end
  120. self.name = 'Cruza Grafos - ' + self.payable.cruza_grafos_type.description
  121. self.price_cents = self.payable.cruza_grafos_type.price_cents
  122. self.price_currency = self.payable.cruza_grafos_type.price_currency
  123. user.cruza_grafos_user.approval_payment_date = Time.now
  124. user.cruza_grafos_user.manual_paid
  125. user.cruza_grafos_user.save()
  126. end
  127. self.save()
  128. if self.payable_type == "Associate"
  129. if user.associate.running?
  130. user.associate.valid_until = user.associate.valid_until + 1.years
  131. else # se não, vai valer por 1 anos a partir de agora
  132. user.associate.valid_until = Date.today + 1.years
  133. end
  134. user.associate.approval_payment_date = Time.now
  135. user.associate.save()
  136. if(user.associate.valid?)
  137. user.associate.manual_paid!
  138. else
  139. return false
  140. end
  141. #criar uma transaction com o manual pay
  142. transaction = Transaction.new
  143. transaction.paymentMethodCode = '6798312'
  144. transaction.payment_id = self.id
  145. transaction.save
  146. end
  147. end
  148. def available_actions; end
  149. def in_dispute_actions; end
  150. def returned_actions; end
  151. def canceled_actions; end
  152. def generate_pagseguro_payment(user_payment, current_user)
  153. end
  154. # payment.cents = price(user).cents
  155. # payment.currency = price(user).currency
  156. # Payment.create(user: u, payable: o, price: 150)
  157. end

app/models/person.rb

0.0% lines covered

3 relevant lines. 0 lines covered and 3 lines missed.
    
  1. class Person < JsonModel
  2. attr_accessor :role, :name, :text, :picture_url, :active
  3. end

app/models/project.rb

0.0% lines covered

11 relevant lines. 0 lines covered and 11 lines missed.
    
  1. class Project < Content
  2. include RailsAdmin::Project
  3. accepts_nested_attributes_for :project_info, allow_destroy: true
  4. delegate :link, :published_at, to: :project_info, allow_nil: true
  5. def self.filters
  6. [['Todos os Projetos', 'all']] + super()
  7. end
  8. def self.section_contents(section)
  9. section.contents.where(type: 'Project').limit(4)
  10. end
  11. end

app/models/project_info.rb

0.0% lines covered

8 relevant lines. 0 lines covered and 8 lines missed.
    
  1. class ProjectInfo < ApplicationRecord
  2. include RailsAdmin::ProjectInfo
  3. belongs_to :content, inverse_of: :project_info
  4. validates :content, presence: true
  5. def title
  6. 'editar dados do projeto'
  7. end
  8. end

app/models/publication.rb

0.0% lines covered

17 relevant lines. 0 lines covered and 17 lines missed.
    
  1. class Publication < Content
  2. include RailsAdmin::Publication
  3. accepts_nested_attributes_for :publication_info, allow_destroy: true
  4. delegate :author, :subject, :pages, :publisher, :link, :details_file,
  5. to: :publication_info, allow_nil: true
  6. validates :publication_info, presence: true
  7. attr_accessor :details_file_cache
  8. def self.filters
  9. [['Todos as Publicações', 'all']] + super()
  10. end
  11. def self.croped_image_size
  12. { 'width': 396, 'height': 489 }
  13. end
  14. def self.section_contents(section)
  15. section.contents.where(type: 'Publication').limit(2)
  16. end
  17. end

app/models/publication_info.rb

0.0% lines covered

12 relevant lines. 0 lines covered and 12 lines missed.
    
  1. class PublicationInfo < ApplicationRecord
  2. include RailsAdmin::PublicationInfo
  3. mount_uploader :details_file, FileUploader
  4. belongs_to :content, inverse_of: :publication_info
  5. validates :content, presence: true
  6. validates :author, presence: true
  7. validates :subject, presence: true
  8. validates :pages, presence: true, numericality: true
  9. def title
  10. 'editar dados da publicação'
  11. end
  12. end

app/models/recent_documentation.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class RecentDocumentation < FileRecord
  2. def self.json_file_path
  3. 'institutional/transparence/documentacao_mais_recente.json'
  4. end
  5. end

app/models/regulation.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class Regulation < FileRecord
  2. def self.json_file_path
  3. 'institutional/fund/regulamento.json'
  4. end
  5. end

app/models/section.rb

100.0% lines covered

7 relevant lines. 7 lines covered and 0 lines missed.
    
  1. 1 class Section < ApplicationRecord
  2. 1 include RailsAdmin::Section
  3. 1 include Sluggi::Slugged
  4. 1 include Concerns::PublishableSections
  5. 1 mount_uploader :banner, ImageUploader
  6. 1 has_and_belongs_to_many :contents, inverse_of: :sections
  7. 1 validates :name, presence: true, uniqueness: { case_sensitive: false }
  8. end

app/models/secundary_menu_option.rb

0.0% lines covered

6 relevant lines. 0 lines covered and 6 lines missed.
    
  1. class SecundaryMenuOption < JsonModel
  2. attr_accessor :session, :slug, :active
  3. def self.json_file_path
  4. 'secundary_menu.json'
  5. end
  6. end

app/models/state.rb

0.0% lines covered

6 relevant lines. 0 lines covered and 6 lines missed.
    
  1. class State < JsonModel
  2. attr_accessor :nome, :sigla
  3. def self.json_file_path
  4. 'states.json'
  5. end
  6. end

app/models/static_content.rb

0.0% lines covered

11 relevant lines. 0 lines covered and 11 lines missed.
    
  1. class StaticContent < ApplicationRecord
  2. include Sluggi::Slugged
  3. validates :title, presence: true, uniqueness: { case_sensitive: false }
  4. validates :slug, presence: true, uniqueness: { case_sensitive: false}
  5. def slug_value
  6. title
  7. end
  8. def slug_value_changed?
  9. title_changed?
  10. end
  11. end

app/models/supervisor.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class Supervisor < Person
  2. def self.json_file_path
  3. '/institutional/conselho_fiscal.json'
  4. end
  5. end

app/models/team.rb

0.0% lines covered

5 relevant lines. 0 lines covered and 5 lines missed.
    
  1. class Team < Person
  2. def self.json_file_path
  3. 'institutional/equipe.json'
  4. end
  5. end

app/models/transaction.rb

0.0% lines covered

3 relevant lines. 0 lines covered and 3 lines missed.
    
  1. class Transaction < ApplicationRecord
  2. belongs_to :payment, optional: true
  3. end

app/models/user.rb

64.71% lines covered

34 relevant lines. 22 lines covered and 12 lines missed.
    
  1. 1 require 'cpf_cnpj'
  2. 1 class User < ApplicationRecord
  3. 1 default_scope -> { order(created_at: :desc) }
  4. # Include default admins modules. Others available are:
  5. # :confirmable, :lockable, :timeoutable and :omniauthable
  6. 1 devise :database_authenticatable, :registerable,
  7. :recoverable, :rememberable, :trackable, :validatable
  8. 1 has_one :associate, dependent: :destroy
  9. 1 has_one :cruza_grafos_user, dependent: :destroy
  10. 1 has_many :payments, dependent: :destroy
  11. 1 after_create :send_welcome_email
  12. 1 include PgSearch
  13. 1 FILTER_DATE_SCOPES = %i[created_at birthday].freeze
  14. 1 FILTER_TEXT_SCOPES = %i[name city state email].freeze
  15. 1 include Concerns::Filterable
  16. 1 attr_writer :login
  17. 1 validates_uniqueness_of :email
  18. # each letter represents a weight while searching
  19. 1 pg_search_scope :any_word_search, against: {
  20. name: 'A', email: 'B'
  21. }, using: { tsearch: { prefix: true, any_word: true } }
  22. 1 pg_search_scope :exact_search, against: {
  23. name: 'A', email: 'B'
  24. }, using: { tsearch: { prefix: true, any_word: false } }
  25. 1 def login
  26. @login || email
  27. end
  28. 1 def self.find_for_database_authentication(warden_conditions)
  29. conditions = warden_conditions.dup
  30. return find_by(conditions.to_h) if conditions.key?(:email)
  31. login = conditions.delete(:login)
  32. return unless login
  33. where(conditions.to_h).find_by(['lower(email) = :value', { value: login.downcase }])
  34. end
  35. 1 private
  36. 1 def password_required?
  37. new_record? || password.present?
  38. end
  39. 1 def self.fulltext_search(text)
  40. return all if text.blank?
  41. ['"', "'"].any? { |quotation| text.include?(quotation) } ? exact_search(text) : any_word_search(text)
  42. end
  43. 1 def send_welcome_email
  44. begin
  45. UserMailer.welcome(self).deliver
  46. rescue => e
  47. puts 'Problema ao enviar email. Possivel problema de SMTP - error message: '+ e.message
  48. end
  49. end
  50. end

lib/json_web_token.rb

0.0% lines covered

14 relevant lines. 0 lines covered and 14 lines missed.
    
  1. class JsonWebToken
  2. class << self
  3. def encode(payload, exp = 24.hours.from_now)
  4. payload[:exp] = exp.to_i
  5. JWT.encode(payload, Rails.application.secrets.secret_key_base)
  6. end
  7. def decode(token)
  8. body = JWT.decode(token, Rails.application.secrets.secret_key_base)[0]
  9. HashWithIndifferentAccess.new body
  10. rescue
  11. nil
  12. end
  13. end
  14. end

lib/rails_admin/publish.rb

64.71% lines covered

17 relevant lines. 11 lines covered and 6 lines missed.
    
  1. 1 module RailsAdmin
  2. 1 module Config
  3. 1 module Actions
  4. 1 class Publish < RailsAdmin::Config::Actions::Base
  5. 1 RailsAdmin::Config::Actions.register(self)
  6. 1 register_instance_option :member do
  7. 1 true
  8. end
  9. 1 register_instance_option :visible? do
  10. bindings[:object].respond_to?(:published) &&
  11. authorized &&
  12. !bindings[:object].published
  13. end
  14. 1 register_instance_option :controller do
  15. proc do
  16. @object.publish
  17. redirect_to back_or_index
  18. end
  19. end
  20. 1 register_instance_option :link_icon do
  21. 'icon-eye-open'
  22. end
  23. 1 register_instance_option :pjax? do
  24. false
  25. end
  26. end
  27. end
  28. end
  29. end

lib/rails_admin/unpublish.rb

64.71% lines covered

17 relevant lines. 11 lines covered and 6 lines missed.
    
  1. 1 module RailsAdmin
  2. 1 module Config
  3. 1 module Actions
  4. 1 class Unpublish < RailsAdmin::Config::Actions::Base
  5. 1 RailsAdmin::Config::Actions.register(self)
  6. 1 register_instance_option :member do
  7. 1 true
  8. end
  9. 1 register_instance_option :visible? do
  10. bindings[:object].respond_to?(:published) &&
  11. authorized &&
  12. bindings[:object].published
  13. end
  14. 1 register_instance_option :controller do
  15. proc do
  16. @object.unpublish
  17. redirect_to back_or_index
  18. end
  19. end
  20. 1 register_instance_option :link_icon do
  21. 'icon-eye-close'
  22. end
  23. 1 register_instance_option :pjax? do
  24. false
  25. end
  26. end
  27. end
  28. end
  29. end

lib/simple_form_extensions/button_components.rb

37.5% lines covered

8 relevant lines. 3 lines covered and 5 lines missed.
    
  1. 1 module ButtonComponents
  2. 1 def cancel_button(*args)
  3. options = args.extract_options!
  4. options[:class] = [options[:class], 'btn-primary'].compact
  5. args << options
  6. cancel = options.delete(:cancel)
  7. template.link_to(I18n.t('simple_form.buttons.cancel'), cancel, class: 'btn submit_buttons', id: 'cancel') if cancel
  8. end
  9. end
  10. 1 SimpleForm::FormBuilder.send :include, ButtonComponents