mumuki-laboratory 9.6.0 → 9.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd241aca9a26c54188bd561d66bdd169636645a0a811ddfdda36380e0ce6cd0d
4
- data.tar.gz: 1b0ac735778e2bf364174ee9477d2366dd98f2e8d6c81c8ee94cfadd96148a11
3
+ metadata.gz: 97ae0a63f9a16ede7d8866af0c7b8231abd7f8ae678da1a694ce0aebe923f61e
4
+ data.tar.gz: 1ce819ad7a32aaaf7ede7ac15105acb8087d4e5a1b62961a10a184512b70de9c
5
5
  SHA512:
6
- metadata.gz: '0818e279bf73c4e53d29ac86f25f04204f011a3441fda6aa2a5d32003cd57ecd026f751ccca5beb58c84014f9102548ccaa965239dfc0289ee7efdbae191c501'
7
- data.tar.gz: d071e2c07cb581cb023e5e81719a9e8d7f0d61cfcf8f10edcda4bf01629cd190a38b16ebfef87716d1f3b8d494b0d0fa7e7d114dbc716f3caa68569bc21bf963
6
+ metadata.gz: 1e87629f7ae2d0c24d5ef892909d04e2ac9118beffb15ef3dd06055032f292454fb9be04b6280ee476953aa0fbcee37fcda044b344d7316c3527ca9d277ef806
7
+ data.tar.gz: 663bc32b009d62762c386151b0c67f680c6b382c67e9360b218a8132f3aed209daaa7f8b25860245666c5c2529f62138de732d6ff8599e1dc2767f8d4c04f02a
@@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base
16
16
 
17
17
  before_action :set_current_organization!
18
18
  before_action :set_locale!
19
+ before_action :set_time_zone!
19
20
 
20
21
  before_action :ensure_user_enabled!, if: :current_user?
21
22
  before_action :validate_active_organization!
@@ -30,6 +31,7 @@ class ApplicationController < ActionController::Base
30
31
  before_action :visit_organization!, if: :current_user?
31
32
 
32
33
  after_action :leave_organization!
34
+ after_action :unset_time_zone!
33
35
 
34
36
  helper_method :current_workspace,
35
37
  :login_button,
@@ -143,6 +145,14 @@ class ApplicationController < ActionController::Base
143
145
  I18n.locale = Organization.current.locale
144
146
  end
145
147
 
148
+ def set_time_zone!
149
+ Time.zone = Organization.current.time_zone
150
+ end
151
+
152
+ def unset_time_zone!
153
+ Time.zone = nil
154
+ end
155
+
146
156
  def subject #TODO may be used to remove breadcrumbs duplication
147
157
  nil
148
158
  end
@@ -1,4 +1,7 @@
1
1
  class ExamAuthorizationRequestsController < ApplicationController
2
+
3
+ before_action :verify_registration_opened!, on: [:create, :update]
4
+
2
5
  def create
3
6
  authorization_request = ExamAuthorizationRequest.find_or_create_by! create_authorization_request_params do |it|
4
7
  it.assign_attributes authorization_request_params
@@ -25,4 +28,9 @@ class ExamAuthorizationRequestsController < ApplicationController
25
28
  .require(:exam_authorization_request).permit(:exam_id, :exam_registration_id)
26
29
  .merge(user: current_user, organization: Organization.current)
27
30
  end
31
+
32
+ def verify_registration_opened!
33
+ exam_registration = ExamRegistration.find(authorization_request_params[:exam_registration_id])
34
+ raise Mumuki::Domain::GoneError if exam_registration.end_time.past?
35
+ end
28
36
  end
