-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Support accredited partnerships
- Loading branch information
1 parent
638ff5b
commit 986b5b1
Showing
15 changed files
with
334 additions
and
35 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
app/controllers/support/providers/accredited_partners/checks_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
module Support | ||
module Providers | ||
module AccreditedPartners | ||
class ChecksController < ApplicationController | ||
include ClearStashable | ||
|
||
def show | ||
accredited_provider_form | ||
end | ||
|
||
def update | ||
@partnership = provider.accredited_partnerships.build(accredited_provider_id: accredited_provider_form.accredited_provider_id, | ||
description: accredited_provider_form.description) | ||
if @partnership.save | ||
notify_accredited_provider_users | ||
|
||
redirect_to support_recruitment_cycle_provider_accredited_partners_path( | ||
recruitment_cycle.year, provider.id | ||
), flash: { success: 'Accredited partner added' } | ||
else | ||
render :show | ||
end | ||
end | ||
|
||
private | ||
|
||
def accredited_provider_form | ||
@accredited_provider_form ||= ProviderPartnershipForm.new(current_user, new_partnership) | ||
end | ||
|
||
def provider | ||
@provider ||= recruitment_cycle.providers.find(params[:provider_id]) | ||
end | ||
|
||
def new_partnership | ||
@new_partnership = provider.accredited_partnerships.build | ||
end | ||
|
||
def partner | ||
Provider.find(accredited_provider_form.accredited_provider_id) | ||
end | ||
|
||
def notify_accredited_provider_users | ||
@partnership.accredited_provider.users.each do |user| | ||
::Users::OrganisationMailer.added_as_an_organisation_to_training_partner( | ||
recipient: user, | ||
provider: provider, | ||
accredited_provider: @partnership.accredited_provider | ||
).deliver_later | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
app/views/support/providers/accredited_partners/_can_remove.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<%= content_for :page_title, t("support.providers.accredited_providers.delete.title") %> | ||
<% content_for :before_content do %> | ||
<%= govuk_back_link_to(support_recruitment_cycle_provider_accredited_partners_path) %> | ||
<% end %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-l"> | ||
<span class="govuk-caption-l"><%= @accredited_provider.provider_name %></span> | ||
<%= t("support.providers.accredited_partners.delete.title") %> | ||
</h1> | ||
|
||
<%= govuk_button_to "Remove accredited partner", | ||
delete_support_recruitment_cycle_provider_accredited_partner_path, | ||
method: :delete, | ||
class: "govuk-button--warning" %> | ||
|
||
<p class="govuk-body"> | ||
<%= govuk_link_to(t("cancel"), support_recruitment_cycle_provider_accredited_partners_path) %> | ||
</p> | ||
</div> | ||
</div> |
23 changes: 23 additions & 0 deletions
23
app/views/support/providers/accredited_partners/_cannot_remove.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<% content_for :page_title, "You cannot remove this accredited partner" %> | ||
<% content_for :before_content do %> | ||
<%= govuk_back_link_to(support_recruitment_cycle_provider_accredited_providers_path) %> | ||
<% end %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-l"> | ||
<span class="govuk-caption-l"><%= @accredited_provider.provider_name %></span> | ||
You cannot remove this accredited provider | ||
</h1> | ||
|
||
<p class="govuk-body"> | ||
<%= @accredited_provider.provider_name %> is an | ||
accredited partner for courses run by <%= @provider.provider_name %>. At least one of these courses is | ||
currently published on Find. | ||
</p> | ||
|
||
<p class="govuk-body"> | ||
<%= govuk_link_to(t("cancel"), support_recruitment_cycle_provider_accredited_partners_path) %> | ||
</p> | ||
</div> | ||
</div> |
42 changes: 42 additions & 0 deletions
42
app/views/support/providers/accredited_partners/checks/show.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
<%= render PageTitle.new( | ||
title: "Check your answers - #{t('.caption', provider_name: @provider.provider_name, code: @provider.provider_code)}" | ||
) %> | ||
|
||
<% content_for :before_content do %> | ||
<%= govuk_back_link_to(new_support_recruitment_cycle_provider_accredited_partner_path) %> | ||
<% end %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds-from-desktop"> | ||
|
||
<%= form_with(url: check_support_recruitment_cycle_provider_accredited_partners_path, method: :put, local: true) do |f| %> | ||
<h1 class="govuk-heading-l"> | ||
<span class="govuk-caption-l"><%= t(".caption", provider_name: @provider.provider_name, code: @provider.provider_code) %></span> | ||
Check your answers | ||
</h1> | ||
|
||
<%= render GovukComponent::SummaryListComponent.new do |component| | ||
component.with_row do |row| | ||
row.with_key { "Accredited provider" } | ||
row.with_value { @accredited_provider_form.provider_name } | ||
row.with_action(text: "Change", href: search_support_recruitment_cycle_provider_accredited_providers_path(goto_confirmation: true), visually_hidden_text: "accredited partner name") | ||
end | ||
|
||
component.with_row do |row| | ||
row.with_key { "About the accredited partner" } | ||
row.with_value { @accredited_provider_form.description } | ||
row.with_action(text: "Change", href: new_support_recruitment_cycle_provider_accredited_partner_path(goto_confirmation: true), visually_hidden_text: "accredited partner description") | ||
end | ||
end %> | ||
|
||
<%= govuk_warning_text(text: "All users at #{@accredited_provider_form.provider_name} will be sent an email to let them know they’ve been added.") %> | ||
|
||
<%= f.govuk_submit(t(".add")) %> | ||
<% end %> | ||
|
||
<p class="govuk-body"> | ||
<%= govuk_link_to(t("cancel"), support_recruitment_cycle_provider_accredited_partners_path) %> | ||
</p> | ||
</div> | ||
</div> |
1 change: 1 addition & 0 deletions
1
app/views/support/providers/accredited_partners/delete.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render partial: @cannot_delete ? "cannot_remove" : "can_remove" %> |
41 changes: 41 additions & 0 deletions
41
app/views/support/providers/accredited_partners/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<% content_for :page_title, title_with_error_prefix("About the accredited partnership - Edit accredited partnership - #{@provider.name_and_code}", @accredited_provider_form.errors.present?) %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
|
||
<%= content_for(:breadcrumbs) do %> | ||
<%= render GovukComponent::BackLinkComponent.new( | ||
text: "Back", | ||
href: support_recruitment_cycle_provider_accredited_partners_path( | ||
recruitment_cycle_year: @recruitment_cycle.year, | ||
provider_id: @provider.id | ||
) | ||
) %> | ||
<% end %> | ||
|
||
<%= form_with( | ||
model: @accredited_provider_form, | ||
url: support_recruitment_cycle_provider_accredited_partner_path, | ||
method: :put | ||
) do |f| %> | ||
|
||
<%= f.govuk_text_area( | ||
:description, | ||
label: { text: t(".title"), size: "l", tag: "h1" }, | ||
hint: { text: t(".hint") }, | ||
caption: { text: @accredited_provider_form.accredited_provider.provider_name, size: "l" }, | ||
max_words: 100, | ||
rows: 10 | ||
) %> | ||
<%= f.hidden_field :accredited_provider_id, value: @accredited_provider_form.accredited_provider.id %> | ||
|
||
<%= f.govuk_submit "Update description" %> | ||
|
||
<p class="govuk-body"> | ||
<%= govuk_link_to(t("cancel"), support_recruitment_cycle_provider_accredited_partners_path) %> | ||
</p> | ||
|
||
<% end %> | ||
|
||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/views/support/providers/accredited_partners/new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<% content_for :page_title, title_with_error_prefix("About the accredited partner - Add accredited partner - #{@provider.name_and_code}", @accredited_provider_form.errors.present?) %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
|
||
<%= form_with( | ||
model: @accredited_provider_form, | ||
url: support_recruitment_cycle_provider_accredited_partners_path, | ||
method: :post | ||
) do |f| %> | ||
|
||
<%= content_for(:breadcrumbs) do %> | ||
<%= render GovukComponent::BackLinkComponent.new( | ||
text: "Back", | ||
href: back_link_for_adding_accredited_partner_path(param_form_key: f.object_name.to_sym, params:, recruitment_cycle_year: @recruitment_cycle.year, provider: @provider) | ||
) %> | ||
<% end %> | ||
|
||
<%= f.govuk_error_summary %> | ||
|
||
<%= f.govuk_text_area( | ||
:description, | ||
label: { text: t(".title"), size: "l", tag: "h1" }, | ||
hint: { text: t(".hint") }, | ||
caption: { text: t(".caption", provider_name: @provider.provider_name, code: @provider.provider_code), size: "l" }, | ||
max_words: 100, | ||
rows: 10 | ||
) %> | ||
|
||
<%= f.hidden_field :accredited_provider_id, value: accredited_provider_id %> | ||
<%= f.govuk_submit t("continue") %> | ||
<% end %> | ||
|
||
<p class="govuk-body"> | ||
<%= govuk_link_to(t("cancel"), support_recruitment_cycle_provider_accredited_partners_path) %> | ||
</p> | ||
</div> | ||
</div> |
Oops, something went wrong.