Skip to content

Commit d3441b5

Browse files
authored
Merge pull request #2607 from alphagov/refactor-forms-controller
Add forms specific base controller
2 parents 87d42e8 + efd1b56 commit d3441b5

32 files changed

+129
-167
lines changed

app/controllers/forms/archive_form_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module Forms
2-
class ArchiveFormController < WebController
2+
class ArchiveFormController < FormsController
33
before_action :check_user_has_permission
4-
after_action :verify_authorized
54

65
def archive
76
return redirect_to path_to_form unless current_form.is_live?

app/controllers/forms/archive_welsh_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module Forms
2-
class ArchiveWelshController < WebController
2+
class ArchiveWelshController < FormsController
33
before_action :check_user_has_permission
4-
after_action :verify_authorized
54

65
def show
76
return redirect_to path_to_form unless has_live_welsh_translation?

app/controllers/forms/archived_controller.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module Forms
2-
class ArchivedController < WebController
3-
after_action :verify_authorized
4-
2+
class ArchivedController < FormsController
53
def show_form
64
authorize current_form, :can_view_form?
75

app/controllers/forms/change_name_controller.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module Forms
2-
class ChangeNameController < WebController
3-
after_action :verify_authorized
4-
2+
class ChangeNameController < FormsController
53
def edit
64
authorize current_form, :can_view_form?
75
@name_input = NameInput.new(form: current_form).assign_form_values

app/controllers/forms/contact_details_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module Forms
2-
class ContactDetailsController < WebController
3-
after_action :verify_authorized
2+
class ContactDetailsController < FormsController
43
def new
54
authorize current_form, :can_view_form?
65
@contact_details_input = ContactDetailsInput.new(form: current_form).assign_form_values

app/controllers/forms/copy_controller.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module Forms
2-
class CopyController < WebController
3-
after_action :verify_authorized
4-
2+
class CopyController < FormsController
53
def copy
64
authorize current_form, :copy?
75

app/controllers/forms/daily_submission_batch_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module Forms
2-
class DailySubmissionBatchController < WebController
2+
class DailySubmissionBatchController < FormsController
33
before_action :check_feature_flag
4-
after_action :verify_authorized
54

65
def new
76
authorize current_form, :can_edit_form?

app/controllers/forms/declaration_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module Forms
2-
class DeclarationController < WebController
3-
after_action :verify_authorized
2+
class DeclarationController < FormsController
43
def new
54
authorize current_form, :can_view_form?
65
@declaration_input = DeclarationInput.new(form: current_form).assign_form_values

app/controllers/forms/delete_confirmation_controller.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module Forms
2-
class DeleteConfirmationController < WebController
3-
after_action :verify_authorized
4-
2+
class DeleteConfirmationController < FormsController
53
def delete
64
authorize current_form
75

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Forms::DraftController < FormsController
2+
def show
3+
authorize current_form, :can_view_form?
4+
task_service = FormTaskListService.call(form: current_form, current_user:)
5+
@task_list = task_service.all_sections
6+
@task_status_counts = task_service.task_counts
7+
render :show, locals: { current_form: }
8+
end
9+
end

0 commit comments

Comments
 (0)