Skip to content

Commit

Permalink
Merge pull request #951 from DFE-Digital/feature/sen-tasklist
Browse files Browse the repository at this point in the history
Feature/external application form
  • Loading branch information
paullocknimble authored Dec 4, 2023
2 parents 87a20e4 + 547a0e8 commit f64a6ec
Show file tree
Hide file tree
Showing 23 changed files with 241 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.4" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="FluentAssertions" Version="6.9.0" />
<PackageReference Include="MELT" Version="0.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.8.2" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.4" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Dfe.Academisation.CorrelationIdMiddleware" Version="2.0.2" />
<PackageReference Include="Dfe.Academisation.ExtensionMethods" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Dfe.PrepareConversions.Data.Models;
using Dfe.PrepareConversions.Data.Services;
using Microsoft.FeatureManagement;
using System.Dynamic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
Expand Down Expand Up @@ -55,4 +56,15 @@ public async Task<HttpResponseMessage> AddProjectNote(int id, AddProjectNote pro
{
return await AcademisationClient.PostAsync(string.Format(PathFor.AddProjectNote, id), JsonContent.Create(projectNote));
}

public async Task<HttpResponseMessage> SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl)
{
var payload = new
{
externalApplicationFormSaved = externalApplicationFormSaved,
externalApplicationFormUrl = externalApplicationFormUrl ?? string.Empty
};

return await AcademisationClient.PutAsync(string.Format(PathFor.SetExternalApplicationForm, id), JsonContent.Create(payload));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public interface IApiClient
Task<HttpResponseMessage> GetFilterParametersAsync();
Task<HttpResponseMessage> GetApplicationByReferenceAsync(string id);
Task<HttpResponseMessage> AddProjectNote(int id, AddProjectNote projectNote);

Task<HttpResponseMessage> SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ public PathFor(IFeatureManager features)
public static string UpdateProject => "/legacy/project/{0}";
public static string GetFilterParameters => "/legacy/projects/status";
public static string AddProjectNote => "/legacy/project/{0}/notes";
public static string SetExternalApplicationForm => "/conversion-project/{0}/setExternalApplicationForm";
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public class AcademyConversionProject
public bool? AnnexBFormReceived { get; set; }
public string AnnexBFormUrl { get; set; }

// External Application Form
public bool? ExternalApplicationFormSaved { get; set; }
public string? ExternalApplicationFormUrl { get; set; }

Check warning on line 59 in Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

// School Overview
public string PublishedAdmissionNumber { get; set; }
public string PartOfPfiScheme { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public class UpdateAcademyConversionProject
public bool? AnnexBFormReceived { get; set; }
public string AnnexBFormUrl { get; set; }

// External Application Form
public bool? ExternalApplicationFormSaved { get; set; }
public string ExternalApplicationFormUrl { get; set; }

//school performance ofsted information
public string SchoolPerformanceAdditionalInformation { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,10 @@ private async Task<T> ReadFromJsonAndThrowIfNull<T>(HttpContent content)
}
return responseObj;
}

public async Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl)
{
HttpResponseMessage result = await _apiClient.SetProjectExternalApplicationForm(id, externalApplicationFormSaved, externalApplicationFormUrl);
if (result.IsSuccessStatusCode is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Task<ApiResponse<ApiV2Wrapper<IEnumerable<AcademyConversionProject>>>> GetAllPro
Task<ApiResponse<AcademyConversionProject>> GetProjectById(int id);
Task<ApiResponse<AcademyConversionProject>> UpdateProject(int id, UpdateAcademyConversionProject updateProject);
Task CreateProject(CreateNewProject newProject);
Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl);
Task<ApiResponse<ProjectFilterParameters>> GetFilterParameters();
Task<ApiResponse<ProjectNote>> AddProjectNote(int id, AddProjectNote addProjectNote);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.4" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.4" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Open-XML-SDK" Version="2.9.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.4" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="AngleSharp.Io" Version="1.0.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.4" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="FluentAssertions" Version="6.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.11" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.11" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<UserSecretsId>eae6d8bd-2a58-4ed4-99e2-a82f32b0ce47</UserSecretsId>
Expand Down Expand Up @@ -35,7 +35,7 @@

<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.0.1" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.4" />
<PackageReference Include="Dfe.Academies.Contracts" Version="1.0.9" />
<PackageReference Include="Dfe.Academisation.CorrelationIdMiddleware" Version="2.0.2" />
<PackageReference Include="Dfe.Academisation.ExtensionMethods" Version="2.0.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
Expand Down
6 changes: 6 additions & 0 deletions Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public static class AnnexB
public static readonly LinkItem Edit = AddLinkItem(page: "/AnnexB/Edit");
}