@@ -0,0 +1,13 @@
1
+ module ExamRegistrationHelper
2
+ def exam_registration_view
3
+ if @registration.end_time.past?
4
+ { icon: :times_circle, class: :danger, t: :exam_registration_finished_html }
5
+ else
6
+ { icon: :info_circle, class: :info, t: :exam_registration_explanation_html }
7
+ end
8
+ end
9
+
10
+ def current_time_zone_html
11
+ %Q{(<span class="select-date-timezone">#{Organization.current&.time_zone}</span>)}.html_safe
12
+ end
13
+ end
@@ -1 +1,2 @@
1
- <%= t :exam_authorization_request_approved_html, date: l(authorization_request.exam.start_time.in_time_zone(-3), format: :long) %>
1
+ <%= t :exam_authorization_request_approved_html, date: l(authorization_request.exam.start_time, format: :long),
2
+ location: Organization.current.time_zone %>
@@ -1,4 +1,5 @@
1
1
  <%= t :exam_authorization_pending_explanation_html,
2
- date: l(authorization_request.exam.start_time.in_time_zone(-3), format: :long),
3
- end_time: l(authorization_request.exam_registration.end_time.in_time_zone(-3), format: :long),
2
+ date: l(authorization_request.exam.start_time, format: :long),
3
+ end_time: l(authorization_request.exam_registration.end_time, format: :long),
4
+ location: Organization.current.time_zone,
4
5
  edit_path: url_for(authorization_request.exam_registration) %>
@@ -12,25 +12,27 @@
12
12
 
13
13
  <div class="row">
14
14
  <div class="col-lg-12">
15
- <div class="bs-callout bs-callout-info">
16
- <h4 class="text-info">
17
- <strong><%= fa_icon :info_circle %> <%= t :important_info %></strong>
18
- </h4>
15
+ <div class="bs-callout bs-callout-<%= exam_registration_view[:class] %>">
16
+ <h4 class="text-<%= exam_registration_view[:class] %>">
17
+ <strong><%= fa_icon exam_registration_view[:icon] %> <%= t :important_info %></strong>
18
+ </h4>
19
19
  <p>
20
- <%= t :exam_registration_explanation_html, date: l(@registration.end_time.in_time_zone(-3), format: :long) %>
20
+ <%= t exam_registration_view[:t], date: l(@registration.end_time, format: :long), location: Organization.current.time_zone %>
21
21
  </p>
22
22
  </div>
23
- <%= form_for @authorization_request, html: {class: 'mu-form'} do |f| %>
24
- <%= f.hidden_field :exam_registration_id, value: @registration.id %>
25
- <%= f.label :exam_id, t(:exam_registration_choose_exam) %>
26
- <% @registration.exams.each do |exam| %>
27
- <div class="form-check">
28
- <%= f.radio_button(:exam_id, exam.id, id: exam.id, required: true, class: 'form-check-input mu-read-only-input',
29
- checked: @authorization_request.exam_id == exam.id) %>
30
- <%= label_tag exam.id, l(exam.start_time.in_time_zone(-3), format: :long), class: 'form-check-label' %>
31
- </div>
23
+ <% unless @registration.end_time.past? %>
24
+ <%= form_for @authorization_request, html: {class: 'mu-form'} do |f| %>
25
+ <%= f.hidden_field :exam_registration_id, value: @registration.id %>
26
+ <%= f.label :exam_id, t(:exam_registration_choose_exam) %>
27
+ <% @registration.exams.each do |exam| %>
28
+ <div class="form-check">
29
+ <%= f.radio_button(:exam_id, exam.id, id: exam.id, required: true, class: 'form-check-input mu-read-only-input',
30
+ checked: @authorization_request.exam_id == exam.id) %>
31
+ <%= label_tag exam.id, "#{l(exam.start_time, format: :long)} #{current_time_zone_html}".html_safe, class: 'form-check-label' %>
32
+ </div>
33
+ <% end %>
34
+ <button class="btn btn-complementary"> <%= t :save %> </button>
32
35
  <% end %>
33
- <button class="btn btn-complementary"> <%= t :save %> </button>
34
36
  <% end %>
35
37
  </div>
36
38
  </div>
@@ -22,7 +22,7 @@
22
22
  <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#<%= "exam_authorization_collapse_item_#{index}" %>" aria-expanded="false" aria-controls="<%= "exam_authorization_collapse_item_#{index}" %>">
23
23
  <span class="fa fa-fw fa-<%= it.icon[:class] %> text-<%= it.icon[:type] %>" data-bs-toggle="tooltip" title="<%= t(it.status).humanize %>"></span>
24
24
  <span class="divider-vertical"></span>
25
- <span><strong><%= it.exam_registration.description %></strong> - <small><%= l(it.exam.start_time.in_time_zone(-3), format: :long) %></small></span>
25
+ <span><strong><%= it.exam_registration.description %></strong> - <small><%= l(it.exam.start_time, format: :long) %></small></span>
26
26
  </button>
27
27
  </h2>
28
28
  <div id="<%= "exam_authorization_collapse_item_#{index}" %>" class="accordion-collapse collapse" aria-labelledby="<%= "exam_authorization_accordion_item_#{index}" %>" data-bs-parent="#exam_authorization_accordion">
@@ -108,14 +108,15 @@ en:
108
108
  error_500: 500 error
109
109
  error_description: This is known as a <span class="error-link">%{error}</span>.
110
110
  errored: Oops, your solution didn't work
111
- exam_authorization_pending_explanation_html: You have until <strong>%{end_time}</strong> to register. After that date, your request will be processed and you will receive a confirmation. <br> Don't forget to check the notifications!
112
- exam_authorization_request_approved_html: Your request was approved, don't forget to log in at <strong>%{date}</strong>. Good luck!
111
+ exam_authorization_pending_explanation_html: You have until <strong>%{end_time}</strong> (%{location} time) to register. After that date, your request will be processed and you will receive a confirmation. <br> Don't forget to check the notifications!
112
+ exam_authorization_request_approved_html: Your request was approved, don't forget to log in at <strong>%{date}</strong> (%{location} time). Good luck!
113
113
  exam_authorization_request_created: Your registration to the exam has been saved!
114
114
  exam_authorization_request_rejected: Your request was rejected because you didn't meet the requirements.
115
115
  exam_authorization_request_saved: Your registration to the exam has been updated!
116
116
  exam_authorization_request_updated: Your registration to %{description} has been updated
117
117
  exam_registration_choose_exam: Choose date and time to attend to the exam
118
- exam_registration_explanation_html: You have until <strong>%{date}</strong> to register. After that date, your request will be processed and you will receive a confirmation. <br> Don't forget to check the notifications!
118
+ exam_registration_explanation_html: You have until <strong>%{date}</strong> (%{location} time) to register. After that date, your request will be processed and you will receive a confirmation. <br> Don't forget to check the notifications!
119
+ exam_registration_finished_html: Registration for this exam ended on <strong>%{date}</strong> (%{location} time)
119
120
  exam_registration_open: Registrations open for %{description}!
120
121
  exam_registration_to: Registration to %{description}
121
122
  exams_will_be_here: Your exams in the organization will appear here.
@@ -108,14 +108,15 @@ es-CL:
108
108
  internal_server_error: ¡Ups! Algo no anduvo bien
109
109
  not_found: ¡Ups! La página no existe
110
110
  errored: ¡Ups! Tu solución no se puede ejecutar
111
- exam_authorization_pending_explanation_html: Tienes tiempo hasta el <strong>%{end_time}</strong> para inscribirte. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No olvides revisar las notificaciones!
112
- exam_authorization_request_approved_html: Tu solicitud fue aprobada, no olvides conectarte el <strong>%{date}</strong>. ¡Buena suerte!
111
+ exam_authorization_pending_explanation_html: Tienes tiempo hasta el <strong>%{end_time}</strong> (hora de %{location}) para inscribirte. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No olvides revisar las notificaciones!
112
+ exam_authorization_request_approved_html: Tu solicitud fue aprobada, no olvides conectarte el <strong>%{date}</strong> (hora de %{location}). ¡Buena suerte!
113
113
  exam_authorization_request_created: ¡Tu inscripción al exámen se registró exitosamente!
114
114
  exam_authorization_request_rejected: Tu solicitud fue rechazada porque no cumpliste con los requisitos para rendir el examen.
115
115
  exam_authorization_request_saved: ¡Tu inscripción al exámen se modificó exitosamente!
116
116
  exam_authorization_request_updated: Hay novedades sobre tu inscripción a %{description}
117
117
  exam_registration_choose_exam: Seleccioná día y horario en el que te gustaría rendir el exámen
118
- exam_registration_explanation_html: Tienes tiempo hasta el <strong>%{date}</strong> para inscribirte. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No olvides revisar las notificaciones!
118
+ exam_registration_explanation_html: Tienes tiempo hasta el <strong>%{date}</strong> (hora de %{location}) para inscribirte. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No olvides revisar las notificaciones!
119
+ exam_registration_finished_html: La inscripción a este examen finalizó el <strong>%{date}</strong> (hora de %{location})
119
120
  exam_registration_open: ¡Ya puedes inscribirte a %{description}!
120
121
  exam_registration_to: Inscripción a %{description}
121
122
  exams_will_be_here: Tus exámenes en esta organización aparecerán acá
@@ -116,14 +116,15 @@ es:
116
116
  internal_server_error: ¡Ups! Algo no anduvo bien
117
117
  not_found: ¡Ups! La página no existe
118
118
  errored: ¡Ups! Tu solución no se puede ejecutar
119
- exam_authorization_pending_explanation_html: Tenés tiempo hasta el <strong>%{end_time}</strong> para cambiar el turno haciendo click <strong><a href="%{edit_path}">acá</a></strong>. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No te olvides de revisar las notificaciones!
120
- exam_authorization_request_approved_html: Tu solicitud fue aprobada, no olvides conectarte el <strong>%{date}</strong>. ¡Buena suerte!
119
+ exam_authorization_pending_explanation_html: Tenés tiempo hasta el <strong>%{end_time}</strong> (hora de %{location}) para cambiar el turno haciendo click <strong><a href="%{edit_path}">acá</a></strong>. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No te olvides de revisar las notificaciones!
120
+ exam_authorization_request_approved_html: Tu solicitud fue aprobada, no olvides conectarte el <strong>%{date}</strong> (hora de %{location}). ¡Buena suerte!
121
121
  exam_authorization_request_created: ¡Tu inscripción al exámen se registró exitosamente!
122
122
  exam_authorization_request_rejected: Tu solicitud fue rechazada porque no cumpliste con los requisitos para rendir el examen.
123
123
  exam_authorization_request_saved: ¡Tu inscripción al exámen se modificó exitosamente!
124
124
  exam_authorization_request_updated: Hay novedades sobre tu inscripción a %{description}
125
125
  exam_registration_choose_exam: Seleccioná día y horario en el que te gustaría rendir el exámen
126
- exam_registration_explanation_html: Tenés tiempo hasta el <strong>%{date}</strong> para inscribirte. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No te olvides de revisar las notificaciones!
126
+ exam_registration_explanation_html: Tenés tiempo hasta el <strong>%{date}</strong> (hora de %{location}) para inscribirte. Pasada esa fecha, tu solicitud será evaluada y recibirás una confirmación. <br> ¡No te olvides de revisar las notificaciones!
127
+ exam_registration_finished_html: La inscripción a este examen finalizó el <strong>%{date}</strong> (hora de %{location})
127
128
  exam_registration_open: ¡Ya podés inscribirte a %{description}!
128
129
  exam_registration_to: Inscripción a %{description}
129
130
  exams_will_be_here: Tus exámenes en esta organización aparecerán acá
@@ -111,14 +111,15 @@ pt:
111
111
  error_500: erro 500
112
112
  error_description: Isto é o que é conhecido como <span class = "error-link"> %{error} </ span>.
113
113
  errored: Opa! Sua solução não pode ser executada
114
- exam_authorization_pending_explanation_html: Você tem tempo até <strong>%{date}</strong> para se inscrever. Após essa data, sua inscrição será avaliada e você receberá uma confirmação. <br> Não se esqueça de verificar as notificações!
115
- exam_authorization_request_approved_html: Sua solicitação foi aprovada, não se esqueça de conectar em <strong>%{date}</strong>. Boa sorte!
114
+ exam_authorization_pending_explanation_html: Você tem tempo até <strong>%{date}</strong> (horário de %{location}) para se inscrever. Após essa data, sua inscrição será avaliada e você receberá uma confirmação. <br> Não se esqueça de verificar as notificações!
115
+ exam_authorization_request_approved_html: Sua solicitação foi aprovada, não se esqueça de conectar em <strong>%{date}</strong> (horário de %{location}). Boa sorte!
116
116
  exam_authorization_request_created: Seu registro de exame foi salvo com sucesso!
117
117
  exam_authorization_request_rejected: Sua solicitação foi rejeitada porque você não atendeu aos requisitos.
118
118
  exam_authorization_request_saved: Seu registro de exame foi modificado com sucesso!
119
119
  exam_authorization_request_updated: Há notícias sobre seu registro para %{description}
120
120
  exam_registration_choose_exam: Selecione o dia e a hora em que gostaria de fazer o exame
121
- exam_registration_explanation_html: Você tem tempo até <strong>%{date}</strong> para se inscrever. Após essa data, sua inscrição será avaliada e você receberá uma confirmação. <br> Não se esqueça de verificar as notificações!
121
+ exam_registration_explanation_html: Você tem tempo até <strong>%{date}</strong> (horário de %{location}) para se inscrever. Após essa data, sua inscrição será avaliada e você receberá uma confirmação. <br> Não se esqueça de verificar as notificações!
122
+ exam_registration_finished_html: A inscrição para este exame terminou na <strong>%{date}</strong> (horário de %{location})
122
123
  exam_registration_open: "¡Inscrições abertas para %{description}!"
123
124
  exam_registration_to: Inscrição a %{description}
124
125
  exams_will_be_here: Seus Examesca nesta organização aparecerão aqui
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Laboratory
3
- VERSION = '9.6.0'
3
+ VERSION = '9.7.0'
4
4
  end
5
5
  end
@@ -10,14 +10,64 @@ describe ExamAuthorizationRequestsController, type: :controller, organization_wo
10
10
  describe 'create' do
11
11
  let!(:notification) { create(:notification, target: exam_registration, user: user) }
12
12
 
13
- before do
13
+ def do_post
14
14
  post :create, params: {
15
15
  exam_authorization_request: { exam_id: exam.id, exam_registration_id: exam_registration.id }
16
16
  }
17
17
  end
18
18
 
19
+ before { do_post }
20
+
21
+ describe 'called once' do
22
+ it { expect(response.status).to eq 302 }
23
+ it { expect(exam_registration.authorization_requests.size).to be 1 }
24
+ it { expect(notification.reload.read).to be_truthy }
25
+ end
26
+
27
+ describe 'called twice' do
28
+ before { do_post }
29
+ it { expect(response.status).to eq 302 }
30
+ it { expect(exam_registration.authorization_requests.size).to be 1 }
31
+ it { expect(notification.reload.read).to be_truthy }
32
+ end
33
+ end
34
+
35
+ describe 'update' do
36
+ let(:exam_authorization_request) { create :exam_authorization_request, exam: exam, exam_registration: exam_registration, user: user }
37
+
38
+ before do
39
+ put :update, params: {
40
+ id: exam_authorization_request.id,
41
+ exam_authorization_request: { exam_id: exam.id, exam_registration_id: exam_registration.id }
42
+ }
43
+ end
44
+
19
45
  it { expect(response.status).to eq 302 }
20
- it { expect(exam_registration.authorization_requests.length).to be 1 }
21
- it { expect(notification.reload.read).to be_truthy }
46
+ it { expect(exam_registration.authorization_requests.size).to be 1 }
47
+ end
48
+
49
+ describe 'fails if exam_registration time ended' do
50
+ let(:exam_registration) { create(:exam_registration, exams: [exam], end_time: 2.minutes.ago) }
51
+ let(:exam_authorization_request) { create :exam_authorization_request, exam: exam, exam_registration: exam_registration, user: user }
52
+
53
+ describe 'create' do
54
+ before do
55
+ post :create, params: {
56
+ exam_authorization_request: { exam_id: exam.id, exam_registration_id: exam_registration.id }
57
+ }
58
+ end
59
+ it { expect(response.status).to eq 410 }
60
+ end
61
+
62
+ describe 'update' do
63
+ before do
64
+ put :update, params: {
65
+ id: exam_authorization_request.id,
66
+ exam_authorization_request: { exam_id: exam.id, exam_registration_id: exam_registration.id }
67
+ }
68
+ end
69
+ it { expect(response.status).to eq 410 }
70
+ end
22
71
  end
72
+
23
73
  end
@@ -198,6 +198,7 @@ describe Api::OrganizationsController, type: :controller, organization_workspace
198
198
  terms_of_service: 'A TOS',
199
199
  public: false,
200
200
  login_methods: ['facebook', 'user_pass'],
201
+ time_zone: 'UTC',
201
202
  book: book }
202
203
  let(:updated_organizaton) { organization.reload }
203
204
  let(:update_json) { {contact_email: 'second_email@gmail.com', immersive: true, locale: 'en'} }
@@ -214,7 +215,8 @@ describe Api::OrganizationsController, type: :controller, organization_workspace
214
215
  description: "a great org",
215
216
  locale: 'en',
216
217
  contact_email: "second_email@gmail.com",
217
- terms_of_service: 'A TOS'
218
+ terms_of_service: 'A TOS',
219
+ time_zone: 'UTC'
218
220
  },
219
221
  settings: {
220
222
  login_methods: ["facebook", "user_pass"],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-laboratory
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.6.0
4
+ version: 9.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Bulgarelli
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 9.6.0
33
+ version: 9.7.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 9.6.0
40
+ version: 9.7.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mumukit-bridge
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -553,6 +553,7 @@ files:
553
553
  - app/helpers/editor_helper.rb
554
554
  - app/helpers/editor_tabs_helper.rb
555
555
  - app/helpers/email_helper.rb
556
+ - app/helpers/exam_registration_helper.rb
556
557
  - app/helpers/exercise_input_helper.rb
557
558
  - app/helpers/gamification_helper.rb
558
559
  - app/helpers/globals_helper.rb