This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #750 from DFE-Digital/feature/150886-KIM-Changes-F…
…or-Academies Feature/150886 kim changes for academies
- Loading branch information
Showing
21 changed files
with
776 additions
and
13 deletions.
There are no files selected for viewing
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
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
69 changes: 69 additions & 0 deletions
69
Dfe.PrepareTransfers.Web/Pages/Projects/GeneralInformation/DistanceFromTrust.cshtml
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,69 @@ | ||
@page "/project/{urn}/general-information/{academyUkprn}/distance-from-trust"; | ||
|
||
@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers | ||
@using Microsoft.AspNetCore.Mvc.TagHelpers | ||
@model Dfe.PrepareTransfers.Web.Pages.Projects.GeneralInformation.DistanceFromTrustModel | ||
|
||
@{ | ||
ViewBag.Title = (!ViewData.ModelState.IsValid ? "Error: " : "") + "How far is the converting school from the trust"; | ||
Layout = "_Layout"; | ||
|
||
var formClasses = ViewData.ModelState.IsValid ? string.Empty : "govuk-form-group--error"; | ||
} | ||
|
||
@section BeforeMain | ||
{ | ||
<backtopreview urn="@Model.Urn" return-to-preview="@Model.ReturnToPreview"> | ||
<a class="govuk-back-link" | ||
asp-page="/Projects/GeneralInformation/Index" | ||
asp-route-urn="@Model.Urn" | ||
asp-route-academyUkprn="@Model.AcademyUkprn">Back</a> | ||
</backtopreview> | ||
|
||
} | ||
|
||
<div asp-gds-validation-summary></div> | ||
|
||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
|
||
<div class="govuk-form-group @formClasses"> | ||
<fieldset class="govuk-fieldset" aria-describedby="diocesan-consent-hint"> | ||
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l"> | ||
<h1 class="govuk-fieldset__heading" data-test="header"> | ||
<span class="govuk-caption-l"> | ||
@Model.AcademyName | ||
</span> | ||
How far is the transferring academies from the trust or other academies in the trust? | ||
</h1> | ||
<p class="govuk-body">Use the academy and trust's postcodes to measure the distance on Bing or Google maps.</p> | ||
<div id="distance-to-trust-headquarters-hint" class="govuk-hint"> | ||
For example, 20 | ||
</div> | ||
|
||
<form method="post"> | ||
<div class="govuk-form-group"> | ||
<div class="govuk-input__wrapper"> | ||
<input class="govuk-input govuk-input--width-10" id="distance-to-trust-headquarters" name="DistanceToTrust" type="text" value="@Model.DistanceToTrust"> | ||
<div class="govuk-input__suffix" aria-hidden="true">miles</div> | ||
</div> | ||
</div> | ||
|
||
<label class="govuk-label"> | ||
Add any additional information if you need to | ||
</label> | ||
<div id="distance-to-trust-headquarters-hint" class="govuk-hint"> | ||
This information will go into your project template under the academy overview section. | ||
</div> | ||
<textarea class="govuk-textarea" rows="5" data-test="distance-to-trust-headquarters-additional-information" name="DistanceFromAcademyToTrustHqDetails">@Model.DistanceFromAcademyToTrustHqDetails</textarea> | ||
<button class="govuk-button govuk-!-margin-top-4" data-module="govuk-button" type="submit" data-test="submit-btn"> | ||
Save and continue | ||
</button> | ||
</form> | ||
|
||
|
||
</div> | ||
</div> | ||
<partial name="_UsefulInformation" /> | ||
</div> |
84 changes: 84 additions & 0 deletions
84
Dfe.PrepareTransfers.Web/Pages/Projects/GeneralInformation/DistanceFromTrust.cshtml.cs
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,84 @@ | ||
using Dfe.PrepareTransfers.Data; | ||
using Dfe.PrepareTransfers.Web.Models; | ||
using Dfe.PrepareTransfers.Web.Models.Forms; | ||
using Dfe.PrepareTransfers.Web.Services.Interfaces; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Dfe.PrepareTransfers.Web.Pages.Projects.GeneralInformation | ||
{ | ||
public class DistanceFromTrustModel : CommonPageModel | ||
{ | ||
public string AcademyName { get; set; } | ||
|
||
[BindProperty] public string DistanceToTrust { get; set; } | ||
[BindProperty] public string DistanceFromAcademyToTrustHqDetails { get; set; } | ||
|
||
public bool IsPreview { get; set; } | ||
|
||
[BindProperty(SupportsGet = true)] public string AcademyUkprn { get; set; } | ||
|
||
private readonly IGetInformationForProject _getInformationForProject; | ||
private readonly IProjects _projectsRepository; | ||
|
||
public DistanceFromTrustModel(IGetInformationForProject getInformationForProject, IProjects projectsRepository) | ||
{ | ||
_getInformationForProject = getInformationForProject; | ||
_projectsRepository = projectsRepository; | ||
} | ||
|
||
public async Task<IActionResult> OnGetAsync() | ||
{ | ||
var projectInformation = await _getInformationForProject.Execute(Urn); | ||
var academy = projectInformation.OutgoingAcademies.First(a => a.Ukprn == AcademyUkprn); | ||
|
||
OutgoingAcademyUrn = academy.Urn; | ||
AcademyName = academy.Name; | ||
DistanceToTrust = academy.DistanceFromAcademyToTrustHq; | ||
DistanceFromAcademyToTrustHqDetails = academy.DistanceFromAcademyToTrustHqDetails; | ||
|
||
return Page(); | ||
} | ||
|
||
public async Task<IActionResult> OnPostAsync() | ||
{ | ||
|
||
if (string.IsNullOrEmpty(DistanceToTrust)) | ||
{ | ||
ModelState.AddModelError(nameof(DistanceToTrust), "Please provide distance to trust."); | ||
} | ||
else if (!decimal.TryParse(DistanceToTrust, out var distanceToTrust)) | ||
{ | ||
ModelState.AddModelError(nameof(DistanceToTrust), "Please provide a valid distance to trust."); | ||
} | ||
else | ||
{ | ||
DistanceToTrust = distanceToTrust.ToString(); | ||
} | ||
|
||
if (!ModelState.IsValid) | ||
{ | ||
// Return the current page with validation errors | ||
return Page(); | ||
} | ||
|
||
var model = await _projectsRepository.GetByUrn(Urn); | ||
|
||
var academy = model.Result.TransferringAcademies.First(a => a.OutgoingAcademyUkprn == AcademyUkprn); | ||
|
||
academy.DistanceFromAcademyToTrustHq = DistanceToTrust; | ||
academy.DistanceFromAcademyToTrustHqDetails = DistanceFromAcademyToTrustHqDetails; | ||
|
||
await _projectsRepository.UpdateAcademyGeneralInformation(model.Result.Urn, academy); | ||
|
||
if (ReturnToPreview) | ||
{ | ||
return RedirectToPage(Links.HeadteacherBoard.Preview.PageName, new { Urn }); | ||
} | ||
|
||
return Redirect($"/project/{Urn}/general-information/{AcademyUkprn}"); | ||
} | ||
|
||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
Dfe.PrepareTransfers.Web/Pages/Projects/GeneralInformation/FinancialDeficit.cshtml
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,65 @@ | ||
@page "/project/{urn}/general-information/{academyUkprn}/financial-deficit"; | ||
|
||
@using Dfe.PrepareTransfers.Web.Dfe.PrepareTransfers.Helpers.TagHelpers | ||
@using Microsoft.AspNetCore.Mvc.TagHelpers | ||
@model Dfe.PrepareTransfers.Web.Pages.Projects.GeneralInformation.FinancialDeficitModel | ||
|
||
@{ | ||
ViewBag.Title = (!ViewData.ModelState.IsValid ? "Error: " : "") + "Financial Deficit"; | ||
Layout = "_Layout"; | ||
|
||
var formClasses = ViewData.ModelState.IsValid ? string.Empty : "govuk-form-group--error"; | ||
} | ||
|
||
@section BeforeMain | ||
{ | ||
<backtopreview urn="@Model.Urn" return-to-preview="@Model.ReturnToPreview"> | ||
<a class="govuk-back-link" | ||
asp-page="/Projects/GeneralInformation/Index" | ||
asp-route-urn="@Model.Urn" | ||
asp-route-academyUkprn="@Model.AcademyUkprn">Back</a> | ||
</backtopreview> | ||
|
||
} | ||
|
||
<div asp-gds-validation-summary></div> | ||
|
||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
|
||
<div class="govuk-form-group @formClasses"> | ||
<fieldset class="govuk-fieldset" aria-describedby="diocesan-consent-hint"> | ||
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l"> | ||
<h1 class="govuk-fieldset__heading" data-test="header"> | ||
<span class="govuk-caption-l"> | ||
@Model.AcademyName | ||
</span> | ||
Is there a financial deficit at the academy in its current financial year? | ||
</h1> | ||
<form method="post"> | ||
<div class="govuk-form-group"> | ||
<div class="govuk-radios govuk-!-margin-top-4" data-module="govuk-radios"> | ||
<div class="govuk-radios__item"> | ||
<input asp-for="@Model.YesChecked" data-test="financial-defecit-yes-input" class="govuk-radios__input" type="radio" value="true" id="radio-yes" data-cy="select-radio-yes"> | ||
<label class="govuk-label govuk-radios__label" for="radio-yes" data-test="financial-defecit-yes-label"> | ||
Yes | ||
</label> | ||
</div> | ||
|
||
<div class="govuk-radios__item"> | ||
<input asp-for="@Model.YesChecked" data-test="financial-defecit-no-input" class="govuk-radios__input" type="radio" value="false" id="radio-no" data-cy="select-radio-no"> | ||
<label class="govuk-label govuk-radios__label" for="radio-no" data-test="financial-defecit-no-label"> | ||
No | ||
</label> | ||
</div> | ||
</div> | ||
<button class="govuk-button govuk-!-margin-top-4" data-module="govuk-button" type="submit" data-test="submit-btn"> | ||
Save and continue | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
<partial name="_UsefulInformation" /> | ||
</div> |
73 changes: 73 additions & 0 deletions
73
Dfe.PrepareTransfers.Web/Pages/Projects/GeneralInformation/FinancialDeficit.cshtml.cs
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,73 @@ | ||
using Dfe.PrepareTransfers.Data; | ||
using Dfe.PrepareTransfers.Web.Models; | ||
using Dfe.PrepareTransfers.Web.Models.Forms; | ||
using Dfe.PrepareTransfers.Web.Services.Interfaces; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Dfe.PrepareTransfers.Web.Pages.Projects.GeneralInformation | ||
{ | ||
public class FinancialDeficitModel : CommonPageModel | ||
{ | ||
public string AcademyName { get; set; } | ||
|
||
public bool IsPreview { get; set; } | ||
|
||
[BindProperty] | ||
public bool? YesChecked { get; set; } | ||
|
||
[BindProperty(SupportsGet = true)] public string AcademyUkprn { get; set; } | ||
|
||
private readonly IGetInformationForProject _getInformationForProject; | ||
private readonly IProjects _projectsRepository; | ||
|
||
public FinancialDeficitModel(IGetInformationForProject getInformationForProject, IProjects projectsRepository) | ||
{ | ||
_getInformationForProject = getInformationForProject; | ||
_projectsRepository = projectsRepository; | ||
} | ||
|
||
public async Task<IActionResult> OnGetAsync() | ||
{ | ||
var projectInformation = await _getInformationForProject.Execute(Urn); | ||
var academy = projectInformation.OutgoingAcademies.First(a => a.Ukprn == AcademyUkprn); | ||
var pupilNumbers = academy.PupilNumbers; | ||
YesChecked = academy.FinancialDeficit?.ToLower().Contains("yes") ?? false; | ||
|
||
OutgoingAcademyUrn = academy.Urn; | ||
AcademyName = academy.Name; | ||
return Page(); | ||
} | ||
|
||
public async Task<IActionResult> OnPostAsync() | ||
{ | ||
if (!YesChecked.HasValue) | ||
{ | ||
ModelState.AddModelError("Financial Deficit", "Please select an option."); | ||
} | ||
|
||
if (!ModelState.IsValid) | ||
{ | ||
// Return the current page with validation errors | ||
return Page(); | ||
} | ||
|
||
var model = await _projectsRepository.GetByUrn(Urn); | ||
|
||
var academy = model.Result.TransferringAcademies.First(a => a.OutgoingAcademyUkprn == AcademyUkprn); | ||
|
||
academy.FinancialDeficit = YesChecked == true ? "Yes " : "No"; | ||
|
||
await _projectsRepository.UpdateAcademyGeneralInformation(model.Result.Urn, academy); | ||
|
||
if (ReturnToPreview) | ||
{ | ||
return RedirectToPage(Links.HeadteacherBoard.Preview.PageName, new { Urn }); | ||
} | ||
|
||
return Redirect($"/project/{Urn}/general-information/{AcademyUkprn}"); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.