public static class ExternalApplicationForm
{
public static readonly LinkItem Index = AddLinkItem(backText: "Back", page: "/ExternalApplicationForm/Index");
public static readonly LinkItem Edit = AddLinkItem(page: "/ExternalApplicationForm/Edit");
}

public static class ProjectType
{
public static readonly LinkItem Index = AddLinkItem(backText: "Back", page: "/ProjectType/Index");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@page "/task-list/{id:int}/ExternalApplicationForm/edit"
@using Dfe.PrepareConversions.TagHelpers
@model Dfe.PrepareConversions.Pages.ExternalApplicationForm.EditModel
@{
ViewData["Title"] = "Have you saved the School Application form";
}

@section BeforeMain
{
<a asp-page="@Links.ExternalApplicationForm.Index.Page" asp-route-id="@Model.Project.Id" class="govuk-back-link">@Links.ExternalApplicationForm.Index.BackText</a>
<partial name="_ErrorSummary"/>
}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<form method="post">
<span class="govuk-caption-l">@Model.Project.SchoolName</span>
<h1 class="govuk-heading-l">Have you saved the school's completed Application form in SharePoint?</h1>
<div class="govuk-form-group">
<div class="govuk-radios" data-module="govuk-radios">
<div class="govuk-radios__item">
<input asp-for="@Model.YesChecked" class="govuk-radios__input" type="radio" value="true" aria-controls="conditional-applicationsaved" id="radio-yes" data-cy="select-radio-yes">
<label class="govuk-label govuk-radios__label" for="radio-yes">
Yes
</label>
</div>

<div class="govuk-radios__conditional" id="conditional-applicationsaved" data-cy="select-sharepoint-section">
<div class="govuk-form-group @ModelState.GetErrorStyleClass()">
<label class="govuk-label" for="application-form-url">
What is the link for the Application form?
</label>

<inline-error for="@nameof(Model.ExternalApplicationFormUrl)"/>
<textarea asp-for="@Model.ExternalApplicationFormUrl" class="govuk-textarea @ModelState.GetTextAreaErrorStyles(nameof(Model.ExternalApplicationFormUrl))" rows="5" aria-describedby="application-form-url-hint" data-cy="select-sharepoint-url" aria-label="text-area-for-application-form"></textarea>
</div>
</div>

<div class="govuk-radios__item">
<input asp-for="@Model.YesChecked" 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">
No
</label>
</div>
</div>
</div>

<button class="govuk-button" data-module="govuk-button" data-cy="select-save-and-continue">
Save and continue
</button>
</form>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Dfe.PrepareConversions.Data;
using Dfe.PrepareConversions.Data.Models;
using Dfe.PrepareConversions.Data.Services;
using Dfe.PrepareConversions.Models;
using Dfe.PrepareConversions.Services;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace Dfe.PrepareConversions.Pages.ExternalApplicationForm;

public class EditModel : BaseAcademyConversionProjectPageModel
{
private readonly ErrorService _errorService;

public EditModel(IAcademyConversionProjectRepository repository, ErrorService errorService) : base(repository)
{
_errorService = errorService;
}

[BindProperty]
public bool? YesChecked { get; set; }

[BindProperty]
public string ExternalApplicationFormUrl { get; set; }

public override async Task<IActionResult> OnGetAsync(int id)
{
await base.OnGetAsync(id);

YesChecked = Project.ExternalApplicationFormSaved;
ExternalApplicationFormUrl = Project.ExternalApplicationFormUrl;

return Page();
}

public override async Task<IActionResult> OnPostAsync(int id)
{
if (YesChecked is true && string.IsNullOrWhiteSpace(ExternalApplicationFormUrl))
{
ModelState.AddModelError(nameof(ExternalApplicationFormUrl), "You must enter valid link for the schools application form");
}

if (ModelState.IsValid)
{

await _repository.SetProjectExternalApplicationForm(id, YesChecked.Value, YesChecked is true ? ExternalApplicationFormUrl : default);


return RedirectToPage(Links.ExternalApplicationForm.Index.Page, new { id });
}

_errorService.AddErrors(ModelState.Keys, ModelState);
return await base.OnGetAsync(id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@page "/task-list/{id:int}/ExternalApplicationForm"
@using Dfe.PrepareConversions.TagHelpers
@model Dfe.PrepareConversions.Pages.ExternalApplicationForm.IndexModel
@{
ViewData["Title"] = "School application form";
}

@section BeforeMain
{
<a asp-page="@Links.ProjectList.Index.Page" class="govuk-back-link">@Links.ProjectList.Index.BackText</a>
}

<partial name="_ProjectHeader" model="@Model.Project"/>

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<dl class="govuk-summary-list">

<div class="govuk-summary-list__row" data-cy="select-annex-b-form-returned">
<dt class="govuk-summary-list__key govuk-!-width-one-third">
Have you saved the school's completed application form in SharePoint?
</dt>
<dd class="govuk-summary-list__value" data-cy="select-annex-b-form-returned-answer">
<span if="Model.AplicationFormSaved.HasValue is false" class="empty">Empty</span>
<span if="Model.AplicationFormSaved is true" id="la-info-template-comments">Yes</span>
<span if="Model.AplicationFormSaved is false" id="la-info-template-comments">No</span>
</dd>
<dd class="govuk-summary-list__actions" data-cy="select-annex-b-form-returned-change">
<a asp-page="@Links.ExternalApplicationForm.Edit.Page" asp-route-id="@Model.Project.Id" class="govuk-link">
Change<span class="govuk-visually-hidden">External application form saved for the school</span>
</a>
</dd>
</div>

<div if="Model.HasLink" class="govuk-summary-list__row" data-cy="select-annex-b-sharepoint-link">
<dt class="govuk-summary-list__key govuk-!-width-one-third">
SharePoint link
</dt>
<dd class="govuk-summary-list__value" data-cy="select-annex-b-sharepoint-url">
<a href="@Model.ApplicationFormLink" target="_blank" rel="noopener" aria-label="Application form (opens in a new tab)">@Model.ApplicationFormLink</a>
</dd>
<dd class="govuk-summary-list__actions" data-cy="select-annex-b-sharepoint-change">
<a asp-page="@Links.ExternalApplicationForm.Edit.Page" asp-route-id="@Model.Project.Id" class="govuk-link">
Change<span class="govuk-visually-hidden">school application form url</span>
</a>
</dd>
</div>
</dl>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Dfe.PrepareConversions.Data.Services;

namespace Dfe.PrepareConversions.Pages.ExternalApplicationForm;

public class IndexModel : BaseAcademyConversionProjectPageModel
{
public IndexModel(IAcademyConversionProjectRepository repository) : base(repository)
{
}

public bool HasLink => string.IsNullOrWhiteSpace(Project.ExternalApplicationFormUrl) is false;

public bool? AplicationFormSaved => Project.ExternalApplicationFormSaved;
public string ApplicationFormLink => Project.ExternalApplicationFormUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,28 @@
</sub-menu-link>
</li>

<li if="@Model.IsVoluntary" class="moj-sub-navigation__item">
<li if="@Model.IsVoluntary && !Model.IsExternalSchoolApplication" class="moj-sub-navigation__item">
<sub-menu-link class="moj-sub-navigation__link"
asp-page="@Links.ApplicationForm.Index.Page"
asp-route-id="@id">
School application form
</sub-menu-link>
</li>

<li if="@Model.IsSponsored" class="moj-sub-navigation__item">
<li if="@Model.IsSponsored" class="moj-sub-navigation__item">
<sub-menu-link class="moj-sub-navigation__link"
asp-page="@Links.AnnexB.Index.Page"
asp-route-id="@id">
Annex B form
</sub-menu-link>
</li>
<li if="@Model.IsVoluntary && Model.IsExternalSchoolApplication" class="moj-sub-navigation__item">
<sub-menu-link class="moj-sub-navigation__link"
asp-page="@Links.ExternalApplicationForm.Index.Page"
asp-route-id="@id">
School application form
</sub-menu-link>
</li>
<li class="moj-sub-navigation__item">
<sub-menu-link class="moj-sub-navigation__link"
asp-page="@Links.Decision.SubMenuRecordADecision.Page"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ public async Task<ApiResponse<ProjectNote>> AddProjectNote(int id, AddProjectNot
{
return await _innerRepository.AddProjectNote(id, addProjectNote);
}

public async Task SetProjectExternalApplicationForm(int id, bool externalApplicationFormSaved, string externalApplicationFormUrl)
{
await _innerRepository.SetProjectExternalApplicationForm(id, externalApplicationFormSaved, externalApplicationFormUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Dfe.PrepareConversions.ViewModels;
public abstract class ProjectTypeBase
{
protected abstract string TypeAndRouteValue { get; }
public virtual bool IsExternalSchoolApplication { get; } = false;


public bool IsSponsored => string.IsNullOrWhiteSpace(TypeAndRouteValue) is false &&
TypeAndRouteValue.Equals(AcademyTypeAndRoutes.Sponsored, StringComparison.InvariantCultureIgnoreCase);
Expand Down
Loading

0 comments on commit f64a6ec

Please sign in to comment.