From 427783f1a623b6430500f1012221b2fe725a3e71 Mon Sep 17 00:00:00 2001 From: IMonardez Date: Thu, 15 Aug 2024 17:25:40 -0300 Subject: [PATCH] issue #477 - Update Skin color at student forms and exclude the Skin color model --- app/controllers/skin_colors_controller.rb | 7 -- app/controllers/students_controller.rb | 6 +- app/models/skin_color.rb | 7 -- app/models/student.rb | 1 - config/locales/navigation.pt-BR.yml | 1 - config/navigation.rb | 3 +- ...0240609002506_add_skin_color_to_student.rb | 10 ++ .../20240609002506_create_skin_color.rb | 19 ---- db/schema.rb | 91 +++++++++---------- db/seeds.rb | 9 +- spec/factories/factory_skin_color.rb | 7 -- spec/features/students_spec.rb | 5 + spec/models/skin_color_spec.rb | 6 -- 13 files changed, 64 insertions(+), 108 deletions(-) delete mode 100644 app/controllers/skin_colors_controller.rb delete mode 100644 app/models/skin_color.rb create mode 100644 db/migrate/20240609002506_add_skin_color_to_student.rb delete mode 100644 db/migrate/20240609002506_create_skin_color.rb delete mode 100644 spec/factories/factory_skin_color.rb delete mode 100644 spec/models/skin_color_spec.rb diff --git a/app/controllers/skin_colors_controller.rb b/app/controllers/skin_colors_controller.rb deleted file mode 100644 index e59c4cfc..00000000 --- a/app/controllers/skin_colors_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class SkinColorsController < ApplicationController - active_scaffold :skin_color do |config| - config.columns = [:name, :description] - end -end diff --git a/app/controllers/students_controller.rb b/app/controllers/students_controller.rb index 6017c738..860232a0 100644 --- a/app/controllers/students_controller.rb +++ b/app/controllers/students_controller.rb @@ -9,7 +9,7 @@ class StudentsController < ApplicationController helper :student_majors UPDATE_FIELDS = [ - :name, :photo, :sex, :civil_status, :birthdate, :city, :neighborhood, + :name, :photo, :sex, :civil_status, :skin_color, :birthdate, :city, :neighborhood, :address, :zip_code, :telephone1, :telephone2, :email, :employer, :job_position, :cpf, :identity_number, :identity_issuing_body, :identity_issuing_place, :identity_expedition_date, :birth_country, @@ -44,6 +44,10 @@ class StudentsController < ApplicationController config.columns[:civil_status].options = { options: ["Solteiro(a)", "Casado(a)"] } + config.columns[:skin_color].form_ui = :select + config.columns[:skin_color].options = { + options: ["Não declarado", "Branca", "Preta", "Parda", "Amarela", "Indígena"] + } config.columns[:student_majors].includes = [:majors, :student_majors] diff --git a/app/models/skin_color.rb b/app/models/skin_color.rb deleted file mode 100644 index ba3d971e..00000000 --- a/app/models/skin_color.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class SkinColor < ApplicationRecord - has_paper_trail - - has_many :students, foreign_key: "skin_color_id" -end diff --git a/app/models/student.rb b/app/models/student.rb index 2e897578..c060d2d7 100644 --- a/app/models/student.rb +++ b/app/models/student.rb @@ -23,7 +23,6 @@ class Student < ApplicationRecord class_name: "Country", foreign_key: "birth_country_id" belongs_to :user, optional: true - belongs_to :skin_color, optional: true has_many :student_majors, dependent: :destroy has_many :majors, through: :student_majors diff --git a/config/locales/navigation.pt-BR.yml b/config/locales/navigation.pt-BR.yml index a56abd07..720d60b5 100644 --- a/config/locales/navigation.pt-BR.yml +++ b/config/locales/navigation.pt-BR.yml @@ -82,7 +82,6 @@ pt-BR: notification_log: Notificações Enviadas custom_variable: Variáveis report_configuration: Configurações de Relatório - skin_color: Cor de pele logout: label: 'Logout' diff --git a/config/navigation.rb b/config/navigation.rb index c400b2b0..d2505ce8 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -231,7 +231,7 @@ def can_read?(*args) config_models = [ User, Role, CustomVariable, Version, Notification, - NotificationLog, ReportConfiguration, EmailTemplate, SkinColor + NotificationLog, ReportConfiguration, EmailTemplate ] mainhelper.listitem :configurations, config_models do |submenu| submenu.modelitem User @@ -243,7 +243,6 @@ def can_read?(*args) submenu.modelitem NotificationLog submenu.modelitem CustomVariable submenu.modelitem ReportConfiguration - submenu.modelitem SkinColor end mainhelper.item :logout, destroy_user_session_path diff --git a/db/migrate/20240609002506_add_skin_color_to_student.rb b/db/migrate/20240609002506_add_skin_color_to_student.rb new file mode 100644 index 00000000..79a8d5e9 --- /dev/null +++ b/db/migrate/20240609002506_add_skin_color_to_student.rb @@ -0,0 +1,10 @@ +class AddSkinColorToStudent < ActiveRecord::Migration[7.0] + def up + add_column :students, :skin_color, :string + add_column :students, :pcd, :boolean + end + def down + remove_column :students, :skin_color + remove_column :students, :pcd + end +end diff --git a/db/migrate/20240609002506_create_skin_color.rb b/db/migrate/20240609002506_create_skin_color.rb deleted file mode 100644 index 3f4d2dda..00000000 --- a/db/migrate/20240609002506_create_skin_color.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateSkinColor < ActiveRecord::Migration[7.0] - def up - create_table :skin_colors do |t| - t.string :name - t.string :description - - t.timestamps - end - add_column :students, :skin_color_id, :integer - add_column :students, :pcd, :boolean - add_foreign_key :students, :skin_colors, name: "skin_color_id" - end - def down - drop_table :skin_colors - remove_column :students, :skin_color_id - remove_column :students, :pcd - remove_foreign_key :students, :skin_colors - end -end diff --git a/db/schema.rb b/db/schema.rb index 7b5d9d9f..c3784741 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_06_09_002506) do +ActiveRecord::Schema[7.0].define(version: 2024_06_10_001559) do create_table "accomplishments", force: :cascade do |t| t.integer "enrollment_id" t.integer "phase_id" @@ -118,16 +118,16 @@ t.integer "member_form_id" t.integer "shared_form_id" t.integer "consolidation_form_id" - t.boolean "can_edit_candidate" + t.boolean "can_edit_candidate", default: false, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "approval_condition_id" t.integer "keep_in_phase_condition_id" t.integer "candidate_form_id" - t.boolean "candidate_can_edit" - t.boolean "candidate_can_see_member" - t.boolean "candidate_can_see_shared" - t.boolean "candidate_can_see_consolidation" + t.boolean "candidate_can_edit", default: false, null: false + t.boolean "candidate_can_see_member", default: false, null: false + t.boolean "candidate_can_see_shared", default: false, null: false + t.boolean "candidate_can_see_consolidation", default: false, null: false t.index "\"ranking_config_id\"", name: "index_admission_phases_on_ranking_config_id" t.index ["candidate_form_id"], name: "index_admission_phases_on_candidate_form_id" t.index ["consolidation_form_id"], name: "index_admission_phases_on_consolidation_form_id" @@ -144,7 +144,7 @@ t.integer "order" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.boolean "partial_consolidation", default: true + t.boolean "partial_consolidation", default: true, null: false t.index ["admission_phase_id"], name: "index_admission_process_phases_on_admission_phase_id" t.index ["admission_process_id"], name: "index_admission_process_phases_on_admission_process_id" end @@ -172,14 +172,14 @@ t.integer "letter_template_id" t.integer "min_letters" t.integer "max_letters" - t.boolean "allow_multiple_applications" - t.boolean "visible", default: true - t.boolean "require_session", default: true + t.boolean "allow_multiple_applications", default: false, null: false + t.boolean "visible", default: true, null: false + t.boolean "require_session", default: true, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.date "edit_date" - t.boolean "staff_can_edit" - t.boolean "staff_can_undo" + t.boolean "staff_can_edit", default: false, null: false + t.boolean "staff_can_undo", default: false, null: false t.integer "level_id" t.integer "enrollment_status_id" t.string "enrollment_number_field" @@ -218,8 +218,8 @@ t.string "group_column_tabular" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.boolean "hide_empty_sections" - t.boolean "show_partial_candidates" + t.boolean "hide_empty_sections", default: false, null: false + t.boolean "show_partial_candidates", default: false, null: false t.index ["form_condition_id"], name: "index_admission_report_configs_on_form_condition_id" t.index ["form_template_id"], name: "index_admission_report_configs_on_form_template_id" end @@ -232,7 +232,7 @@ t.string "committee" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.boolean "in_simple" + t.boolean "in_simple", default: false, null: false t.string "pdf_format" t.index ["admission_report_config_id"], name: "index_admission_report_groups_on_admission_report_config_id" end @@ -249,7 +249,7 @@ create_table "advisements", force: :cascade do |t| t.integer "professor_id", null: false t.integer "enrollment_id", null: false - t.boolean "main_advisor", default: false + t.boolean "main_advisor", default: false, null: false t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false t.index ["enrollment_id"], name: "index_advisements_on_enrollment_id" @@ -319,8 +319,8 @@ t.integer "enrollment_id" t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false - t.boolean "disapproved_by_absence", default: false - t.boolean "grade_not_count_in_gpr", default: false + t.boolean "disapproved_by_absence", default: false, null: false + t.boolean "grade_not_count_in_gpr", default: false, null: false t.string "justification_grade_not_count_in_gpr", default: "" t.index ["course_class_id"], name: "index_class_enrollments_on_course_class_id" t.index ["enrollment_id"], name: "index_class_enrollments_on_enrollment_id" @@ -353,7 +353,7 @@ t.integer "semester" t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false - t.boolean "not_schedulable", default: false + t.boolean "not_schedulable", default: false, null: false t.string "obs_schedule" t.index ["course_id"], name: "index_course_classes_on_course_id" t.index ["professor_id"], name: "index_course_classes_on_professor_id" @@ -370,11 +370,11 @@ create_table "course_types", force: :cascade do |t| t.string "name", limit: 255 - t.boolean "has_score" + t.boolean "has_score", default: false, null: false t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false - t.boolean "schedulable", default: true - t.boolean "show_class_name", default: true + t.boolean "schedulable", default: true, null: false + t.boolean "show_class_name", default: true, null: false t.boolean "allow_multiple_classes", default: false, null: false t.boolean "on_demand", default: false, null: false end @@ -388,7 +388,7 @@ t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false t.integer "workload" - t.boolean "available", default: true + t.boolean "available", default: true, null: false t.index ["course_type_id"], name: "index_courses_on_course_type_id" end @@ -428,7 +428,7 @@ t.text "description" t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false - t.boolean "show_advisor_name", default: false + t.boolean "show_advisor_name", default: false, null: false t.string "thesis_judgement", limit: 255 end @@ -448,7 +448,7 @@ t.string "to" t.string "subject" t.text "body" - t.boolean "enabled", default: true + t.boolean "enabled", default: true, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end @@ -460,7 +460,7 @@ t.integer "number_of_semesters", default: 1 t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false - t.boolean "active", default: true + t.boolean "active", default: true, null: false t.index ["enrollment_id"], name: "index_enrollment_holds_on_enrollment_id" end @@ -490,7 +490,7 @@ t.string "name", limit: 255 t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false - t.boolean "user" + t.boolean "user", default: false, null: false end create_table "enrollments", force: :cascade do |t| @@ -542,7 +542,7 @@ create_table "filled_forms", force: :cascade do |t| t.integer "form_template_id" - t.boolean "is_filled" + t.boolean "is_filled", default: false, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false t.index ["form_template_id"], name: "index_filled_forms_on_form_template_id" @@ -608,7 +608,7 @@ t.datetime "updated_at", precision: nil, null: false t.string "course_name", limit: 255 t.integer "default_duration", default: 0 - t.boolean "show_advisements_points_in_list" + t.boolean "show_advisements_points_in_list", default: false, null: false t.string "short_name_showed_in_list_header" end @@ -645,9 +645,9 @@ t.datetime "next_execution", precision: nil t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false - t.boolean "individual", default: true + t.boolean "individual", default: true, null: false t.integer "query_id", null: false - t.boolean "has_grades_report_pdf_attachment", default: false + t.boolean "has_grades_report_pdf_attachment", default: false, null: false t.index ["query_id"], name: "index_notifications_on_query_id" end @@ -679,9 +679,9 @@ t.string "description", limit: 255 t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false - t.boolean "is_language", default: false - t.boolean "extend_on_hold", default: false - t.boolean "active", default: true + t.boolean "is_language", default: false, null: false + t.boolean "extend_on_hold", default: false, null: false + t.boolean "active", default: true, null: false end create_table "professor_research_areas", force: :cascade do |t| @@ -776,7 +776,7 @@ t.integer "form_condition_id" t.string "behavior_on_invalid_condition", default: "Erro - apenas em seletores" t.string "behavior_on_invalid_ranking", default: "Erro" - t.boolean "candidate_can_see" + t.boolean "candidate_can_see", default: false, null: false t.index ["form_condition_id"], name: "index_ranking_configs_on_form_condition_id" t.index ["form_template_id"], name: "index_ranking_configs_on_form_template_id" t.index ["machine_field_id"], name: "index_ranking_configs_on_machine_field_id" @@ -815,13 +815,13 @@ create_table "report_configurations", force: :cascade do |t| t.string "name", limit: 255 - t.boolean "use_at_report" - t.boolean "use_at_transcript" - t.boolean "use_at_grades_report" - t.boolean "use_at_schedule" + t.boolean "use_at_report", default: false, null: false + t.boolean "use_at_transcript", default: false, null: false + t.boolean "use_at_grades_report", default: false, null: false + t.boolean "use_at_schedule", default: false, null: false t.text "text" t.string "image", limit: 255 - t.boolean "signature_footer" + t.boolean "signature_footer", default: false, null: false t.integer "order", default: 2 t.decimal "scale", precision: 10, scale: 8 t.integer "x" @@ -860,7 +860,7 @@ create_table "scholarship_suspensions", force: :cascade do |t| t.date "start_date" t.date "end_date" - t.boolean "active", default: true + t.boolean "active", default: true, null: false t.integer "scholarship_duration_id" t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false @@ -899,13 +899,6 @@ t.index ["updated_at"], name: "index_sessions_on_updated_at" end - create_table "skin_colors", force: :cascade do |t| - t.string "name" - t.string "description" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - create_table "sponsors", force: :cascade do |t| t.string "name", limit: 255 t.datetime "created_at", precision: nil, null: false @@ -957,7 +950,7 @@ t.string "photo", limit: 255 t.integer "birth_country_id" t.integer "user_id", limit: 8 - t.integer "skin_color_id" + t.string "skin_color" t.boolean "pcd" t.index ["birth_city_id"], name: "index_students_on_birth_city_id" t.index ["birth_country_id"], name: "index_students_on_birth_country_id" diff --git a/db/seeds.rb b/db/seeds.rb index e78e6508..dc9f5e44 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -13269,11 +13269,4 @@ { name: "Venus", state: State.find_by_code("TO") }, { name: "Wanderlandia", state: State.find_by_code("TO") }, { name: "Xambioa", state: State.find_by_code("TO") }, -]) -SkinColor.create([ - {name: "Preta"}, - {name: "Branco"}, - {name: "Pardo"}, - {name: "Indígena"}, - {name: "Não declarado"}, - ]) +]) \ No newline at end of file diff --git a/spec/factories/factory_skin_color.rb b/spec/factories/factory_skin_color.rb deleted file mode 100644 index 0d8ceec4..00000000 --- a/spec/factories/factory_skin_color.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :skin_color do - name { "Branca" } - end -end \ No newline at end of file diff --git a/spec/features/students_spec.rb b/spec/features/students_spec.rb index 531047f0..cb0a2279 100644 --- a/spec/features/students_spec.rb +++ b/spec/features/students_spec.rb @@ -117,6 +117,11 @@ expect(page.all("select#record_sex_ option").map(&:value)).to eq ["M", "F"] end + it "should have a selection for sex options" do + expect(page.all("select#record_skin_color_ option").map(&:text)).to eq ["Não declarado", "Branca", "Preta", "Parda", "Amarela", "Indígena"] + expect(page.all("select#record_skin_color_ option").map(&:value)).to eq ["Não declarado", "Branca", "Preta", "Parda", "Amarela", "Indígena"] + end + it "should have a selection for civil_status options" do expect(page.all("select#record_civil_status_ option").map(&:text)).to eq ["Solteiro(a)", "Casado(a)"] expect(page.all("select#record_civil_status_ option").map(&:value)).to eq ["Solteiro(a)", "Casado(a)"] diff --git a/spec/models/skin_color_spec.rb b/spec/models/skin_color_spec.rb deleted file mode 100644 index d55a5a65..00000000 --- a/spec/models/skin_color_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe SkinColor, type: :model do - it{ should be_able_to_be_destroyed } - it{ should have_many(:students) } -end