Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #750 from DFE-Digital/feature/150886-KIM-Changes-F…
Browse files Browse the repository at this point in the history
…or-Academies

Feature/150886 kim changes for academies
  • Loading branch information
elielijah321 authored Jun 12, 2024
2 parents 00d308e + 235a8b6 commit 5acd411
Show file tree
Hide file tree
Showing 21 changed files with 776 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ public static TransferringAcademyGeneralInformationUpdate TransferringAcademyGen
{
TransferringAcademyUkprn = input.OutgoingAcademyUkprn,
PFIScheme = input.PFIScheme ?? string.Empty,
PFISchemeDetails = input.PFISchemeDetails ?? string.Empty
PFISchemeDetails = input.PFISchemeDetails ?? string.Empty,
DistanceFromAcademyToTrustHq = input.DistanceFromAcademyToTrustHq?.ToString() ?? string.Empty,
DistanceFromAcademyToTrustHqDetails = input.DistanceFromAcademyToTrustHqDetails ?? string.Empty,
ViabilityIssues = input.ViabilityIssues ?? string.Empty,
FinancialDeficit = input.FinancialDeficit ?? string.Empty,
MPNameAndParty = input.MPNameAndParty ?? string.Empty,
PublishedAdmissionNumber = input.PublishedAdmissionNumber ?? string.Empty
};
}
public static AcademyTransferProjectBenefits Benefits(Project input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ private static List<TransferringAcademy> TransferringAcademies(AcademisationProj
KeyStage4PerformanceAdditionalInformation = transfer.KeyStage4PerformanceAdditionalInformation,
KeyStage5PerformanceAdditionalInformation = transfer.KeyStage5PerformanceAdditionalInformation,
PFIScheme = transfer.PFIScheme,
PFISchemeDetails = transfer.PFISchemeDetails
PFISchemeDetails = transfer.PFISchemeDetails,
DistanceFromAcademyToTrustHq = transfer.DistanceFromAcademyToTrustHq,
DistanceFromAcademyToTrustHqDetails = transfer.DistanceFromAcademyToTrustHqDetails,
ViabilityIssues = transfer.ViabilityIssues,
FinancialDeficit = transfer.FinancialDeficit,
MPNameAndParty = transfer.MPNameAndParty,
PublishedAdmissionNumber = transfer.PublishedAdmissionNumber
}
)
.ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public class TransferringAcademy
public string KeyStage5PerformanceAdditionalInformation { get; set; }
public string PFIScheme { get; set; }
public string PFISchemeDetails { get; set; }
public string ViabilityIssues { get; set; }
public string FinancialDeficit { get; set; }
public string MPNameAndParty { get; set; }
public string DistanceFromAcademyToTrustHq { get; set; }
public string DistanceFromAcademyToTrustHqDetails { get; set; }
public string PublishedAdmissionNumber { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ public class TransferringAcademyGeneralInformationUpdate
public string TransferringAcademyUkprn { get; set; }
public string PFIScheme { get; set; }
public string PFISchemeDetails { get; set; }
public string DistanceFromAcademyToTrustHq { get; set; }
public string DistanceFromAcademyToTrustHqDetails { get; set; }
public string ViabilityIssues { get; set; }
public string FinancialDeficit { get; set; }
public string MPNameAndParty { get; set; }
public string PublishedAdmissionNumber { get; set; }

}
}
6 changes: 6 additions & 0 deletions Dfe.PrepareTransfers.Data/Models/Academy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public Academy()
public string FaithSchool { get; set; }
public string PFIScheme { get; set; }
public string PFISchemeDetails { get; set; }
public string ViabilityIssues { get; set; }
public string FinancialDeficit { get; set; }
public string MPNameAndParty { get; set; }
public string DistanceFromAcademyToTrustHq { get; set; }
public string DistanceFromAcademyToTrustHqDetails { get; set; }
public string PublishedAdmissionNumber { get; set; }
public GeneralInformation GeneralInformation { get; set; }
public PupilNumbers PupilNumbers { get; set; }
public LatestOfstedJudgement LatestOfstedJudgement { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public class TransferringAcademy
public string OutgoingAcademyUrn { get; set; }
public string? PFIScheme { get; set; }
public string? PFISchemeDetails { get; set; }
public string? DistanceFromAcademyToTrustHq { get; set; }
public string? DistanceFromAcademyToTrustHqDetails{ get; set; }
public string? ViabilityIssues { get; set; }
public string? FinancialDeficit { get; set; }
public string? MPNameAndParty { get; set; }
public string? PublishedAdmissionNumber { get; set; }

public string PupilNumbersAdditionalInformation { get; set; }
public string LatestOfstedReportAdditionalInformation { get; set; }
Expand Down
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>
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}");
}

}
}
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>
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}");
}

}
}
Loading

0 comments on commit 5acd411

Please sign in to comment.