Skip to content

Commit

Permalink
Merge branch 'main' into issue-218
Browse files Browse the repository at this point in the history
  • Loading branch information
¨caiovelp¨ committed Jan 15, 2025
2 parents 06d4be3 + 46e1453 commit 5f50269
Show file tree
Hide file tree
Showing 65 changed files with 3,260 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/assets/javascripts/form_fields/config_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ function form_field_config_base(form_field) {
} else if (selected_value == "code") {
form_field.widgets = [
config_form_field_codemirror(form_field, "code", "text/x-ruby"),
config_form_field_condition(form_field, "condition", form_field.condition_options)
config_form_field_condition(form_field, "condition", form_field.condition_options),
config_form_field_select(form_field, "code_type", [["number", "Número"], ["string", "Texto"], ["date", "Data"]], { required: false, default: "number" })
]
} else if (selected_value == "email") {
form_field.widgets = [
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/form_fields/config_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function config_form_field_select(form_field, field, selectable, options) {
let r = (Math.random() + 1).toString(36).substring(7);
let title = form_field.i18n(field);
let id = `${form_field.baseid}_${field}_${r}`
let value = form_field.data[field] || "";
let value = form_field.data[field] || options["default"] || "";

let options_text = [];
let found = null;
Expand Down
2 changes: 1 addition & 1 deletion app/models/admissions/admission_committee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Admissions::AdmissionCommittee < ActiveRecord::Base
has_many :admission_phases, through: :admission_phase_committees,
class_name: "Admissions::AdmissionPhase"

belongs_to :form_condition, optional:true,
belongs_to :form_condition, optional: true,
class_name: "Admissions::FormCondition"

validates :name, presence: true
Expand Down
1 change: 1 addition & 0 deletions app/models/admissions/admission_phase_evaluation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Admissions::AdmissionPhaseEvaluation < ActiveRecord::Base
after_initialize :initialize_filled_form

def initialize_filled_form
return if self.admission_phase.blank?
self.filled_form ||= Admissions::FilledForm.new(
is_filled: false,
form_template: self.admission_phase.member_form
Expand Down
2 changes: 2 additions & 0 deletions app/models/admissions/admission_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def max_edit_date
end

def end_greater_than_start_date
return if self.start_date.nil? || self.end_date.nil?
if self.end_date < self.start_date
self.errors.add(:base, :end_greater_than_start_date)
end
Expand All @@ -77,6 +78,7 @@ def max_greater_than_min_letters
end

def simple_url_is_unique_while_open
return if self.end_date.nil?
return if self.end_date < Date.today

if self.simple_url.to_i.to_s == self.simple_url
Expand Down
1 change: 1 addition & 0 deletions app/models/admissions/admission_process_ranking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Admissions::AdmissionProcessRanking < ActiveRecord::Base

def that_phase_is_part_of_the_process
return if self.admission_phase.blank?
return if self.admission_process.blank?
self.admission_process.phases.each do |p|
return if p.admission_phase == self.admission_phase
end
Expand Down
1 change: 1 addition & 0 deletions app/models/admissions/admission_ranking_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Admissions::AdmissionRankingResult < ActiveRecord::Base
after_initialize :initialize_filled_form

def initialize_filled_form
return if self.ranking_config.nil?
self.filled_form ||= Admissions::FilledForm.new(
is_filled: false,
form_template: self.ranking_config.form_template
Expand Down
6 changes: 5 additions & 1 deletion app/models/admissions/filled_form_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def validate_file_field(configuration, is_photo: false)
values << ".jpg" if is_photo
filename = self.file.filename.downcase
if values.none? { |ext| filename.end_with?(ext.downcase) }
add_error(:extension, valid: configuration["values"].join(', '))
add_error(:extension, valid: configuration["values"].join(", "))
end
end
end
Expand Down Expand Up @@ -356,6 +356,10 @@ def get_type
else
"string"
end
when Admissions::FormField::CODE
configuration = self.form_field.config_hash
return configuration["code_type"] if configuration["code_type"].present?
"number"
else
"string"
end
Expand Down
1 change: 1 addition & 0 deletions app/models/admissions/letter_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Admissions::LetterRequest < ActiveRecord::Base
after_initialize :initialize_filled_form

def initialize_filled_form
return if self.admission_application.blank?
self.filled_form ||= Admissions::FilledForm.new(
is_filled: false,
form_template: self.admission_application.admission_process.letter_template
Expand Down
1 change: 1 addition & 0 deletions config/locales/admissions/form_field.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pt-BR:
email: Email
date: Data
configurations:
code_type: "Tipo do resultado"
show_config: "Mostrar configuração"
hide_config: "Esconder configuração"
error_exists: "Há algum problema nas configurações"
Expand Down
21 changes: 21 additions & 0 deletions spec/factories/admissions/factory_admission_application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_application, class: Admissions::AdmissionApplication, aliases: [
"admissions/admission_application"
] do
name { "ana" }
email { "[email protected]" }
admission_process
filled_form

trait :in_process_with_letters do
admission_process { create(:admission_process, :with_letter_template) }
end
end
end
14 changes: 14 additions & 0 deletions spec/factories/admissions/factory_admission_committee.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_committee, class: Admissions::AdmissionCommittee, aliases: [
"admissions/admission_committee"
] do
name { "Comitê" }
end
end
15 changes: 15 additions & 0 deletions spec/factories/admissions/factory_admission_committee_member.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_committee_member, class: Admissions::AdmissionCommitteeMember, aliases: [
"admissions/admission_committee_member"
] do
admission_committee
user
end
end
17 changes: 17 additions & 0 deletions spec/factories/admissions/factory_admission_pendency.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_pendency, class: Admissions::AdmissionPendency, aliases: [
"admissions/admission_pendency"
] do
admission_phase
admission_application
mode { Admissions::AdmissionPendency::SHARED }
status { Admissions::AdmissionPendency::PENDENT }
end
end
29 changes: 29 additions & 0 deletions spec/factories/admissions/factory_admission_phase.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_phase, class: Admissions::AdmissionPhase, aliases: [
"admissions/admission_phase"
] do
# association :approval_condition, factory: form_condition
# association :keep_in_phase_condition, factory: form_condition
# association :consolidation_form, factory: form_template
# association :candidate_form, factory: form_template
name { "Fase 1" }
can_edit_candidate { false }
candidate_can_see_member { false }
candidate_can_see_shared { false }
candidate_can_see_consolidation { false }

trait :with_member_form do
member_form { create(:form_template) }
end
trait :with_shared_form do
shared_form { create(:form_template) }
end
end
end
15 changes: 15 additions & 0 deletions spec/factories/admissions/factory_admission_phase_committee.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_phase_committee, class: Admissions::AdmissionPhaseCommittee, aliases: [
"admissions/admission_phase_committee"
] do
admission_phase
admission_committee
end
end
17 changes: 17 additions & 0 deletions spec/factories/admissions/factory_admission_phase_evaluation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_phase_evaluation, class: Admissions::AdmissionPhaseEvaluation, aliases: [
"admissions/admission_phase_evaluation"
] do
admission_phase { create(:admission_phase, :with_member_form) }
user
admission_application
filled_form
end
end
17 changes: 17 additions & 0 deletions spec/factories/admissions/factory_admission_phase_result.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_phase_result, class: Admissions::AdmissionPhaseResult, aliases: [
"admissions/admission_phase_result"
] do
admission_phase { create(:admission_phase, :with_shared_form) }
admission_application
filled_form
mode { Admissions::AdmissionPhaseResult::SHARED }
end
end
35 changes: 35 additions & 0 deletions spec/factories/admissions/factory_admission_process.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_process, class: Admissions::AdmissionProcess, aliases: [
"admissions/admission_process"
] do
name { "Mestrado 2024.1" }
simple_url { "mestrado" }
year { 2024 }
semester { 1 }
start_date { Date.parse("2024/01/01") }
end_date { Date.parse("2024/02/01") }
edit_date { Date.parse("2024/02/15") }
form_template
# letter_template
min_letters { 0 }
max_letters { 0 }
allow_multiple_applications { false }
visible { true }
staff_can_edit { true }
staff_can_undo { true }
require_session { false }

trait :with_letter_template do
letter_template { create(:form_template, template_type: "Carta de Recomendação") }
min_letters { nil }
max_letters { nil }
end
end
end
15 changes: 15 additions & 0 deletions spec/factories/admissions/factory_admission_process_phase.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_process_phase, class: Admissions::AdmissionProcessPhase, aliases: [
"admissions/admission_process_phase"
] do
admission_process
admission_phase
end
end
15 changes: 15 additions & 0 deletions spec/factories/admissions/factory_admission_process_ranking.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_process_ranking, class: Admissions::AdmissionProcessRanking, aliases: [
"admissions/admission_process_ranking"
] do
ranking_config
admission_process
end
end
16 changes: 16 additions & 0 deletions spec/factories/admissions/factory_admission_ranking_result.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_ranking_result, class: Admissions::AdmissionRankingResult, aliases: [
"admissions/admission_ranking_result"
] do
ranking_config
admission_application
filled_form
end
end
22 changes: 22 additions & 0 deletions spec/factories/admissions/factory_admission_report_column.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_report_column, class: Admissions::AdmissionReportColumn, aliases: [
"admissions/admission_report_column"
] do
admission_report_group
name { "coluna" }
before(:create) do |column|
if !Admissions::FormField.field_name_exists?(
column.name, in_main: true, in_letter: true
)
FactoryBot.create(:form_field, name: column.name)
end
end
end
end
15 changes: 15 additions & 0 deletions spec/factories/admissions/factory_admission_report_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_report_config, class: Admissions::AdmissionReportConfig, aliases: [
"admissions/admission_report_config"
] do
name { "Configuração de Relatório" }
group_column_tabular { Admissions::AdmissionReportConfig::COLUMN }
end
end
17 changes: 17 additions & 0 deletions spec/factories/admissions/factory_admission_report_group.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) Universidade Federal Fluminense (UFF).
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file.

# Read about factories at https://github.com/thoughtbot/factory_bot

# frozen_string_literal: true

FactoryBot.define do
factory :admission_report_group, class: Admissions::AdmissionReportGroup, aliases: [
"admissions/admission_report_group"
] do
admission_report_config
mode { Admissions::AdmissionReportGroup::MAIN }
pdf_format { Admissions::AdmissionReportGroup::LIST }
operation { Admissions::AdmissionReportGroup::INCLUDE }
end
end
Loading

0 comments on commit 5f50269

Please sign in to comment.