Skip to content

Commit

Permalink
Renamed WithdrawnDuringPreopening project status enum to "IN pre-open…
Browse files Browse the repository at this point in the history
…ing" to match UI. Also including "during pre-opening" in the filter for legacy data (#951)

* Renamed Withdrawn during pre-opening to
 IN pre-opening to reflect filter & change status change

* fix code smellings
  • Loading branch information
zhodges-nimble authored Nov 7, 2024
1 parent 68a7cb8 commit 081dd94
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ public enum ProjectStatus
Cancelled,

[Description("Withdrawn in pre-opening")]
WithdrawnInPreOpening,

//Possible legacy value
[Description("Withdrawn during pre-opening")]
WithdrawnDuringPreOpening,

[Description("Application competition stage")]
ApplicationCompetitionStage,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void ToTrustType_ReturnsExpectedEnum(string input, TrustType expectedResu
[InlineData("Cancelled",ProjectStatus.Cancelled)]
[InlineData("Cancelled during pre-opening",ProjectStatus.Cancelled)]
[InlineData("Closed",ProjectStatus.Closed)]
[InlineData("Withdrawn during pre-opening",ProjectStatus.WithdrawnDuringPreOpening)]
[InlineData("Withdrawn in pre-opening",ProjectStatus.WithdrawnDuringPreOpening)]
[InlineData("Withdrawn during pre-opening",ProjectStatus.WithdrawnInPreOpening)]
[InlineData("Withdrawn in pre-opening",ProjectStatus.WithdrawnInPreOpening)]
[InlineData("Application Competition stage",ProjectStatus.ApplicationCompetitionStage)]
[InlineData("Application stage",ProjectStatus.ApplicationStage)]
[InlineData("Open free school - Not included in figures", ProjectStatus.OpenNotIncludedInFigures)]
Expand All @@ -72,7 +72,7 @@ public void ToProjectStatusType_ReturnsExpectedEnum(string input, ProjectStatus
//[InlineData("AnyNotRecognised", ProjectStatus.Preopening)]
[InlineData(ProjectStatus.Cancelled, "Cancelled during pre-opening")]
[InlineData(ProjectStatus.Closed, "Closed")]
[InlineData(ProjectStatus.WithdrawnDuringPreOpening, "Withdrawn in pre-opening")]
[InlineData(ProjectStatus.WithdrawnInPreOpening, "Withdrawn in pre-opening")]
[InlineData(ProjectStatus.ApplicationCompetitionStage, "Application Competition stage")]
[InlineData(ProjectStatus.ApplicationStage, "Application stage")]
[InlineData(ProjectStatus.OpenNotIncludedInFigures, "Open free school - Not included in figures")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ValidationResult Execute(ValidationCommandParameters<BulkEditDto> paramet
ProjectStatus.Cancelled,
ProjectStatus.Open,
ProjectStatus.Closed,
ProjectStatus.WithdrawnDuringPreOpening
ProjectStatus.WithdrawnInPreOpening
];

ProjectStatus? status = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dfe.ManageFreeSchoolProjects.API.Contracts.Dashboard;
using Dfe.ManageFreeSchoolProjects.API.Contracts.Project;
using Dfe.ManageFreeSchoolProjects.API.Extensions;
using Dfe.ManageFreeSchoolProjects.API.UseCases.Project;
using Dfe.ManageFreeSchoolProjects.Data;
Expand Down Expand Up @@ -79,9 +80,15 @@ private static IQueryable<Kpi> ApplyFilters(IQueryable<Kpi> query, GetDashboardP

if (parameters.ProjectManagedBy.Count != 0)
query = query.Where(kpi => parameters.ProjectManagedBy.Any(projectManagedBy => kpi.KeyContactsFsgLeadContact == projectManagedBy));

if (parameters.ProjectStatus.Count != 0)
query = query.Where(kpi => parameters.ProjectStatus.Any(projectStatus => kpi.ProjectStatusProjectStatus == projectStatus));

var projectStatuses = parameters.ProjectStatus;
if (projectStatuses.Count != 0)
{
if (projectStatuses.Exists(x => x == ProjectStatus.WithdrawnInPreOpening.ToDescription()))
projectStatuses.Add(ProjectStatus.WithdrawnDuringPreOpening.ToDescription());

query = query.Where(kpi => projectStatuses.Any(projectStatus => kpi.ProjectStatusProjectStatus == projectStatus));
}

if (!string.IsNullOrEmpty(parameters.Wave))
query = query.Where(kpi => kpi.ProjectStatusFreeSchoolApplicationWave == parameters.Wave);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public static ProjectStatusType ToProjectStatusType(string projectStatus)
"closed" => ProjectStatusType.Closed,
"cancelled during pre-opening" => ProjectStatusType.Cancelled,
"cancelled" => ProjectStatusType.Cancelled,
"withdrawn during pre-opening" => ProjectStatusType.WithdrawnDuringPreOpening,
"withdrawn in pre-opening" => ProjectStatusType.WithdrawnDuringPreOpening,
"withdrawn during pre-opening" => ProjectStatusType.WithdrawnInPreOpening,
"withdrawn in pre-opening" => ProjectStatusType.WithdrawnInPreOpening,
"rejected at application stage" => ProjectStatusType.Rejected,
"application competition stage" => ProjectStatusType.ApplicationCompetitionStage,
"application stage" => ProjectStatusType.ApplicationStage,
Expand All @@ -111,7 +111,7 @@ public static string FromProjectStatusType(ProjectStatusType projectStatus)
ProjectStatusType.Open => "Open",
ProjectStatusType.Closed => "Closed",
ProjectStatusType.Cancelled => "Cancelled during pre-opening",
ProjectStatusType.WithdrawnDuringPreOpening => "Withdrawn in pre-opening",
ProjectStatusType.WithdrawnInPreOpening => "Withdrawn in pre-opening",
ProjectStatusType.Rejected => "Rejected at application stage",
ProjectStatusType.ApplicationCompetitionStage => "Application Competition stage",
ProjectStatusType.ApplicationStage => "Application stage",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private string BuildPaginationQuery()

if (ProjectStatusSearchTerm.Count > 0)
ProjectStatusSearchTerm.ForEach((m => query = query.Add("search-by-project-status", m)));

return query.ToString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var regionLabels = (from object region in regions select region.ToDescription()).ToList();

var projectStatuses = Enum.GetValues(typeof(ProjectStatus));
var projectStatusLabels = (from object status in projectStatuses select status.ToDescription()).ToList();
var projectStatusLabels = (from ProjectStatus status in projectStatuses select status.ToDescription()).ToList();
projectStatusLabels.Sort();

var projectManagerLabels = Model.ProjectManagers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
@if (@Model.Project.ProjectStatus.ProjectStatus is
ProjectStatus.Cancelled or
ProjectStatus.Closed or
ProjectStatus.WithdrawnDuringPreOpening or
ProjectStatus.WithdrawnInPreOpening or
ProjectStatus.WithdrawnDuringApplication)
{
<div class="govuk-summary-list__row">
@if (Model.Project.ProjectStatus.ProjectStatus == ProjectStatus.WithdrawnDuringPreOpening ||
@if (Model.Project.ProjectStatus.ProjectStatus == ProjectStatus.WithdrawnInPreOpening ||
Model.Project.ProjectStatus.ProjectStatus == ProjectStatus.WithdrawnDuringApplication)
{
<dt class="govuk-summary-list__key" id="overview-withdrawn-date">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

var isPresumptionProject = Model.Project.ProjectType.Contains("Presumption");

ProjectStatus[] presumptionStatuses = [ProjectStatus.Cancelled, ProjectStatus.Closed, ProjectStatus.Open, ProjectStatus.Preopening, ProjectStatus.WithdrawnDuringPreOpening];
ProjectStatus[] presumptionStatuses = [ProjectStatus.Cancelled, ProjectStatus.Closed, ProjectStatus.Open, ProjectStatus.Preopening, ProjectStatus.WithdrawnInPreOpening];

var projectStatusOptions = new List<ProjectStatusOption>
{
Expand Down Expand Up @@ -42,7 +42,7 @@
new("project-status-withdrawn-application", ProjectStatus.WithdrawnDuringApplication, ProjectStatus.WithdrawnDuringApplication.ToDescription(), "For example, the trust withdrew their application.", true,
"year-withdrawn-application", "year-withdrawn-application", "Date the project was withdrawn", "For example, 23 2 2021", Model.WithdrawnApplicationYear),

new("project-status-withdrawn", ProjectStatus.WithdrawnDuringPreOpening, ProjectStatus.WithdrawnDuringPreOpening.ToDescription(), "For example, the trust withdrew in the pre-opening stage.", true,
new("project-status-withdrawn", ProjectStatus.WithdrawnInPreOpening, ProjectStatus.WithdrawnInPreOpening.ToDescription(), "For example, the trust withdrew in the pre-opening stage.", true,
"year-withdrawn-preopening", "year-withdrawn-preopening", "Date the project was withdrawn", "For example, 23 2 2021", Model.WithdrawnYear)
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public async Task<IActionResult> OnGet()
if (Project.ProjectStatus.ProjectStatus == ProjectStatusType.Cancelled)
CancelledYear = Project.ProjectStatus.ProjectCancelledDate;

if(Project.ProjectStatus.ProjectStatus == ProjectStatusType.WithdrawnDuringPreOpening)
if(Project.ProjectStatus.ProjectStatus == ProjectStatusType.WithdrawnInPreOpening)
WithdrawnYear = Project.ProjectStatus.ProjectWithdrawnDate;

if (Project.ProjectStatus.ProjectStatus == ProjectStatusType.WithdrawnDuringApplication)
Expand All @@ -93,7 +93,7 @@ public async Task<IActionResult> OnPost()
{
CheckErrors(ClosedYearId, ProjectStatusType.Closed, ClosedYear);
CheckErrors(CancelledYearId, ProjectStatusType.Cancelled, CancelledYear);
CheckErrors(WithdrawnPreopeningYearId, ProjectStatusType.WithdrawnDuringPreOpening, WithdrawnYear);
CheckErrors(WithdrawnPreopeningYearId, ProjectStatusType.WithdrawnInPreOpening, WithdrawnYear);
CheckErrors(WithdrawnApplicationYearId, ProjectStatusType.WithdrawnDuringApplication, WithdrawnApplicationYear);

ClearNotApplicableValues();
Expand Down Expand Up @@ -139,7 +139,7 @@ private void ClearNotApplicableValues()
return;
}

if (ProjectStatus == ProjectStatusType.WithdrawnDuringPreOpening)
if (ProjectStatus == ProjectStatusType.WithdrawnInPreOpening)
{
ClosedYear = null;
CancelledYear = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
ProjectStatus.PreopeningNotIncludedInFigures => "yellow",
ProjectStatus.Rejected => "orange",
ProjectStatus.WithdrawnDuringApplication => "orange",
ProjectStatus.WithdrawnDuringPreOpening => "orange",
ProjectStatus.WithdrawnInPreOpening => "orange",
_ => "grey"
};

Expand Down

0 comments on commit 081dd94

Please sign in to comment.