From 12917a775365e0b7146aa958e1733c2b8af44ecb Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 21 May 2022 01:39:39 -0300 Subject: [PATCH 01/37] Ajusta nome do host para evitar conflitos --- config/database.sample.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/database.sample.yml b/config/database.sample.yml index f222a5347..584e3c9bc 100644 --- a/config/database.sample.yml +++ b/config/database.sample.yml @@ -4,7 +4,7 @@ default: &default pool: 5 username: postgres password: postgres - host: localhost + host: postgres-idiario development: <<: *default From 9e968badb352e03362193fc6f133145073c0ddc6 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 21 May 2022 01:40:50 -0300 Subject: [PATCH 02/37] =?UTF-8?q?Remove=20condi=C3=A7=C3=A3o=20do=20script?= =?UTF-8?q?=20para=20rodar=20sempre=20os=20comandos=20e=20cria=20banco=20s?= =?UTF-8?q?eparado=20do=20idiario=5Fdevelopment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/start | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/script/start b/script/start index 5f89487a5..0b0659b9f 100755 --- a/script/start +++ b/script/start @@ -4,25 +4,23 @@ bundle check || BUNDLE_JOBS=4 bundle install yarn install -if ! test -f ".setup"; then - echo -e " - development: - secret_key_base: `bundle exec rake secret` - redis_url: redis://redis-idiario - " > config/secrets.yml +echo -e " +development: + secret_key_base: `bundle exec rake secret` + redis_url: redis://redis-idiario + " > config/secrets.yml - cp config/database.sample.yml config/database.yml +cp config/database.sample.yml config/database.yml - bundle exec rake db:create - bundle exec rake db:migrate - bundle exec rake entity:setup NAME=prefeitura DOMAIN=localhost DATABASE=prefeitura_diario - bundle exec rake entity:admin:create NAME=prefeitura ADMIN_PASSWORD=123456789 +bundle exec rake db:create +bundle exec rake db:migrate +bundle exec rake entity:setup NAME=prefeitura DOMAIN=localhost DATABASE=idiario +bundle exec rake entity:admin:create NAME=prefeitura ADMIN_PASSWORD=A123456789$ - cp public/404.html.sample public/404.html - cp public/500.html.sample public/500.html +cp public/404.html.sample public/404.html +cp public/500.html.sample public/500.html - touch .setup -fi +touch .setup rm -f /app/tmp/pids/server.pid From a464be9f260ee7eb4871b9bf7a83d0d62dcdf0a0 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 21 May 2022 01:41:30 -0300 Subject: [PATCH 03/37] Ajusta readme com senha nova --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50e2bd47b..2cc4ecbaa 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ idiario | Use Ctrl-C to stop ``` Você poderá acessar o i-Diário na URL [http://localhost:3000](http://localhost:3000) com o login `admin` e a senha -`123456789`. +`A123456789$`. #### Personalizando a instalação via Docker From 42283337a21a50e63a549397674d2a5257ac717d Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 24 May 2022 20:47:19 -0300 Subject: [PATCH 04/37] =?UTF-8?q?Adiciona=20if=20novamente=20caso=20ambien?= =?UTF-8?q?te=20j=C3=A1=20tenha=20sido=20criado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/start | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/script/start b/script/start index 0b0659b9f..f4ad812af 100755 --- a/script/start +++ b/script/start @@ -4,23 +4,25 @@ bundle check || BUNDLE_JOBS=4 bundle install yarn install -echo -e " -development: - secret_key_base: `bundle exec rake secret` - redis_url: redis://redis-idiario - " > config/secrets.yml +if ! test -f ".setup"; then + echo -e " + development: + secret_key_base: `bundle exec rake secret` + redis_url: redis://redis-idiario + " > config/secrets.yml -cp config/database.sample.yml config/database.yml + cp config/database.sample.yml config/database.yml -bundle exec rake db:create -bundle exec rake db:migrate -bundle exec rake entity:setup NAME=prefeitura DOMAIN=localhost DATABASE=idiario -bundle exec rake entity:admin:create NAME=prefeitura ADMIN_PASSWORD=A123456789$ + bundle exec rake db:create + bundle exec rake db:migrate + bundle exec rake entity:setup NAME=prefeitura DOMAIN=localhost DATABASE=idiario + bundle exec rake entity:admin:create NAME=prefeitura ADMIN_PASSWORD=A123456789$ -cp public/404.html.sample public/404.html -cp public/500.html.sample public/500.html + cp public/404.html.sample public/404.html + cp public/500.html.sample public/500.html -touch .setup + touch .setup +fi rm -f /app/tmp/pids/server.pid From de86e9aff5544f6ee7e9ab10bdc9b0780ec7e2da Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 20 Dec 2022 14:07:40 -0300 Subject: [PATCH 05/37] =?UTF-8?q?Cria=20migration=20de=20novo=20par=C3=A2m?= =?UTF-8?q?etro=20na=20tela=20de=20configura=C3=A7=C3=B5es=20gerais?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ss_number_on_content_records_to_general_configurations.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/migrate/20221220170255_add_allow_class_number_on_content_records_to_general_configurations.rb diff --git a/db/migrate/20221220170255_add_allow_class_number_on_content_records_to_general_configurations.rb b/db/migrate/20221220170255_add_allow_class_number_on_content_records_to_general_configurations.rb new file mode 100644 index 000000000..4ef7ace8a --- /dev/null +++ b/db/migrate/20221220170255_add_allow_class_number_on_content_records_to_general_configurations.rb @@ -0,0 +1,5 @@ +class AddAllowClassNumberOnContentRecordsToGeneralConfigurations < ActiveRecord::Migration + def change + add_column :general_configurations, :allow_class_number_on_content_records, :boolean, default: false + end +end From 55bb845bd0b97d32bab3839f9cf24a4fb2ee1936 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 20 Dec 2022 15:43:24 -0300 Subject: [PATCH 06/37] =?UTF-8?q?Permite=20habilitar=20checkbox=20de=20aul?= =?UTF-8?q?as=20no=20registro=20de=20conte=C3=BAdos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/general_configurations_controller.rb | 3 ++- app/views/general_configurations/edit.html.erb | 5 +++++ config/locales/models/general_configuration.yml | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/general_configurations_controller.rb b/app/controllers/general_configurations_controller.rb index b201241aa..e7aaf6647 100644 --- a/app/controllers/general_configurations_controller.rb +++ b/app/controllers/general_configurations_controller.rb @@ -54,7 +54,8 @@ def permitted_attributes :days_to_expire_password, :days_to_disable_access, :show_inactive_enrollments, - :show_percentage_on_attendance_record_report + :show_percentage_on_attendance_record_report, + :allow_class_number_on_content_records ) parameters[:types_of_teaching] = parameters[:types_of_teaching].split(',') diff --git a/app/views/general_configurations/edit.html.erb b/app/views/general_configurations/edit.html.erb index d5c25c28f..156792244 100644 --- a/app/views/general_configurations/edit.html.erb +++ b/app/views/general_configurations/edit.html.erb @@ -85,6 +85,11 @@ <%= f.input :type_of_teaching, as: :boolean, label: false, inline_label: true %> +
+
+ <%= f.input :allow_class_number_on_content_records, as: :boolean, label: false, inline_label: true %> +
+
diff --git a/config/locales/models/general_configuration.yml b/config/locales/models/general_configuration.yml index 01f037617..9301eeab5 100644 --- a/config/locales/models/general_configuration.yml +++ b/config/locales/models/general_configuration.yml @@ -31,6 +31,7 @@ pt-BR: days_to_disable_access: "Quantidade de dias permitidos sem acessar o sistema para inativação automática de usuário" show_inactive_enrollments: "Apresentar enturmações inativas de alunos(as) nas telas de lançamento e relatórios (avaliação e frequência)" show_percentage_on_attendance_record_report: "Exibir frequência em porcentagem no Registro de frequência" + allow_class_number_on_content_records: "Permitir informar número de aula no Registro de conteúdos?" backup: completed: "Exportação de dados realizada com sucesso! Clique %{link} para fazer download!" error: "Exportação de dados não pode ser realizada. Favor tentar novamente." From 2174644b45fd2c79a6ce5839ace9426a3459b5a9 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 20 Dec 2022 17:28:59 -0300 Subject: [PATCH 07/37] =?UTF-8?q?Valida=20disciplina=20apenas=20se=20n?= =?UTF-8?q?=C3=A3o=20for=20permitido=20setar=20n=C3=BAmero=20de=20aulas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/discipline_content_record.rb | 6 +++++- app/services/create_multiple_contents.rb | 0 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 app/services/create_multiple_contents.rb diff --git a/app/models/discipline_content_record.rb b/app/models/discipline_content_record.rb index 26c04b41f..a53d5c157 100644 --- a/app/models/discipline_content_record.rb +++ b/app/models/discipline_content_record.rb @@ -44,7 +44,7 @@ class DisciplineContentRecord < ActiveRecord::Base validates :content_record, presence: true validates :discipline, presence: true - validate :uniqueness_of_discipline_content_record + validate :uniqueness_of_discipline_content_record if :not_allow_class_number? validate :ensure_is_school_day delegate :contents, :record_date, :classroom, to: :content_record @@ -52,6 +52,10 @@ class DisciplineContentRecord < ActiveRecord::Base private + def not_allow_class_number? + !GeneralConfiguration.first.allow_class_number_on_content_records + end + def valid_for_destruction? @valid_for_destruction if defined?(@valid_for_destruction) @valid_for_destruction = begin diff --git a/app/services/create_multiple_contents.rb b/app/services/create_multiple_contents.rb new file mode 100644 index 000000000..e69de29bb From 7aecb7fead95373f4b45cc017fabf4011e85c122 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 20 Dec 2022 18:21:13 -0300 Subject: [PATCH 08/37] =?UTF-8?q?Adiciona=20n=C3=BAmero=20de=20aula=20ao?= =?UTF-8?q?=20registro=20de=20conte=C3=BAdo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221220165443_add_class_number_to_content_record.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/migrate/20221220165443_add_class_number_to_content_record.rb diff --git a/db/migrate/20221220165443_add_class_number_to_content_record.rb b/db/migrate/20221220165443_add_class_number_to_content_record.rb new file mode 100644 index 000000000..1fb5453be --- /dev/null +++ b/db/migrate/20221220165443_add_class_number_to_content_record.rb @@ -0,0 +1,5 @@ +class AddClassNumberToContentRecord < ActiveRecord::Migration + def change + add_column :content_records, :class_number, :integer, default: nil + end +end From ea9b905c5002dd9c29effa3ea70e7c4622f37ed9 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 20 Dec 2022 18:35:07 -0300 Subject: [PATCH 09/37] =?UTF-8?q?Ajusta=20tradu=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/models/content_record.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/models/content_record.yml b/config/locales/models/content_record.yml index 4cfd20a5c..8bee68fa0 100644 --- a/config/locales/models/content_record.yml +++ b/config/locales/models/content_record.yml @@ -15,6 +15,7 @@ pt-BR: daily_activities_record: "Registro diário das atividades" contents: "Conteúdos" contents_tags: "Adicionar novo" + class_number: "Aula" errors: models: content_record: From cfd0c22f3c1b41edb9c1788365d32e4dd76432b4 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 20 Dec 2022 18:35:36 -0300 Subject: [PATCH 10/37] =?UTF-8?q?Adiciona=20valida=C3=A7=C3=A3o=20de=20n?= =?UTF-8?q?=C3=BAmero=20de=20aulas=20caso=20utilize=20a=20configura=C3=A7?= =?UTF-8?q?=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/content_record.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/content_record.rb b/app/models/content_record.rb index 07a1b6aaf..d936024a4 100644 --- a/app/models/content_record.rb +++ b/app/models/content_record.rb @@ -31,12 +31,17 @@ class ContentRecord < ActiveRecord::Base validates :record_date, presence: true, school_calendar_day: true, posting_date: true validates :teacher, presence: true validate :at_least_one_content + validates :class_number, uniqueness: true, allow_blank: true if :allow_class_number? delegate :grades, :grade_ids, :first_grade, to: :classroom scope :by_unity_id, lambda { |unity_id| joins(:classroom).merge(Classroom.by_unity(unity_id)) } scope :by_teacher_id, lambda { |teacher_id| where(teacher_id: teacher_id) } + def allow_class_number? + GeneralConfiguration.first.allow_class_number_on_content_records + end + def to_s return discipline_content_record.discipline.to_s if discipline_content_record return knowledge_area_content_record.knowledge_areas.first.to_s if knowledge_area_content_record From a12f909cbc43d96ec388de0b72e6292a273cd4cb Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 20 Dec 2022 18:49:30 -0300 Subject: [PATCH 11/37] Ajusta migration --- db/migrate/20221220165443_add_class_number_to_content_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20221220165443_add_class_number_to_content_record.rb b/db/migrate/20221220165443_add_class_number_to_content_record.rb index 1fb5453be..b395235f2 100644 --- a/db/migrate/20221220165443_add_class_number_to_content_record.rb +++ b/db/migrate/20221220165443_add_class_number_to_content_record.rb @@ -1,5 +1,5 @@ class AddClassNumberToContentRecord < ActiveRecord::Migration def change - add_column :content_records, :class_number, :integer, default: nil + add_column :content_records, :class_number, :integer, default: 0 end end From 2a2a1a7ab86236b9e0ab6b24bf6a09caa974b8bc Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Wed, 21 Dec 2022 16:06:06 -0300 Subject: [PATCH 12/37] =?UTF-8?q?Ajusta=20valida=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/content_record.rb | 2 +- app/models/discipline_content_record.rb | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/content_record.rb b/app/models/content_record.rb index d936024a4..b778ec1b8 100644 --- a/app/models/content_record.rb +++ b/app/models/content_record.rb @@ -31,7 +31,7 @@ class ContentRecord < ActiveRecord::Base validates :record_date, presence: true, school_calendar_day: true, posting_date: true validates :teacher, presence: true validate :at_least_one_content - validates :class_number, uniqueness: true, allow_blank: true if :allow_class_number? + validates :class_number, uniqueness: true, presence: true if :allow_class_number? delegate :grades, :grade_ids, :first_grade, to: :classroom diff --git a/app/models/discipline_content_record.rb b/app/models/discipline_content_record.rb index a53d5c157..f4b151146 100644 --- a/app/models/discipline_content_record.rb +++ b/app/models/discipline_content_record.rb @@ -44,7 +44,7 @@ class DisciplineContentRecord < ActiveRecord::Base validates :content_record, presence: true validates :discipline, presence: true - validate :uniqueness_of_discipline_content_record if :not_allow_class_number? + validate :uniqueness_of_discipline_content_record validate :ensure_is_school_day delegate :contents, :record_date, :classroom, to: :content_record @@ -52,8 +52,8 @@ class DisciplineContentRecord < ActiveRecord::Base private - def not_allow_class_number? - !GeneralConfiguration.first.allow_class_number_on_content_records + def allow_class_number? + GeneralConfiguration.first.allow_class_number_on_content_records end def valid_for_destruction? @@ -72,6 +72,7 @@ def valid_for_destruction? end def uniqueness_of_discipline_content_record + return if allow_class_number? return unless content_record.present? && content_record.classroom.present? && content_record.record_date.present? discipline_content_records = DisciplineContentRecord.by_teacher_id(content_record.teacher_id) From ee15cade28f25af71540c6b8eb9bdcb9ce6c8181 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Wed, 21 Dec 2022 16:06:56 -0300 Subject: [PATCH 13/37] Ajusta views para trabalhar com os dois formatos --- app/views/discipline_content_records/_form.html.erb | 9 +++++++++ .../discipline_content_records/_resources.html.erb | 5 +++++ app/views/discipline_content_records/index.html.erb | 12 +++++++++++- app/views/discipline_content_records/show.html.erb | 9 +++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/views/discipline_content_records/_form.html.erb b/app/views/discipline_content_records/_form.html.erb index 31993fccf..a4778d678 100644 --- a/app/views/discipline_content_records/_form.html.erb +++ b/app/views/discipline_content_records/_form.html.erb @@ -31,6 +31,15 @@
<%= content_record.input :record_date, as: :date %>
+ + <% if @allow_class_number %> +
+ <%= content_record.input :class_number, as: :select2, multiple: true, + elements: number_of_classes_elements(@number_of_classes), + placeholder: 'Selecione uma ou mais aulas', + disabled: action_name == 'new' || 'create' ? false : true %> +
+ <% end %>
diff --git a/app/views/discipline_content_records/_resources.html.erb b/app/views/discipline_content_records/_resources.html.erb index ae2f507f8..c56ae0df6 100644 --- a/app/views/discipline_content_records/_resources.html.erb +++ b/app/views/discipline_content_records/_resources.html.erb @@ -10,6 +10,11 @@ <%= discipline_content_record.discipline %> <%= l(discipline_content_record.content_record.record_date) %> <%= discipline_content_record.content_record.decorator.author(current_teacher) %> + + <% if @allow_class_number %> + <%= discipline_content_record.content_record.class_number %> + <% end %> + <%= link_to( t('helpers.links.copy_html'), diff --git a/app/views/discipline_content_records/index.html.erb b/app/views/discipline_content_records/index.html.erb index 1e7f5aeca..563bc387f 100644 --- a/app/views/discipline_content_records/index.html.erb +++ b/app/views/discipline_content_records/index.html.erb @@ -13,6 +13,11 @@ <%= f.input :by_author, as: :select2_plans, label: false %> + + <% if @allow_class_number %> + + <% end %> + <%= link_to t('.new_html'), new_discipline_content_record_path, class: 'btn btn-primary pull-right', style: 'width: 165px;' %> @@ -24,6 +29,11 @@ <%= DisciplineContentRecord.human_attribute_name :discipline %> <%= ContentRecord.human_attribute_name :record_date %> <%= DisciplineContentRecord.human_attribute_name :author %> + + <% if @allow_class_number %> + <%= ContentRecord.human_attribute_name :class_number %> + <% end %> + @@ -31,7 +41,7 @@ <%= render 'resources' %> - + <%= render 'shared/pagination', records: @discipline_content_records %> diff --git a/app/views/discipline_content_records/show.html.erb b/app/views/discipline_content_records/show.html.erb index 4d030dfaf..bc734f733 100644 --- a/app/views/discipline_content_records/show.html.erb +++ b/app/views/discipline_content_records/show.html.erb @@ -26,6 +26,15 @@
<%= content_record.input :record_date, as: :date, readonly: true %>
+ + <% if @allow_class_number %> +
+ <%= content_record.input :class_number, as: :select2, multiple: true, + elements: number_of_classes_elements(@number_of_classes), + placeholder: 'Selecione uma ou mais aulas', + disabled: action_name == 'new' ? false : true %> +
+ <% end %>
From 5b0c88b34f2ced85abbff740c9f831df6e6f57a0 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Wed, 21 Dec 2022 19:25:57 -0300 Subject: [PATCH 14/37] =?UTF-8?q?Cria=20servi=C3=A7o=20que=20ir=C3=A1=20du?= =?UTF-8?q?plicar=20os=20conte=C3=BAdos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/create_multiple_contents.rb | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/services/create_multiple_contents.rb b/app/services/create_multiple_contents.rb index e69de29bb..dffb39399 100644 --- a/app/services/create_multiple_contents.rb +++ b/app/services/create_multiple_contents.rb @@ -0,0 +1,25 @@ +class CreateMultipleContents + attr_accessor :lessons_to_create, :base_content + + def initialize(lessons_to_create, base_content) + @lessons_to_create = lessons_to_create + @base_content = base_content + end + + def call + create_multiple + end + + private + + def create_multiple + ActiveRecord::Base.transaction do + lessons_to_create.each do |class_number| + discipline_content = base_content.dup + discipline_content.content_record = base_content.content_record.dup + discipline_content.content_record.class_number = class_number + discipline_content.save + end + end + end +end From 30dc2456f64dd6dc9880906c3f15f18329e75dd8 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Wed, 21 Dec 2022 19:27:02 -0300 Subject: [PATCH 15/37] Adapta controller para novo funcionamento --- .../discipline_content_records_controller.rb | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/app/controllers/discipline_content_records_controller.rb b/app/controllers/discipline_content_records_controller.rb index 140225152..f9ec5067f 100644 --- a/app/controllers/discipline_content_records_controller.rb +++ b/app/controllers/discipline_content_records_controller.rb @@ -4,6 +4,8 @@ class DisciplineContentRecordsController < ApplicationController before_action :require_current_teacher before_action :require_allow_to_modify_prev_years, only: [:create, :update, :destroy, :clone] + before_action :set_number_of_classes, only: [:new, :create, :edit, :show] + before_action :allow_class_number, only: [:index, :new, :edit, :show] def index params[:filter] ||= {} @@ -38,6 +40,7 @@ def new record_date: Time.zone.now, unity_id: current_unity.id ) + @class_numbers = [] authorize @discipline_content_record end @@ -52,10 +55,31 @@ def create authorize @discipline_content_record - if @discipline_content_record.save - respond_with @discipline_content_record, location: discipline_content_records_path + if allow_class_number + @class_numbers = resource_params[:content_record_attributes][:class_number].split(',').sort + @discipline_content_record.content_record.class_number = @class_numbers.first + + @class_numbers.each do |class_number| + @discipline_content_record.content_record.class_number = class_number + + return render :new if @discipline_content_record.invalid? + end + + multiple_content_creator = CreateMultipleContents.new(@class_numbers, @discipline_content_record) + + if multiple_content_creator.call + respond_with @discipline_content_record, location: discipline_content_records_path + else + render :new + end else - render :new + if @discipline_content_record.save + return unless validate_class_numbers + + respond_with @discipline_content_record, location: discipline_content_records_path + else + render :new + end end end @@ -110,6 +134,24 @@ def clone private + def allow_class_number + @allow_class_number ||= GeneralConfiguration.first.allow_class_number_on_content_records + end + + def set_number_of_classes + @number_of_classes = current_school_calendar.number_of_classes + end + + def validate_class_numbers + return true unless allow_class_number + return true if @class_numbers.present? + + @error_on_class_numbers = true + flash.now[:alert] = t('errors.daily_frequencies.class_numbers_required_when_not_global_absence') + + false + end + def content_ids param_content_ids = params[:discipline_content_record][:content_record_attributes][:content_ids] || [] content_descriptions = params[:discipline_content_record][:content_record_attributes][:content_descriptions] || [] @@ -125,6 +167,7 @@ def resource_params :unity_id, :classroom_id, :record_date, + :class_number, :daily_activities_record, :content_ids ] From a37f018e62e99abed0100fdb4ac571d2e2be222a Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Wed, 21 Dec 2022 19:52:08 -0300 Subject: [PATCH 16/37] =?UTF-8?q?Ajusta=20tela=20de=20edi=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/discipline_content_records/_form.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/discipline_content_records/_form.html.erb b/app/views/discipline_content_records/_form.html.erb index a4778d678..109c45f86 100644 --- a/app/views/discipline_content_records/_form.html.erb +++ b/app/views/discipline_content_records/_form.html.erb @@ -34,10 +34,11 @@ <% if @allow_class_number %>
+ <% show_classes = action_name == ('new' || 'create') ? false : true %> <%= content_record.input :class_number, as: :select2, multiple: true, elements: number_of_classes_elements(@number_of_classes), placeholder: 'Selecione uma ou mais aulas', - disabled: action_name == 'new' || 'create' ? false : true %> + disabled: show_classes %>
<% end %>
From 6638e5338360bd2e13cacdf6ec4dcfab95c1c841 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Wed, 21 Dec 2022 20:05:30 -0300 Subject: [PATCH 17/37] =?UTF-8?q?Ajusta=20valida=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/content_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/content_record.rb b/app/models/content_record.rb index b778ec1b8..d7a2d845e 100644 --- a/app/models/content_record.rb +++ b/app/models/content_record.rb @@ -31,7 +31,7 @@ class ContentRecord < ActiveRecord::Base validates :record_date, presence: true, school_calendar_day: true, posting_date: true validates :teacher, presence: true validate :at_least_one_content - validates :class_number, uniqueness: true, presence: true if :allow_class_number? + validates :class_number, uniqueness: true, presence: true, if: -> { allow_class_number? } delegate :grades, :grade_ids, :first_grade, to: :classroom From c86ce1cace53fd33e085a2b2028af2f52542c230 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Wed, 21 Dec 2022 20:19:50 -0300 Subject: [PATCH 18/37] =?UTF-8?q?Ajusta=20configura=C3=A7=C3=A3o=20de=20ba?= =?UTF-8?q?nco=20de=20dados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/database.sample.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/database.sample.yml b/config/database.sample.yml index 584e3c9bc..f222a5347 100644 --- a/config/database.sample.yml +++ b/config/database.sample.yml @@ -4,7 +4,7 @@ default: &default pool: 5 username: postgres password: postgres - host: postgres-idiario + host: localhost development: <<: *default From 8d30b3bd45cd30f762775f776f60169029430a0b Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Wed, 1 Mar 2023 22:16:00 -0300 Subject: [PATCH 19/37] =?UTF-8?q?Ajusta=20valida=C3=A7=C3=A3o=20composta?= =?UTF-8?q?=20para=20n=C3=BAmero=20de=20aula/turma/professor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/general_configurations_controller.rb | 2 +- app/models/content_record.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/general_configurations_controller.rb b/app/controllers/general_configurations_controller.rb index c8c524018..a01cbfea5 100644 --- a/app/controllers/general_configurations_controller.rb +++ b/app/controllers/general_configurations_controller.rb @@ -55,7 +55,7 @@ def permitted_attributes :days_to_disable_access, :show_inactive_enrollments, :show_percentage_on_attendance_record_report, - :allow_class_number_on_content_records + :allow_class_number_on_content_records, :require_daily_activities_record ) diff --git a/app/models/content_record.rb b/app/models/content_record.rb index 40cdedab2..47ed21591 100644 --- a/app/models/content_record.rb +++ b/app/models/content_record.rb @@ -34,7 +34,8 @@ class ContentRecord < ActiveRecord::Base validates :daily_activities_record, presence: true, if: :require_daily_activities_record? validates :teacher, presence: true validate :at_least_one_content - validates :class_number, uniqueness: true, presence: true, if: -> { allow_class_number? } + validates_uniqueness_of :class_number, scope: [:classroom, :teacher] + validates :class_number, presence: true, if: -> { allow_class_number? } delegate :grades, :grade_ids, :first_grade, to: :classroom From 40ce3ba349409b5a672c64f1d05bb7c0517edde9 Mon Sep 17 00:00:00 2001 From: Marcos Oliveira Soares Date: Thu, 2 Mar 2023 00:07:37 -0300 Subject: [PATCH 20/37] add :record_date in validates_uniqueness_of --- app/models/content_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/content_record.rb b/app/models/content_record.rb index 47ed21591..1034f34a2 100644 --- a/app/models/content_record.rb +++ b/app/models/content_record.rb @@ -34,7 +34,7 @@ class ContentRecord < ActiveRecord::Base validates :daily_activities_record, presence: true, if: :require_daily_activities_record? validates :teacher, presence: true validate :at_least_one_content - validates_uniqueness_of :class_number, scope: [:classroom, :teacher] + validates_uniqueness_of :class_number, scope: [:classroom, :teacher, :record_date] validates :class_number, presence: true, if: -> { allow_class_number? } delegate :grades, :grade_ids, :first_grade, to: :classroom From 3b37b5eed6b7c86e01b62bcfd25accfee74c052c Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Fri, 3 Mar 2023 22:39:56 -0300 Subject: [PATCH 21/37] =?UTF-8?q?Ajusta=20recupera=C3=A7=C3=A3o=20de=20eta?= =?UTF-8?q?pas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../school_term_recovery_diary_records_controller.rb | 6 ++++-- app/services/steps_fetcher.rb | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/school_term_recovery_diary_records_controller.rb b/app/controllers/school_term_recovery_diary_records_controller.rb index 3aa0df197..69239c813 100644 --- a/app/controllers/school_term_recovery_diary_records_controller.rb +++ b/app/controllers/school_term_recovery_diary_records_controller.rb @@ -36,8 +36,9 @@ def new @school_term_recovery_diary_record = SchoolTermRecoveryDiaryRecord.new.localized @school_term_recovery_diary_record.build_recovery_diary_record @school_term_recovery_diary_record.recovery_diary_record.unity = current_unity + current_year_last_step = StepsFetcher.new(current_user_classroom).last_step_by_year - if current_test_setting.blank? + if current_test_setting.blank? && current_year_last_step.blank? flash[:error] = t('errors.avaliations.require_setting') redirect_to(school_term_recovery_diary_records_path) @@ -45,7 +46,8 @@ def new return if performed? - @number_of_decimal_places = current_test_setting.number_of_decimal_places + @number_of_decimal_places = current_test_setting&.number_of_decimal_places || + current_test_setting_step(current_year_last_step)&.number_of_decimal_places end def create diff --git a/app/services/steps_fetcher.rb b/app/services/steps_fetcher.rb index a827329b1..9f84c9749 100644 --- a/app/services/steps_fetcher.rb +++ b/app/services/steps_fetcher.rb @@ -29,6 +29,13 @@ def step_by_id(step_id) school_calendar_steps.find_by(id: step_id) end + def last_step_by_year + return if school_calendar.blank? + + school_calendar_steps.last + end + + def current_step step_by_date(Date.current) end From 4e9f1cf0aab050811b522058ef03cfd1247f802f Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Fri, 3 Mar 2023 22:42:39 -0300 Subject: [PATCH 22/37] =?UTF-8?q?Ajusta=20relat=C3=B3rio=20de=20notas=20pa?= =?UTF-8?q?rciais=20e=20registro=20de=20avalia=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/partial_score_record_report_controller.rb | 2 +- app/reports/exam_record_report.rb | 2 +- app/services/score_rounder.rb | 5 +++-- app/services/student_average_calculator.rb | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/partial_score_record_report_controller.rb b/app/controllers/partial_score_record_report_controller.rb index 439631428..49ede99aa 100644 --- a/app/controllers/partial_score_record_report_controller.rb +++ b/app/controllers/partial_score_record_report_controller.rb @@ -16,7 +16,7 @@ def report @partial_score_record_report_form.students, @partial_score_record_report_form.unity, @partial_score_record_report_form.classroom, - current_test_setting) + current_test_setting_step(@partial_score_record_report_form.step)) send_pdf(t("routes.partial_score_record"), partial_score_record_report.render) else @partial_score_record_report_form.school_calendar_year = current_school_calendar.year diff --git a/app/reports/exam_record_report.rb b/app/reports/exam_record_report.rb index badf9ef57..40bc08016 100644 --- a/app/reports/exam_record_report.rb +++ b/app/reports/exam_record_report.rb @@ -278,7 +278,7 @@ def daily_notes_table recovery_average = SchoolTermAverageCalculator.new(classroom) .calculate(averages[key], recovery_score) - averages[key] = ScoreRounder.new(classroom, RoundedAvaliations::SCHOOL_TERM_RECOVERY) + averages[key] = ScoreRounder.new(classroom, RoundedAvaliations::SCHOOL_TERM_RECOVERY, @school_calendar_step) .round(recovery_average) average = averages[key] diff --git a/app/services/score_rounder.rb b/app/services/score_rounder.rb index dab1f56fa..26c48f3a2 100644 --- a/app/services/score_rounder.rb +++ b/app/services/score_rounder.rb @@ -1,7 +1,8 @@ class ScoreRounder - def initialize(classroom, rounded_avaliation) + def initialize(classroom, rounded_avaliation, step = nil) @classroom = classroom @rounded_avaliation = rounded_avaliation + @step = step end def round(score) @@ -74,7 +75,7 @@ def round_to_below(score) end def number_of_decimal_places - TestSettingFetcher.current(@classroom).number_of_decimal_places + TestSettingFetcher.current(@classroom, @step).number_of_decimal_places end def truncate_score(score) diff --git a/app/services/student_average_calculator.rb b/app/services/student_average_calculator.rb index 7b6761966..3fe7367bf 100644 --- a/app/services/student_average_calculator.rb +++ b/app/services/student_average_calculator.rb @@ -26,7 +26,7 @@ def calculate(classroom, discipline, step) step ).calculate(result) - ScoreRounder.new(classroom, RoundedAvaliations::NUMERICAL_EXAM).round(result) + ScoreRounder.new(classroom, RoundedAvaliations::NUMERICAL_EXAM, step).round(result) end private From c0a75d69cd0bddaf303e96e0412e00d653d6b9b1 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Fri, 3 Mar 2023 22:43:38 -0300 Subject: [PATCH 23/37] =?UTF-8?q?Adiciona=20v=C3=ADrgula=20faltante?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/general_configurations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/general_configurations_controller.rb b/app/controllers/general_configurations_controller.rb index c8c524018..a01cbfea5 100644 --- a/app/controllers/general_configurations_controller.rb +++ b/app/controllers/general_configurations_controller.rb @@ -55,7 +55,7 @@ def permitted_attributes :days_to_disable_access, :show_inactive_enrollments, :show_percentage_on_attendance_record_report, - :allow_class_number_on_content_records + :allow_class_number_on_content_records, :require_daily_activities_record ) From 59c6a32f7d78a99c9548b67ab86e13bc65d7d4ee Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 4 Mar 2023 00:37:22 -0300 Subject: [PATCH 24/37] Ajusta envio --- app/services/exam_poster/numerical_exam_poster.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/exam_poster/numerical_exam_poster.rb b/app/services/exam_poster/numerical_exam_poster.rb index 6a9380ef9..6a5445311 100644 --- a/app/services/exam_poster/numerical_exam_poster.rb +++ b/app/services/exam_poster/numerical_exam_poster.rb @@ -52,7 +52,7 @@ def post_by_classrooms teacher_discipline_classrooms.each do |teacher_discipline_classroom| classroom = teacher_discipline_classroom.classroom discipline = teacher_discipline_classroom.discipline - score_rounder = ScoreRounder.new(classroom, RoundedAvaliations::SCHOOL_TERM_RECOVERY) + score_rounder = ScoreRounder.new(classroom, RoundedAvaliations::SCHOOL_TERM_RECOVERY, get_step(classroom)) next unless can_post?(classroom) From 39ffc06ff2f845231673d9005c1a575fc5d6a97f Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 4 Mar 2023 00:43:53 -0300 Subject: [PATCH 25/37] Utiliza colspan --- app/views/discipline_content_records/index.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/discipline_content_records/index.html.erb b/app/views/discipline_content_records/index.html.erb index 563bc387f..63f9540a4 100644 --- a/app/views/discipline_content_records/index.html.erb +++ b/app/views/discipline_content_records/index.html.erb @@ -28,13 +28,13 @@ <%= ContentRecord.human_attribute_name :classroom %> <%= DisciplineContentRecord.human_attribute_name :discipline %> <%= ContentRecord.human_attribute_name :record_date %> - <%= DisciplineContentRecord.human_attribute_name :author %> + <%= DisciplineContentRecord.human_attribute_name :author %> <% if @allow_class_number %> - <%= ContentRecord.human_attribute_name :class_number %> + <%= ContentRecord.human_attribute_name :class_number %> <% end %> - + From ccb34254469de2ccf8c3645c8ba1e435c63347c5 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 4 Mar 2023 00:49:08 -0300 Subject: [PATCH 26/37] Seta id para atributos --- app/views/discipline_content_records/index.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/discipline_content_records/index.html.erb b/app/views/discipline_content_records/index.html.erb index 63f9540a4..028a52215 100644 --- a/app/views/discipline_content_records/index.html.erb +++ b/app/views/discipline_content_records/index.html.erb @@ -28,13 +28,13 @@ <%= ContentRecord.human_attribute_name :classroom %> <%= DisciplineContentRecord.human_attribute_name :discipline %> <%= ContentRecord.human_attribute_name :record_date %> - <%= DisciplineContentRecord.human_attribute_name :author %> + <%= DisciplineContentRecord.human_attribute_name :author %> <% if @allow_class_number %> - <%= ContentRecord.human_attribute_name :class_number %> + <%= ContentRecord.human_attribute_name :class_number %> <% end %> - + From c24c13ac2938390618a73786f31ec77e57880090 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 4 Mar 2023 00:56:32 -0300 Subject: [PATCH 27/37] Ajusta styles --- app/views/discipline_content_records/index.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/discipline_content_records/index.html.erb b/app/views/discipline_content_records/index.html.erb index 028a52215..d3cc02a2a 100644 --- a/app/views/discipline_content_records/index.html.erb +++ b/app/views/discipline_content_records/index.html.erb @@ -28,13 +28,13 @@ <%= ContentRecord.human_attribute_name :classroom %> <%= DisciplineContentRecord.human_attribute_name :discipline %> <%= ContentRecord.human_attribute_name :record_date %> - <%= DisciplineContentRecord.human_attribute_name :author %> + <%= DisciplineContentRecord.human_attribute_name :author %> <% if @allow_class_number %> - <%= ContentRecord.human_attribute_name :class_number %> + <%= ContentRecord.human_attribute_name :class_number %> <% end %> - + From ee1e7aabe783cb9ace9c17aff39d3c91a6872b16 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 4 Mar 2023 12:00:27 -0300 Subject: [PATCH 28/37] =?UTF-8?q?Ajusta=20edi=C3=A7=C3=A3o=20de=20recupera?= =?UTF-8?q?=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../school_term_recovery_diary_records_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/school_term_recovery_diary_records_controller.rb b/app/controllers/school_term_recovery_diary_records_controller.rb index 69239c813..5d695136c 100644 --- a/app/controllers/school_term_recovery_diary_records_controller.rb +++ b/app/controllers/school_term_recovery_diary_records_controller.rb @@ -70,7 +70,8 @@ def create def edit @school_term_recovery_diary_record = SchoolTermRecoveryDiaryRecord.find(params[:id]).localized step_number = @school_term_recovery_diary_record.step_number - @school_term_recovery_diary_record.step_id = steps_fetcher.step(step_number).try(:id) + step = steps_fetcher.step(step_number) + @school_term_recovery_diary_record.step_id = step.try(:id) if @school_term_recovery_diary_record.step_id.blank? recorded_at = @school_term_recovery_diary_record.recorded_at @@ -89,7 +90,8 @@ def edit add_missing_students(students_in_recovery) @any_student_exempted_from_discipline = any_student_exempted_from_discipline? - @number_of_decimal_places = current_test_setting.number_of_decimal_places + @number_of_decimal_places = current_test_setting&.number_of_decimal_places || + current_test_setting_step(step)&.number_of_decimal_places end def update From 4e4b29cd5f427639537c716b4f4e824774b374ec Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 4 Mar 2023 22:36:51 -0300 Subject: [PATCH 29/37] =?UTF-8?q?Ajusta=20envio=20de=20recupera=C3=A7?= =?UTF-8?q?=C3=A3o=20final?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/exam_poster/final_recovery_poster.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/exam_poster/final_recovery_poster.rb b/app/services/exam_poster/final_recovery_poster.rb index af3b2cbe6..a0f00dbb8 100644 --- a/app/services/exam_poster/final_recovery_poster.rb +++ b/app/services/exam_poster/final_recovery_poster.rb @@ -45,7 +45,8 @@ def build_params discipline_api_code = final_recovery_diary_record.recovery_diary_record.discipline.api_code score_rounder = ScoreRounder.new( final_recovery_diary_record.recovery_diary_record.classroom, - RoundedAvaliations::FINAL_RECOVERY + RoundedAvaliations::FINAL_RECOVERY, + get_step(teacher_discipline_classroom.classroom) ) final_recovery_diary_record.recovery_diary_record.students.each do |recovery_diary_record_student| From 0adb84ce58e02d2aca0d91d64c07c5ce7eedc430 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sun, 5 Mar 2023 22:52:13 -0300 Subject: [PATCH 30/37] Ajusta estrutura --- app/services/exam_poster/final_recovery_poster.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/services/exam_poster/final_recovery_poster.rb b/app/services/exam_poster/final_recovery_poster.rb index a0f00dbb8..b32bcdee9 100644 --- a/app/services/exam_poster/final_recovery_poster.rb +++ b/app/services/exam_poster/final_recovery_poster.rb @@ -37,20 +37,22 @@ def build_params end final_recovery_diary_records.each do |final_recovery_diary_record| + classroom = final_recovery_diary_record.recovery_diary_record.classroom + if final_recovery_diary_record.recovery_diary_record.students.any? { |student| student.score.blank? } - @warning_messages << "Não foi possível enviar as recuperações finais da turma #{final_recovery_diary_record.recovery_diary_record.classroom} pois existem alunos sem nota." + @warning_messages << "Não foi possível enviar as recuperações finais da turma #{classroom} pois existem alunos sem nota." end - classroom_api_code = final_recovery_diary_record.recovery_diary_record.classroom.api_code + classroom_api_code = classroom.api_code discipline_api_code = final_recovery_diary_record.recovery_diary_record.discipline.api_code score_rounder = ScoreRounder.new( - final_recovery_diary_record.recovery_diary_record.classroom, + classroom, RoundedAvaliations::FINAL_RECOVERY, - get_step(teacher_discipline_classroom.classroom) + get_step(classroom) ) final_recovery_diary_record.recovery_diary_record.students.each do |recovery_diary_record_student| - next unless not_posted?({ classroom: recovery_diary_record_student.recovery_diary_record.classroom, + next unless not_posted?({ classroom: classroom, discipline: recovery_diary_record_student.recovery_diary_record.discipline, student: recovery_diary_record_student.student })[:final_recovery] From 0f3912a27db26f0031418cfff8d20c1fb853bfb1 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 11 Mar 2023 14:34:41 -0300 Subject: [PATCH 31/37] =?UTF-8?q?Cria=20rake=20para=20rodar=20migration=20?= =?UTF-8?q?em=20tenant=20espec=C3=ADfico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/database.rake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/tasks/database.rake b/lib/tasks/database.rake index 840b8beee..167908515 100644 --- a/lib/tasks/database.rake +++ b/lib/tasks/database.rake @@ -37,6 +37,21 @@ namespace :db do end end end + + task run_specific_tenant: :environment do + begin + Entity.find_by_name(ENV["TENANT"].to_sym).using_connection do + ActiveRecord::Migrator.migrations_paths = Educacao::Application.config.paths['db/migrate'].expanded + ActiveRecord::Migration.verbose = true + + puts "Migrating db: #{Entity.current.domain}" + + ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths) + end + rescue Exception => e + puts "Database #{ENV["TENANT"]} not found" + end + end end end From 1d8f9b0135dd99a9b4e7f4fc546428c6fb177d43 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sun, 2 Apr 2023 17:29:44 -0300 Subject: [PATCH 32/37] =?UTF-8?q?Valida=20se=20ele=20pode=20enviar=20antes?= =?UTF-8?q?=20de=20atribuir=20outras=20vari=C3=A1veis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/exam_poster/numerical_exam_poster.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/services/exam_poster/numerical_exam_poster.rb b/app/services/exam_poster/numerical_exam_poster.rb index 6a5445311..78a3ee979 100644 --- a/app/services/exam_poster/numerical_exam_poster.rb +++ b/app/services/exam_poster/numerical_exam_poster.rb @@ -51,11 +51,12 @@ def post_by_classrooms teacher_discipline_classrooms.each do |teacher_discipline_classroom| classroom = teacher_discipline_classroom.classroom - discipline = teacher_discipline_classroom.discipline - score_rounder = ScoreRounder.new(classroom, RoundedAvaliations::SCHOOL_TERM_RECOVERY, get_step(classroom)) next unless can_post?(classroom) + discipline = teacher_discipline_classroom.discipline + score_rounder = ScoreRounder.new(classroom, RoundedAvaliations::SCHOOL_TERM_RECOVERY, get_step(classroom)) + teacher_score_fetcher = TeacherScoresFetcher.new( teacher, classroom, From 80f01e35731b063870e9c8cb24bb60b9d346af93 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sun, 2 Apr 2023 17:37:13 -0300 Subject: [PATCH 33/37] =?UTF-8?q?Atribui=20chamadas=20para=20vari=C3=A1vel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/exam_poster/numerical_exam_poster.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/services/exam_poster/numerical_exam_poster.rb b/app/services/exam_poster/numerical_exam_poster.rb index 78a3ee979..5af06259f 100644 --- a/app/services/exam_poster/numerical_exam_poster.rb +++ b/app/services/exam_poster/numerical_exam_poster.rb @@ -55,13 +55,14 @@ def post_by_classrooms next unless can_post?(classroom) discipline = teacher_discipline_classroom.discipline - score_rounder = ScoreRounder.new(classroom, RoundedAvaliations::SCHOOL_TERM_RECOVERY, get_step(classroom)) + step = get_step(classroom) + score_rounder = ScoreRounder.new(classroom, RoundedAvaliations::SCHOOL_TERM_RECOVERY, step) teacher_score_fetcher = TeacherScoresFetcher.new( teacher, classroom, discipline, - get_step(classroom) + step ) teacher_score_fetcher.fetch! @@ -69,7 +70,7 @@ def post_by_classrooms teacher, classroom, discipline, - get_step(classroom) + step ) teacher_recovery_score_fetcher.fetch! @@ -83,12 +84,12 @@ def post_by_classrooms next unless numerical_or_school_term_recovery?(classroom, discipline, student_score) exempted_discipline_ids = - ExemptedDisciplinesInStep.discipline_ids(classroom.id, get_step(classroom).to_number) + ExemptedDisciplinesInStep.discipline_ids(classroom.id, step.to_number) next if exempted_discipline_ids.include?(discipline.id) if (value = StudentAverageCalculator.new(student_score) - .calculate(classroom, discipline, get_step(classroom))) + .calculate(classroom, discipline, step)) scores[classroom.api_code][student_score.api_code][discipline.api_code]['nota'] = value end From 0a28ee5d995c34fb34ba1e92084643070f72d240 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 2 May 2023 21:16:38 -0300 Subject: [PATCH 34/37] =?UTF-8?q?Valida=20apenas=20se=20tiver=20configura?= =?UTF-8?q?=C3=A7=C3=A3o=20ativa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/content_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/content_record.rb b/app/models/content_record.rb index 47ed21591..dc942e5ba 100644 --- a/app/models/content_record.rb +++ b/app/models/content_record.rb @@ -34,7 +34,7 @@ class ContentRecord < ActiveRecord::Base validates :daily_activities_record, presence: true, if: :require_daily_activities_record? validates :teacher, presence: true validate :at_least_one_content - validates_uniqueness_of :class_number, scope: [:classroom, :teacher] + validates_uniqueness_of :class_number, scope: [:classroom, :teacher, :record_date], if: -> { allow_class_number? } validates :class_number, presence: true, if: -> { allow_class_number? } delegate :grades, :grade_ids, :first_grade, to: :classroom From df9c8018c6f804e308f6c8439046313519f2746d Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 2 May 2023 23:18:19 -0300 Subject: [PATCH 35/37] Ajustes gerais na estrutura --- .../discipline_content_records_controller.rb | 8 ++++---- app/models/content_record.rb | 6 ------ app/models/discipline_content_record.rb | 17 +++++++++++++++++ app/services/create_multiple_contents.rb | 2 +- .../discipline_content_records/_form.html.erb | 2 +- .../_resources.html.erb | 2 +- .../discipline_content_records/index.html.erb | 2 +- config/locales/models/content_record.yml | 1 - .../models/discipline_content_record.yml | 2 ++ ...165443_add_class_number_to_content_record.rb | 5 ----- ...class_number_to_discipline_content_record.rb | 5 +++++ 11 files changed, 32 insertions(+), 20 deletions(-) delete mode 100644 db/migrate/20221220165443_add_class_number_to_content_record.rb create mode 100644 db/migrate/20230503013503_add_class_number_to_discipline_content_record.rb diff --git a/app/controllers/discipline_content_records_controller.rb b/app/controllers/discipline_content_records_controller.rb index db57f71c5..eefe77a9a 100644 --- a/app/controllers/discipline_content_records_controller.rb +++ b/app/controllers/discipline_content_records_controller.rb @@ -57,11 +57,11 @@ def create authorize @discipline_content_record if allow_class_number - @class_numbers = resource_params[:content_record_attributes][:class_number].split(',').sort - @discipline_content_record.content_record.class_number = @class_numbers.first + @class_numbers = resource_params[:class_number].split(',').sort + @discipline_content_record.class_number = @class_numbers.first @class_numbers.each do |class_number| - @discipline_content_record.content_record.class_number = class_number + @discipline_content_record.class_number = class_number return render :new if @discipline_content_record.invalid? end @@ -162,13 +162,13 @@ def content_ids def resource_params params.require(:discipline_content_record).permit( + :class_number, :discipline_id, content_record_attributes: [ :id, :unity_id, :classroom_id, :record_date, - :class_number, :daily_activities_record, :content_ids ] diff --git a/app/models/content_record.rb b/app/models/content_record.rb index dc942e5ba..d3eb55570 100644 --- a/app/models/content_record.rb +++ b/app/models/content_record.rb @@ -34,18 +34,12 @@ class ContentRecord < ActiveRecord::Base validates :daily_activities_record, presence: true, if: :require_daily_activities_record? validates :teacher, presence: true validate :at_least_one_content - validates_uniqueness_of :class_number, scope: [:classroom, :teacher, :record_date], if: -> { allow_class_number? } - validates :class_number, presence: true, if: -> { allow_class_number? } delegate :grades, :grade_ids, :first_grade, to: :classroom scope :by_unity_id, lambda { |unity_id| joins(:classroom).merge(Classroom.by_unity(unity_id)) } scope :by_teacher_id, lambda { |teacher_id| where(teacher_id: teacher_id) } - def allow_class_number? - GeneralConfiguration.first.allow_class_number_on_content_records - end - def to_s return discipline_content_record.discipline.to_s if discipline_content_record return knowledge_area_content_record.knowledge_areas.first.to_s if knowledge_area_content_record diff --git a/app/models/discipline_content_record.rb b/app/models/discipline_content_record.rb index f4b151146..7cd5f0492 100644 --- a/app/models/discipline_content_record.rb +++ b/app/models/discipline_content_record.rb @@ -40,12 +40,15 @@ class DisciplineContentRecord < ActiveRecord::Base joins(:content_record).merge(ContentRecord.where.not(teacher_id: current_teacher_id)) end } + scope :by_class_number, lambda { |class_number| where(class_number: class_number) } + validates :class_number, presence: true, if: -> { allow_class_number? } validates :content_record, presence: true validates :discipline, presence: true validate :uniqueness_of_discipline_content_record validate :ensure_is_school_day + validate :uniqueness_of_class_number, if: -> { allow_class_number? } delegate :contents, :record_date, :classroom, to: :content_record delegate :grades, to: :classroom @@ -87,6 +90,20 @@ def uniqueness_of_discipline_content_record end end + def uniqueness_of_class_number + discipline_content_record = DisciplineContentRecord.by_teacher_id(content_record.teacher_id) + .by_classroom_id(content_record.classroom_id) + .by_discipline_id(discipline_id) + .by_date(content_record.record_date) + .by_class_number(class_number) + .exists? + + if discipline_content_record + errors.add(:class_number, I18n.t('activerecord.errors.models.discipline_content_record.attributes.discipline_id.class_number_in_use')) + end + end + + def ensure_is_school_day return unless content_record.present? && content_record.school_calendar.present? && diff --git a/app/services/create_multiple_contents.rb b/app/services/create_multiple_contents.rb index dffb39399..b9216053a 100644 --- a/app/services/create_multiple_contents.rb +++ b/app/services/create_multiple_contents.rb @@ -17,7 +17,7 @@ def create_multiple lessons_to_create.each do |class_number| discipline_content = base_content.dup discipline_content.content_record = base_content.content_record.dup - discipline_content.content_record.class_number = class_number + discipline_content.class_number = class_number discipline_content.save end end diff --git a/app/views/discipline_content_records/_form.html.erb b/app/views/discipline_content_records/_form.html.erb index b59d4d28f..835a522b4 100644 --- a/app/views/discipline_content_records/_form.html.erb +++ b/app/views/discipline_content_records/_form.html.erb @@ -35,7 +35,7 @@ <% if @allow_class_number %>
<% show_classes = action_name == ('new' || 'create') ? false : true %> - <%= content_record.input :class_number, as: :select2, multiple: true, + <%= f.input :class_number, as: :select2, multiple: true, elements: number_of_classes_elements(@number_of_classes), placeholder: 'Selecione uma ou mais aulas', disabled: show_classes %> diff --git a/app/views/discipline_content_records/_resources.html.erb b/app/views/discipline_content_records/_resources.html.erb index c56ae0df6..97dab51c6 100644 --- a/app/views/discipline_content_records/_resources.html.erb +++ b/app/views/discipline_content_records/_resources.html.erb @@ -12,7 +12,7 @@ <%= discipline_content_record.content_record.decorator.author(current_teacher) %> <% if @allow_class_number %> - <%= discipline_content_record.content_record.class_number %> + <%= discipline_content_record.class_number %> <% end %> diff --git a/app/views/discipline_content_records/index.html.erb b/app/views/discipline_content_records/index.html.erb index 563bc387f..d5a4ec9fb 100644 --- a/app/views/discipline_content_records/index.html.erb +++ b/app/views/discipline_content_records/index.html.erb @@ -31,7 +31,7 @@ <%= DisciplineContentRecord.human_attribute_name :author %> <% if @allow_class_number %> - <%= ContentRecord.human_attribute_name :class_number %> + <%= DisciplineContentRecord.human_attribute_name :class_number %> <% end %> diff --git a/config/locales/models/content_record.yml b/config/locales/models/content_record.yml index 8bee68fa0..4cfd20a5c 100644 --- a/config/locales/models/content_record.yml +++ b/config/locales/models/content_record.yml @@ -15,7 +15,6 @@ pt-BR: daily_activities_record: "Registro diário das atividades" contents: "Conteúdos" contents_tags: "Adicionar novo" - class_number: "Aula" errors: models: content_record: diff --git a/config/locales/models/discipline_content_record.yml b/config/locales/models/discipline_content_record.yml index 00907e10f..4a621f8c9 100644 --- a/config/locales/models/discipline_content_record.yml +++ b/config/locales/models/discipline_content_record.yml @@ -13,9 +13,11 @@ pt-BR: discipline_id: "Disciplina" author: "Autor" contents: "Conteúdos" + class_number: "Aula" errors: models: discipline_content_record: attributes: discipline_id: discipline_in_use: "já existe um registro de conteúdo para a disciplina informada" + class_number_in_use: "Já existe um registro de conteúdo para a Turma/Disciplina/Data/Número de aula infomado" diff --git a/db/migrate/20221220165443_add_class_number_to_content_record.rb b/db/migrate/20221220165443_add_class_number_to_content_record.rb deleted file mode 100644 index b395235f2..000000000 --- a/db/migrate/20221220165443_add_class_number_to_content_record.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddClassNumberToContentRecord < ActiveRecord::Migration - def change - add_column :content_records, :class_number, :integer, default: 0 - end -end diff --git a/db/migrate/20230503013503_add_class_number_to_discipline_content_record.rb b/db/migrate/20230503013503_add_class_number_to_discipline_content_record.rb new file mode 100644 index 000000000..b22871a0c --- /dev/null +++ b/db/migrate/20230503013503_add_class_number_to_discipline_content_record.rb @@ -0,0 +1,5 @@ +class AddClassNumberToDisciplineContentRecord < ActiveRecord::Migration + def change + add_column :discipline_content_records, :class_number, :integer, default: 0 + end +end From 78ddd3c447f7d3c7192a60f0742c786ccfa230a3 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Sat, 21 May 2022 01:39:39 -0300 Subject: [PATCH 36/37] Ajusta nome do host para evitar conflitos --- config/database.sample.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/database.sample.yml b/config/database.sample.yml index 241469a2d..085e6afd3 100644 --- a/config/database.sample.yml +++ b/config/database.sample.yml @@ -4,7 +4,7 @@ default: &default pool: 5 username: <%= ENV.fetch("DATABASE_USERNAME", "postgres") %> password: <%= ENV.fetch("DATABASE_PASSWORD", "postgres") %> - host: <%= ENV.fetch("DATABASE_HOST", "localhost") %> + host: <%= ENV.fetch("DATABASE_HOST", "postgres-idiario") %> development: <<: *default From 5fe0cf3effd177fdc8c250413c52441247aee123 Mon Sep 17 00:00:00 2001 From: gustavomendess Date: Tue, 16 Jan 2024 19:35:12 -0300 Subject: [PATCH 37/37] Apply sugestions --- README.md | 10 ++++++++++ app/views/discipline_content_records/index.html.erb | 2 +- script/start | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7730cc9c5..2ce799e1e 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,16 @@ idiario | * Listening on tcp://0.0.0.0:3000 idiario | Use Ctrl-C to stop ``` +Após finalizada a instalação, descubra em qual endereço o i-Diário está rodando, basta executar o comando: + +``` +docker-compose port app 3000 +``` + +Acesse o endereço que será exibido após rodar o comando acima. + +O usuário padrão é: `admin` / A senha padrão é: `123456789` + #### Personalizando a instalação via Docker Você pode criar um arquivo `docker-compose.override.yml` para personalizar sua instalação do i-Diário, mudando as portas diff --git a/app/views/discipline_content_records/index.html.erb b/app/views/discipline_content_records/index.html.erb index 31b4a5717..859b43968 100644 --- a/app/views/discipline_content_records/index.html.erb +++ b/app/views/discipline_content_records/index.html.erb @@ -47,7 +47,7 @@ <%= render 'resources' %> - + <%= render 'shared/pagination', records: @discipline_content_records %> diff --git a/script/start b/script/start index f4ad812af..5f89487a5 100755 --- a/script/start +++ b/script/start @@ -15,8 +15,8 @@ if ! test -f ".setup"; then bundle exec rake db:create bundle exec rake db:migrate - bundle exec rake entity:setup NAME=prefeitura DOMAIN=localhost DATABASE=idiario - bundle exec rake entity:admin:create NAME=prefeitura ADMIN_PASSWORD=A123456789$ + bundle exec rake entity:setup NAME=prefeitura DOMAIN=localhost DATABASE=prefeitura_diario + bundle exec rake entity:admin:create NAME=prefeitura ADMIN_PASSWORD=123456789 cp public/404.html.sample public/404.html cp public/500.html.sample public/500.html