diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..d5ff60bc --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "bundler" # See documentation for possible values + directory: "/" # Location of package manifests + target-branch: "bugfixes" + schedule: + interval: "weekly" diff --git a/README.md b/README.md index 8355669d..1bf71ca8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ This project was initiated by professors Leonardo Murta and Vanessa Braganholo a * Luis Antônio Vieira Junior (joined in August 2013) * Daniel Prett (joined in August 2014) * Carlos Eduardo Cabral da Cunha (joined in August 2016) +* Caio Henrique Velloso Paranhos (joined in March 2024) +* Igor de Paula Siqueira Monárdez (joined in May 2024) # Additional contributors diff --git a/app/assets/stylesheets/custom/admissions.scss b/app/assets/stylesheets/custom/admissions.scss index c218277e..8307fafc 100644 --- a/app/assets/stylesheets/custom/admissions.scss +++ b/app/assets/stylesheets/custom/admissions.scss @@ -87,4 +87,8 @@ .advanced-config-item { display: none; +} + +.reupload-notice { + color: purple; } \ No newline at end of file diff --git a/app/controllers/admissions/apply_controller.rb b/app/controllers/admissions/apply_controller.rb index e9736657..ec9d005e 100644 --- a/app/controllers/admissions/apply_controller.rb +++ b/app/controllers/admissions/apply_controller.rb @@ -90,11 +90,25 @@ def update(creating: false) id: @admission_application.token ), notice: notice else + # Temporary log to understand the reason of why submission is failing + ExceptionNotifier.notify_exception( + Exception.new("Validação javascript de seleção falhou e form com erro chegou no servidor"), + data: { + params:, + full_messages: @admission_application.errors.full_messages, + errors: @admission_application.errors + } + ) if !was_filled @admission_application.submission_time = nil end @admission_application.filled_form.is_filled = was_filled prepare_admission_application_fields + @show_reupload_files_notice = @admission_application + .filled_form.form_template.has_file_fields? + if @show_reupload_files_notice + @admission_application.filled_form.erase_non_filled_file_fields + end render :edit end end @@ -126,6 +140,7 @@ def prepare_edit_update_application(creating: false) if !creating @show_name = false @show_email = false + @show_reupload_files_notice = false @submission_url = admission_apply_path( admission_id: @admission_process.simple_id, id: @admission_application.token diff --git a/app/mailers/devise_mailer.rb b/app/mailers/devise_mailer.rb index a8d697a8..8376fabe 100644 --- a/app/mailers/devise_mailer.rb +++ b/app/mailers/devise_mailer.rb @@ -22,6 +22,9 @@ def headers_for(action, opts) headers[:body] = render_to_string( inline: @template.body ) unless @template.body.nil? + headers[:reply_to] = render_to_string( + inline: CustomVariable.reply_to + ) @template.update_mailer_headers(headers) headers end diff --git a/app/models/admissions/filled_form.rb b/app/models/admissions/filled_form.rb index b73a6797..d291a99e 100644 --- a/app/models/admissions/filled_form.rb +++ b/app/models/admissions/filled_form.rb @@ -152,4 +152,16 @@ def find_cpf_field end nil end + + def erase_non_filled_file_fields + self.fields.each do |field| + if field.form_field.is_file_field? + if field.persisted? + field.reload + else + field.file = nil + end + end + end + end end diff --git a/app/models/admissions/form_field.rb b/app/models/admissions/form_field.rb index 5fc73966..5a58fb55 100644 --- a/app/models/admissions/form_field.rb +++ b/app/models/admissions/form_field.rb @@ -213,6 +213,15 @@ def get_values_map(option) result end + def is_file_field? + return true if self.field_type == FILE + if self.field_type == STUDENT_FIELD + config = self.config_hash + return true if config["field"] == "photo" + end + false + end + def self.search_name(field: nil, substring: false) field = "%#{field}%" if field.present? && substring Admissions::FormField.where( diff --git a/app/models/admissions/form_template.rb b/app/models/admissions/form_template.rb index 7e66a747..bdc251c7 100644 --- a/app/models/admissions/form_template.rb +++ b/app/models/admissions/form_template.rb @@ -51,4 +51,8 @@ def initialize_dup(other) super self.fields = other.fields.map(&:dup) end + + def has_file_fields? + fields.any? { |f| f.is_file_field? } + end end diff --git a/app/models/custom_variable.rb b/app/models/custom_variable.rb index ce95da97..4ed0fee1 100644 --- a/app/models/custom_variable.rb +++ b/app/models/custom_variable.rb @@ -7,6 +7,8 @@ class CustomVariable < ApplicationRecord has_paper_trail + SAPOS_MAIL = "sapos@sapos.ic.uff.br" + VARIABLES = { "single_advisor_points" => :text, "multiple_advisor_points" => :text, @@ -14,6 +16,7 @@ class CustomVariable < ApplicationRecord "identity_issuing_country" => :text, "class_schedule_text" => :text, "redirect_email" => :text, + "reply_to" => :text, "notification_footer" => :text, "minimum_grade_for_approval" => :text, "grade_of_disapproval_for_absence" => :text, @@ -59,6 +62,12 @@ def self.redirect_email config.blank? ? nil : (config.value || "") end + def self.reply_to + default = ActionMailer::Base.default[:from] + config = CustomVariable.find_by_variable(:reply_to) + config.blank? ? default : (config.value || default) + end + def self.notification_footer config = CustomVariable.find_by_variable(:notification_footer) config.blank? ? "" : config.value diff --git a/app/models/email_template.rb b/app/models/email_template.rb index dd9244f2..56921ea4 100644 --- a/app/models/email_template.rb +++ b/app/models/email_template.rb @@ -298,6 +298,7 @@ def update_mailer_headers(headers) headers[:to] = CustomVariable.redirect_email headers[:skip_redirect] = true end + headers[:reply_to] = CustomVariable.reply_to headers[:skip_message] = ! self.enabled headers[:skip_footer] = true end diff --git a/app/views/admissions/admission_applications/_custom_forms_form_column.html.erb b/app/views/admissions/admission_applications/_custom_forms_form_column.html.erb index cdf074eb..332aa888 100644 --- a/app/views/admissions/admission_applications/_custom_forms_form_column.html.erb +++ b/app/views/admissions/admission_applications/_custom_forms_form_column.html.erb @@ -1,4 +1,5 @@ <% + @override = false if @override.blank? if @override return "Acesso inválido" if !controller.override_authorized?(record) else @@ -63,12 +64,14 @@ <% end %> + <%= fields_for :record, record, multipart: true do |form| %>