metadata_presenter 2.17.44 → 2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/metadata_presenter/engine_controller.rb +6 -0
- data/app/controllers/metadata_presenter/save_and_return_controller.rb +81 -3
- data/app/models/metadata_presenter/email_confirmation.rb +17 -0
- data/app/models/metadata_presenter/saved_form.rb +29 -1
- data/app/validators/email_confirmation_validator.rb +7 -0
- data/app/validators/saved_progress_validator.rb +8 -0
- data/app/views/layouts/metadata_presenter/application.html.erb +3 -2
- data/app/views/metadata_presenter/page/singlequestion.html.erb +1 -1
- data/app/views/metadata_presenter/save_and_return/email_confirmation.html.erb +22 -0
- data/app/views/metadata_presenter/save_and_return/save_progress.html.erb +13 -0
- data/app/views/metadata_presenter/save_and_return/show.html.erb +1 -0
- data/config/locales/en.yml +12 -0
- data/config/routes.rb +4 -0
- data/lib/metadata_presenter/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f510cf174501cb63991c19c4315d049dbdde45cc1710dc5c0dae3f739c2908a
|
4
|
+
data.tar.gz: e3b761015334f2e86e683e2cc286b1771350920e8ac48d538584db3f26df8586
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed4b94152f503bd888a2e767824a60093c802a9ed83cb6b0cdbc1e7f502bda18279f6eb794dceaea8dd6a61f2331428c56cb2208c22087197a286a7ee447afb8
|
7
|
+
data.tar.gz: 19dce7610b5c923d456ea795020755c5f3b95f8fec3071387fe930284f99dbd5210c799438694ebbe51b85afbe888e11ce221264483c9d04274fb34819ad12a7
|
@@ -1,13 +1,68 @@
|
|
1
1
|
module MetadataPresenter
|
2
2
|
class SaveAndReturnController < EngineController
|
3
|
-
before_action :check_feature_flag
|
4
|
-
helper_method :secret_questions
|
3
|
+
# before_action :check_feature_flag
|
4
|
+
helper_method :secret_questions, :page_slug, :confirmed_email
|
5
5
|
|
6
6
|
def show
|
7
7
|
@saved_form = SavedForm.new
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def page_slug
|
11
|
+
params[:page_slug] || params[:saved_form][:page_slug]
|
12
|
+
end
|
13
|
+
|
14
|
+
def confirmed_email
|
15
|
+
session['saved_form']['email']
|
16
|
+
# TODO: clear session data after submission is successful
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@saved_form = SavedForm.new
|
21
|
+
@saved_form.populate_param_values(saved_form_params)
|
22
|
+
@saved_form.secret_question = text_for(params['saved_form']['secret_question'])
|
23
|
+
@saved_form.populate_service_values(service)
|
24
|
+
@saved_form.populate_session_values(session)
|
25
|
+
if @saved_form.valid?
|
26
|
+
# put in session until we have confirmed email address
|
27
|
+
session[:saved_form] = @saved_form
|
28
|
+
redirect_to '/save/email_confirmation'
|
29
|
+
else
|
30
|
+
render :show, params: { page_slug: params[:page_slug], status: :unprocessable_entity }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def email_confirmation
|
35
|
+
@saved_form = session[:saved_form]
|
36
|
+
@email_confirmation = EmailConfirmation.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def confirm_email
|
40
|
+
@email_confirmation = EmailConfirmation.new
|
41
|
+
@email_confirmation.assign_attributes(confirmation_params[:email_confirmation], session['saved_form']['email'])
|
42
|
+
|
43
|
+
if @email_confirmation.valid?
|
44
|
+
# save_form_progress returns the uuid of the saved form as 'id'
|
45
|
+
# user to generate email link, for now not assigned because rubocop
|
46
|
+
# save_form_progress.body['id']
|
47
|
+
# TODO: rescue failed POST
|
48
|
+
# send_email(uuid, confirmation_params[:email_confirmation])
|
49
|
+
redirect_to '/save/progress_saved'
|
50
|
+
else
|
51
|
+
render :email_confirmation, status: :unprocessable_entity
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# def return
|
56
|
+
# uuid = params[:uuid]
|
57
|
+
# response = get_saved_progress(uuid)
|
58
|
+
|
59
|
+
# session[:user_id] = response['user_id']
|
60
|
+
# session[:user_token] = response['user_token']
|
61
|
+
|
62
|
+
# Rails.logger.info('returning to form')
|
63
|
+
# Rails.logger.info('session')
|
64
|
+
# redirect_to '/check-answers'
|
65
|
+
# end
|
11
66
|
|
12
67
|
def secret_questions
|
13
68
|
[
|
@@ -17,6 +72,29 @@ module MetadataPresenter
|
|
17
72
|
]
|
18
73
|
end
|
19
74
|
|
75
|
+
def text_for(question)
|
76
|
+
return nil if question.blank?
|
77
|
+
|
78
|
+
secret_questions.select { |s| s.id.to_s == question.to_s }.first.name
|
79
|
+
end
|
80
|
+
|
81
|
+
def saved_form_params
|
82
|
+
params.permit(
|
83
|
+
:email,
|
84
|
+
:secret_answer,
|
85
|
+
{ saved_form: %i[page_slug secret_question] },
|
86
|
+
:authenticity_token,
|
87
|
+
:page_slug
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
def confirmation_params
|
92
|
+
params.permit(
|
93
|
+
:email_confirmation,
|
94
|
+
:authenticity_token
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
20
98
|
private
|
21
99
|
|
22
100
|
def check_feature_flag
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MetadataPresenter
|
2
|
+
class EmailConfirmation
|
3
|
+
include ActiveModel::Model
|
4
|
+
|
5
|
+
attr_accessor :email_confirmation,
|
6
|
+
:session_email
|
7
|
+
|
8
|
+
validates_with EmailConfirmationValidator
|
9
|
+
|
10
|
+
def initialize; end
|
11
|
+
|
12
|
+
def assign_attributes(email_confirmation, session_email)
|
13
|
+
@email_confirmation = email_confirmation
|
14
|
+
@session_email = session_email
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,11 +1,39 @@
|
|
1
1
|
module MetadataPresenter
|
2
2
|
class SavedForm
|
3
3
|
include ActiveModel::Model
|
4
|
+
validates_with SavedProgressValidator
|
4
5
|
|
5
6
|
attr_accessor :email,
|
6
7
|
:secret_question,
|
7
|
-
:secret_answer
|
8
|
+
:secret_answer,
|
9
|
+
:page_slug,
|
10
|
+
:service_slug,
|
11
|
+
:service_version,
|
12
|
+
:user_id,
|
13
|
+
:user_token,
|
14
|
+
:user_data_payload,
|
15
|
+
:attempts,
|
16
|
+
:active
|
8
17
|
|
18
|
+
validates :secret_question, :secret_answer, :service_slug, :page_slug, :service_version, :user_id, :user_token, presence: true, allow_blank: false
|
9
19
|
def initialize; end
|
20
|
+
|
21
|
+
def populate_param_values(params)
|
22
|
+
self.email = params['email']
|
23
|
+
self.page_slug = params['saved_form']['page_slug']
|
24
|
+
self.secret_question = params['saved_form']['secret_question']
|
25
|
+
self.secret_answer = params['secret_answer']
|
26
|
+
end
|
27
|
+
|
28
|
+
def populate_session_values(session)
|
29
|
+
self.user_id = session[:user_id]
|
30
|
+
self.user_token = session[:user_token]
|
31
|
+
self.user_data_payload = session[:user_data]
|
32
|
+
end
|
33
|
+
|
34
|
+
def populate_service_values(service)
|
35
|
+
self.service_slug = service.service_slug
|
36
|
+
self.service_version = service.version_id
|
37
|
+
end
|
10
38
|
end
|
11
39
|
end
|
@@ -28,6 +28,7 @@
|
|
28
28
|
document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');
|
29
29
|
</script>
|
30
30
|
|
31
|
+
|
31
32
|
<div class="govuk-modal-dialogue-inert-container">
|
32
33
|
<% if show_cookie_request? %>
|
33
34
|
<%= render partial: 'metadata_presenter/analytics/cookie_banner_request' %>
|
@@ -43,7 +44,7 @@
|
|
43
44
|
<% if back_link.present? %>
|
44
45
|
<a class="govuk-back-link" href="<%= back_link %>">Back</a>
|
45
46
|
<% end %>
|
46
|
-
<% if !
|
47
|
+
<% if !allowed_page? %>
|
47
48
|
<%= render partial: 'metadata_presenter/session/timeout_fallback' %>
|
48
49
|
<% end %>
|
49
50
|
<%= yield %>
|
@@ -53,7 +54,7 @@
|
|
53
54
|
<%= render template: 'metadata_presenter/footer/footer' %>
|
54
55
|
</div>
|
55
56
|
|
56
|
-
<% if !
|
57
|
+
<% if !allowed_page? %>
|
57
58
|
<%= render partial: 'metadata_presenter/session/timeout_warning_modal' %>
|
58
59
|
<% end %>
|
59
60
|
</body>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
</div>
|
21
21
|
<% end %>
|
22
22
|
|
23
|
-
<%= f.govuk_submit(disabled: editable?) %>
|
23
|
+
<%= f.govuk_submit(disabled: editable?) %> <% if ENV['SAVE_AND_RETURN'] == 'enabled' %><a href="<%= save_path(:page_slug=>request.env['PATH_INFO']) %>" class="govuk-button" data-module="govuk-button" data-component="save-button"><%= t('presenter.save_and_return.save') %></a><% end %>
|
24
24
|
<% end %>
|
25
25
|
</div>
|
26
26
|
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<div class="fb-main-grid-wrapper">
|
2
|
+
<div class="govuk-grid-row">
|
3
|
+
<div class="govuk-grid-column-two-thirds">
|
4
|
+
<h1 id="page-heading" class="govuk-heading-xl"><%= t('presenter.save_and_return.confirm_email.heading') %></h1>
|
5
|
+
<%= form_for @email_confirmation do |f| %>
|
6
|
+
<%= f.govuk_error_summary %>
|
7
|
+
<div class="govuk-form-group">
|
8
|
+
<%=
|
9
|
+
f.govuk_email_field :email_confirmation,
|
10
|
+
label: { text: t('presenter.save_and_return.show.email_confirmation') },
|
11
|
+
name: "email_confirmation",
|
12
|
+
spellcheck: "false",
|
13
|
+
autocomplete: "email"
|
14
|
+
%>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<p class="mojf-settings-screen__description"><%= t('presenter.save_and_return.confirm_email.description') %></p>
|
18
|
+
|
19
|
+
<%= f.govuk_submit t('presenter.save_and_return.show.continue') %><% end %> <%= link_to t('presenter.save_and_return.show.cancel'), :back %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="fb-main-grid-wrapper">
|
2
|
+
<div class="govuk-grid-row">
|
3
|
+
<div class="govuk-grid-column-two-thirds">
|
4
|
+
<h1 id="page-heading" class="govuk-heading-xl"><%= t('presenter.save_and_return.saved.heading') %></h1>
|
5
|
+
<p class="mojf-settings-screen__description"><%= t('presenter.save_and_return.saved.success', email: confirmed_email) %></p>
|
6
|
+
<p class="govuk-hint"><%= t('presenter.save_and_return.saved.info_1') %></p>
|
7
|
+
<br/>
|
8
|
+
<p class="govuk-hint"><%= t('presenter.save_and_return.saved.info_2') %></p>
|
9
|
+
<br/>
|
10
|
+
<p class="govuk-hint"><%= t('presenter.save_and_return.saved.info_3') %></p>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
</div>
|
data/config/locales/en.yml
CHANGED
@@ -48,6 +48,18 @@ en:
|
|
48
48
|
secret_answer: 'The answer to your security question'
|
49
49
|
continue: 'Continue with saving'
|
50
50
|
cancel: 'Cancel saving and resume form'
|
51
|
+
confirm_email:
|
52
|
+
heading: 'Check your email address is correct'
|
53
|
+
description: 'Make sure this is correct before finishing'
|
54
|
+
saved:
|
55
|
+
heading: 'Your form has been saved'
|
56
|
+
success: "We have sent a one-off link to %{email} which you can use to resume this form within 28 days. After that time, your saved information will be deleted."
|
57
|
+
info_1: "If you haven't received the email after a few minutes, check your spam folder."
|
58
|
+
info_2: 'This link will only work once. If you want to save your progress again after resuming the form, you will need to repeat the save process and generate another link'
|
59
|
+
info_3: 'You are now free to close this window or navigate away from this page.'
|
60
|
+
validation:
|
61
|
+
email: 'Enter an email address in the correct format, like name@example.com'
|
62
|
+
email_not_matched: 'Does not match'
|
51
63
|
secret_questions:
|
52
64
|
one: "What is your mother's maiden name?"
|
53
65
|
two: 'What is the last name of your favourite teacher?'
|
data/config/routes.rb
CHANGED
@@ -12,6 +12,10 @@ MetadataPresenter::Engine.routes.draw do
|
|
12
12
|
|
13
13
|
get 'save', to: 'save_and_return#show'
|
14
14
|
post 'saved_forms', to: 'save_and_return#create'
|
15
|
+
get 'save/email_confirmation', to: 'save_and_return#email_confirmation'
|
16
|
+
post 'email_confirmations', to: 'save_and_return#confirm_email'
|
17
|
+
get 'save/progress_saved', to: 'save_and_return#save_progress'
|
18
|
+
# get 'return/:service_slug/:uuid', to: 'save_and_return#return'
|
15
19
|
|
16
20
|
post '/', to: 'answers#create'
|
17
21
|
match '*path', to: 'answers#create', via: :post
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metadata_presenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: '2.18'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MoJ Forms
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_design_system_formbuilder
|
@@ -271,6 +271,7 @@ files:
|
|
271
271
|
- app/models/metadata_presenter/conditional.rb
|
272
272
|
- app/models/metadata_presenter/coordinates.rb
|
273
273
|
- app/models/metadata_presenter/date_field.rb
|
274
|
+
- app/models/metadata_presenter/email_confirmation.rb
|
274
275
|
- app/models/metadata_presenter/evaluate_conditionals.rb
|
275
276
|
- app/models/metadata_presenter/expression.rb
|
276
277
|
- app/models/metadata_presenter/file_uploader.rb
|
@@ -301,6 +302,7 @@ files:
|
|
301
302
|
- app/operators/metadata_presenter/is_operator.rb
|
302
303
|
- app/operators/metadata_presenter/operator.rb
|
303
304
|
- app/presenters/metadata_presenter/page_answers_presenter.rb
|
305
|
+
- app/validators/email_confirmation_validator.rb
|
304
306
|
- app/validators/metadata_presenter/accept_validator.rb
|
305
307
|
- app/validators/metadata_presenter/autocomplete_validator.rb
|
306
308
|
- app/validators/metadata_presenter/base_validator.rb
|
@@ -322,6 +324,7 @@ files:
|
|
322
324
|
- app/validators/metadata_presenter/validate_schema.rb
|
323
325
|
- app/validators/metadata_presenter/virus_scan_validator.rb
|
324
326
|
- app/validators/metadata_presenter/word_count.rb
|
327
|
+
- app/validators/saved_progress_validator.rb
|
325
328
|
- app/views/errors/404.html
|
326
329
|
- app/views/layouts/metadata_presenter/application.html.erb
|
327
330
|
- app/views/metadata_presenter/analytics/_cookie_banner_confirmation.html.erb
|
@@ -360,6 +363,8 @@ files:
|
|
360
363
|
- app/views/metadata_presenter/page/singlequestion.html.erb
|
361
364
|
- app/views/metadata_presenter/page/standalone.html.erb
|
362
365
|
- app/views/metadata_presenter/page/start.html.erb
|
366
|
+
- app/views/metadata_presenter/save_and_return/email_confirmation.html.erb
|
367
|
+
- app/views/metadata_presenter/save_and_return/save_progress.html.erb
|
363
368
|
- app/views/metadata_presenter/save_and_return/show.html.erb
|
364
369
|
- app/views/metadata_presenter/session/_timeout_fallback.html.erb
|
365
370
|
- app/views/metadata_presenter/session/_timeout_warning_modal.html.erb
|