Skip to content

Commit

Permalink
Merge pull request #1082 from DFE-Digital/feature/school-trust-sharep…
Browse files Browse the repository at this point in the history
…oint-files

Feature/school trust sharepoint files
  • Loading branch information
paullocknimble authored Jun 10, 2024
2 parents 52bcf80 + eb47705 commit 4871577
Show file tree
Hide file tree
Showing 12 changed files with 362 additions and 231 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class AcademyConversionProject
public int Id { get; set; }
public int? Urn { get; set; }
public int? FormAMatProjectId { get; set; }
public Guid? SchoolSharePointId { get; set; }
public Guid? ApplicationSharePointId { get; set; }
public bool? IsFormAMat { get; set; }
public DateTime CreatedOn { get; set; }
public string SchoolName { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Dfe.PrepareConversions.Configuration
{
public class SharePointOptions
{
public bool Enabled { get; set; }
public string Url { get; set; }
}
}
13 changes: 13 additions & 0 deletions Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using DocumentFormat.OpenXml.InkML;
using System;
using System.Collections.Generic;

Expand All @@ -9,6 +10,9 @@ public static class Links
private static string _transfersUrl;
public static string TransfersUrl => _transfersUrl;

private static bool _isApplicationDocumentsEnabled;
public static bool IsApplicationDocumentsEnabled => _isApplicationDocumentsEnabled;

private static LinkItem AddLinkItem(string page, string backText = "Back")
{
LinkItem item = new() { Page = page, BackText = backText };
Expand All @@ -19,6 +23,10 @@ public static void InitializeTransfersUrl(string transfersUrl)
{
_transfersUrl = transfersUrl;
}

public static void InializeProjectDocumentsEnabled(bool isApplicationDocumentsEnabled) {
_isApplicationDocumentsEnabled = isApplicationDocumentsEnabled;
}
public static LinkItem ByPage(string page)
{
return _links.Find(x => string.Equals(page, x.Page, StringComparison.InvariantCultureIgnoreCase));
Expand Down Expand Up @@ -64,6 +72,11 @@ public static class ProjectNotes
public static readonly LinkItem NewNote = AddLinkItem(page: "/ProjectNotes/NewNote");
}

public static class ApplicationDocuments
{
public static readonly LinkItem Index = AddLinkItem(page: "/ApplicationDocuments/Index");
}

public static class TaskList
{
public static readonly LinkItem Index = AddLinkItem(backText: "Back", page: "/TaskList/Index");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@page "/application-documents/{id:int}"
@using Dfe.PrepareConversions.Data.Models
@model Dfe.PrepareConversions.Pages.ApplicationDocuments.IndexModel
@{
ViewData["Title"] = "Application documents";
}

@section BeforeMain
{
<a asp-page="@Model.ReturnPage" asp-route-id="@Model.ReturnId" class="govuk-back-link">@Links.ProjectList.Index.BackText</a>
}

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

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<p class="govuk-body">
Application level documents folder <a href="@Model.ApplicationLevelDocumentsFolder" class="govuk-link" rel="noreferrer noopener" target="_blank">here</a>
</p><p class="govuk-body">
School level documents folder <a href="@Model.SchoolLevelDocumentsFolder" class="govuk-link" rel="noreferrer noopener" target="_blank">here</a>
</p>
</div>

</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using AngleSharp.Io.Dom;
using Dfe.PrepareConversions.Data.Services;
using Dfe.PrepareConversions.Models;
using Dfe.PrepareConversions.Services;
using Dfe.PrepareConversions.ViewModels;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;

namespace Dfe.PrepareConversions.Pages.ApplicationDocuments;

public class IndexModel : BaseAcademyConversionProjectPageModel
{
private readonly IConfiguration _configuration;

public string ReturnPage { get; set; }
public string ReturnId { get; set; }

public IndexModel(IAcademyConversionProjectRepository repository, IConfiguration configuration) : base(repository)
{
_configuration = configuration;
}

[BindProperty]
public string ApplicationLevelDocumentsFolder { get; set; }
[BindProperty]
public string SchoolLevelDocumentsFolder { get; private set; }

public override async Task<IActionResult> OnGetAsync(int id)
{
await base.OnGetAsync(id);
var rootSharePointFolder = _configuration["Sharepoint:Url"];

ApplicationLevelDocumentsFolder = $"{rootSharePointFolder}sip_application/{Project.ApplicationReferenceNumber}_{Project.ApplicationSharePointId.Value.ToString("N").ToUpper()}";
SchoolLevelDocumentsFolder = $"{rootSharePointFolder}sip_applyingschools/{Project.ApplicationReferenceNumber}_{Project.SchoolSharePointId.Value.ToString("N").ToUpper()}";

return Page();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Dfe.PrepareConversions.Data;

using Dfe.PrepareConversions.Data;
using Dfe.PrepareConversions.Data.Models;
using Dfe.PrepareConversions.Data.Services;
using Dfe.PrepareConversions.Models;
using Dfe.PrepareConversions.ViewModels;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Configuration;
using System.Security.Claims;
using System.Threading.Tasks;

Expand Down Expand Up @@ -46,6 +48,7 @@ protected async Task<IActionResult> SetProject(int id)
}

Project = new ProjectViewModel(project.Body);

return Page();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@
School application form
</sub-menu-link>
</li>

<li if="@Links.IsApplicationDocumentsEnabled && !Model.IsExternalSchoolApplication" class="moj-sub-navigation__item">
<sub-menu-link class="moj-sub-navigation__link"
asp-page="@Links.ApplicationDocuments.Index.Page"
asp-route-id="@id">
Application documents
</sub-menu-link>
</li>
<li if="@Model.IsSponsored" class="moj-sub-navigation__item">
<sub-menu-link class="moj-sub-navigation__link"
asp-page="@Links.AnnexB.Index.Page"
Expand All @@ -60,5 +66,6 @@
Project notes
</sub-menu-link>
</li>

</ul>
</nav>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Dfe.PrepareConversions.Services;
using Dfe.PrepareConversions.ViewModels;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Primitives;
using System.Linq;
using System.Net;
Expand All @@ -14,14 +15,16 @@ namespace Dfe.PrepareConversions.Pages.TaskList;
public class IndexModel : BaseAcademyConversionProjectPageModel
{
private readonly ErrorService _errorService;
private readonly IConfiguration _configuration;
private readonly KeyStagePerformanceService _keyStagePerformanceService;

public IndexModel(KeyStagePerformanceService keyStagePerformanceService,
IAcademyConversionProjectRepository repository,
ErrorService errorService) : base(repository)
ErrorService errorService, IConfiguration configuration) : base(repository)
{
_keyStagePerformanceService = keyStagePerformanceService;
_errorService = errorService;
_configuration = configuration;
}

public bool ShowGenerateHtbTemplateError { get; set; }
Expand Down
Loading

0 comments on commit 4871577

Please sign in to comment.