From 801aafacaee2e9e2400d5057a17304cfe4841510 Mon Sep 17 00:00:00 2001 From: plockwood Date: Fri, 24 May 2024 17:01:36 +0100 Subject: [PATCH 1/5] document changes --- .../Models/AcademyConversionProject.cs | 1 + .../Configuration/SharePointApiOptions.cs | 11 +++ .../Dfe.PrepareConversions/Models/Links.cs | 13 +++ .../BaseAcademyConversionProjectPageModel.cs | 5 +- .../Pages/ProjectDocuments/Index.cshtml | 39 ++++++++ .../Pages/ProjectDocuments/Index.cshtml.cs | 74 ++++++++++++++ .../Pages/Shared/_FilesPartial.cshtml | 24 +++++ .../Pages/Shared/_SubMenu.cshtml | 7 ++ .../Pages/TaskList/Index.cshtml.cs | 5 +- .../Services/FileService.cs | 99 +++++++++++++++++++ .../Helpers/AadAuthorisationHelper.cs | 32 ++++++ .../Services/Helpers/FileUploadConstants.cs | 18 ++++ .../Dfe.PrepareConversions/Startup.cs | 13 ++- .../ViewModels/FilesViewModel.cs | 16 +++ .../ViewModels/ProjectViewModel.cs | 2 + .../Dfe.PrepareConversions/appsettings.json | 9 +- 16 files changed, 364 insertions(+), 4 deletions(-) create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointApiOptions.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FilesPartial.cshtml create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Services/FileService.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/AadAuthorisationHelper.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/FileUploadConstants.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/FilesViewModel.cs diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs index dbea87fc3..80005be2d 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs @@ -8,6 +8,7 @@ public class AcademyConversionProject public int Id { get; set; } public int? Urn { get; set; } public int? FormAMatProjectId { get; set; } + public Guid? SharePointId { get; set; } public bool? IsFormAMat { get; set; } public DateTime CreatedOn { get; set; } public string SchoolName { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointApiOptions.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointApiOptions.cs new file mode 100644 index 000000000..42db3465b --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointApiOptions.cs @@ -0,0 +1,11 @@ +namespace Dfe.PrepareConversions.Configuration +{ + public class SharePointApiOptions + { + public bool Enabled { get; set; } + public string ApiUrl { get; set; } + public string ClientId { get; set; } + public string Secret { get; set; } + public string Authority { get; set; } + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs index 4df359b2f..d66b7f2b8 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs @@ -1,3 +1,4 @@ +using DocumentFormat.OpenXml.InkML; using System; using System.Collections.Generic; @@ -9,6 +10,9 @@ public static class Links private static string _transfersUrl; public static string TransfersUrl => _transfersUrl; + private static bool _isProjectDocumentsEnabled; + public static bool IsProjectDocumentsEnabled => _isProjectDocumentsEnabled; + private static LinkItem AddLinkItem(string page, string backText = "Back") { LinkItem item = new() { Page = page, BackText = backText }; @@ -19,6 +23,10 @@ public static void InitializeTransfersUrl(string transfersUrl) { _transfersUrl = transfersUrl; } + + public static void InializeProjectDocumentsEnabled(bool isProjectDocumentsEnabled) { + _isProjectDocumentsEnabled = isProjectDocumentsEnabled; + } public static LinkItem ByPage(string page) { return _links.Find(x => string.Equals(page, x.Page, StringComparison.InvariantCultureIgnoreCase)); @@ -64,6 +72,11 @@ public static class ProjectNotes public static readonly LinkItem NewNote = AddLinkItem(page: "/ProjectNotes/NewNote"); } + public static class ProjectDocuments + { + public static readonly LinkItem Index = AddLinkItem(page: "/ProjectDocuments/Index"); + } + public static class TaskList { public static readonly LinkItem Index = AddLinkItem(backText: "Back", page: "/TaskList/Index"); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/BaseAcademyConversionProjectPageModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/BaseAcademyConversionProjectPageModel.cs index 78228c386..cc8b31d09 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/BaseAcademyConversionProjectPageModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/BaseAcademyConversionProjectPageModel.cs @@ -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; @@ -46,6 +48,7 @@ protected async Task SetProject(int id) } Project = new ProjectViewModel(project.Body); + return Page(); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml new file mode 100644 index 000000000..d9dfa2b70 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml @@ -0,0 +1,39 @@ +@page "/project-documents/{id:int}" +@using Dfe.PrepareConversions.Data.Models +@using Dfe.PrepareConversions.Services.Helpers +@model Dfe.PrepareConversions.Pages.ProjectDocuments.IndexModel +@{ + ViewData["Title"] = "Project documents"; +} + +@section BeforeMain +{ + @Links.ProjectList.Index.BackText +} + + + +
+
+
+ + + + + +
+
\ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs new file mode 100644 index 000000000..112eceed8 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs @@ -0,0 +1,74 @@ +using AngleSharp.Io.Dom; +using Dfe.PrepareConversions.Data.Services; +using Dfe.PrepareConversions.Models; +using Dfe.PrepareConversions.Services; +using Dfe.PrepareConversions.Services.Helpers; +using Dfe.PrepareConversions.ViewModels; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Net; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Pages.ProjectDocuments; + +public class IndexModel : BaseAcademyConversionProjectPageModel +{ + private readonly IFileService _fileService; + + public string ReturnPage { get; set; } + public string ReturnId { get; set; } + + public IndexModel(IAcademyConversionProjectRepository repository, IFileService fileService) : base(repository) + { + _fileService = fileService; + } + + [BindProperty] + public List DioceseFileNames { get; set; } + [BindProperty] + public List ResolutionConsentFileNames { get; private set; } + + public override async Task OnGetAsync(int id) + { + await base.OnGetAsync(id); + + DioceseFileNames = await _fileService.GetFiles(FileUploadConstants.TopLevelSchoolFolderName, Project.SharePointId.ToString(), Project.ApplicationReferenceNumber, FileUploadConstants.DioceseFilePrefixFieldName); + //TempDataHelper.StoreSerialisedValue($"{EntityId}-dioceseFiles", TempData, DioceseFileNames); + //FoundationConsentFileNames = await _fileUploadService.GetFiles(FileUploadConstants.TopLevelSchoolFolderName, EntityId.ToString(), ApplicationReference, FileUploadConstants.FoundationConsentFilePrefixFieldName); + + ResolutionConsentFileNames = await _fileService.GetFiles(FileUploadConstants.TopLevelSchoolFolderName, Project.SharePointId.ToString(), Project.ApplicationReferenceNumber, FileUploadConstants.ResolutionConsentfilePrefixFieldName); + + return Page(); + } + + public async Task GetFile(string entityName, string recordId, string recordName, string fieldName, string fileName) + { + //if (String.IsNullOrEmpty(id)) + // return Request.CreateResponse(HttpStatusCode.BadRequest); + + var file = await _fileService.DownloadFile(entityName, recordId, recordName, fieldName, fileName); + + HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); + + response.Content = new StreamContent(GenerateStreamFromString(file)); + response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); + response.Content.Headers.ContentDisposition.FileName = fileName; + //response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf"); + + return response; + } + + public static Stream GenerateStreamFromString(string s) + { + var stream = new MemoryStream(); + var writer = new StreamWriter(stream); + writer.Write(s); + writer.Flush(); + stream.Position = 0; + return stream; + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FilesPartial.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FilesPartial.cshtml new file mode 100644 index 000000000..689cf49d9 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FilesPartial.cshtml @@ -0,0 +1,24 @@ +@model Dfe.PrepareConversions.ViewModels.FilesViewModel + + + @Model.SectionName files + +
+ + +@foreach (var fileName in Model.FileNames) +{ + + + + + + + + + + +
+

@fileName

+
+} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml index d75b360d0..d4b593b3e 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml @@ -60,5 +60,12 @@ Project notes +
  • + + Project documents + +
  • \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml.cs index 985b10133..b73464602 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/TaskList/Index.cshtml.cs @@ -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; @@ -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; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/FileService.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/FileService.cs new file mode 100644 index 000000000..b747b5310 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/FileService.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Dfe.PrepareConversions.Services.Helpers; +using Microsoft.VisualBasic; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Dfe.PrepareConversions.Services; + +public interface IFileService +{ + Task> GetFiles(string entityName, string recordId, string recordName, string fieldName); + Task DownloadFile(string entityName, string recordId, string recordName, string fieldName, string fileName); +} + +public class FileService : IFileService +{ + private readonly HttpClient _httpClient; + private readonly IAadAuthorisationHelper _aadAuthorisationHelper; + + public FileService() { } + + public FileService(HttpClient httpClient, IAadAuthorisationHelper aadAuthorisationHelper) + { + _httpClient = httpClient; + _aadAuthorisationHelper = aadAuthorisationHelper; + } + + public async Task> GetFiles(string entityName, string recordId, string recordName, string fieldName) + { + var url = $"?entityName={entityName}&recordName={recordName}&recordId={recordId}&fieldName={fieldName}"; + + using var request = new HttpRequestMessage(HttpMethod.Get, url); + + var content = await DoHttpRequest(request); + + return ParseJResponse(content); + } + + public async Task DownloadFile(string entityName, string recordId, string recordName, string fieldName, string fileName) + { + var url = $@"download?entityName={entityName}&recordName={recordName}&recordId={recordId}&fieldName={fieldName}&fileName={fileName}"; + + using var request = new HttpRequestMessage(HttpMethod.Get, url); + var content = await DoHttpRequest(request); + + return content; + + } + + private async Task DoHttpRequest(HttpRequestMessage request) + { + var accessToken = await _aadAuthorisationHelper.GetAccessToken(); + _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + + var response = await _httpClient.SendAsync(request); + var content = await response.Content.ReadAsStringAsync(); + + if (!response.IsSuccessStatusCode) + throw new Exception($"The file service failed with a status of {response.ReasonPhrase} {content}"); + + var receiveStream = await response.Content.ReadAsStreamAsync(); + using var readStream = new StreamReader(receiveStream, Encoding.UTF8); + return await readStream.ReadToEndAsync(); + } + + private List ParseJResponse(string content) + { + var jobject = JObject.Parse(content); + var jfiles = (JArray)jobject?.GetValue("Files", StringComparison.OrdinalIgnoreCase)!; + return jfiles.Select(x => (string)x).ToList(); + } + + internal static string GetJsonAsString(JObject jObject) + { + var sb = new StringBuilder(); + sb.Append("\""); + using (var sw = new StringWriter(sb)) + using (var writer = new JsonTextWriter(sw)) + { + writer.QuoteChar = '\''; + + var ser = new JsonSerializer(); + ser.Serialize(writer, jObject); + } + + sb.Append("\""); + + return sb.ToString(); + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/AadAuthorisationHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/AadAuthorisationHelper.cs new file mode 100644 index 000000000..2af505717 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/AadAuthorisationHelper.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Identity.Client; +using System.Threading.Tasks; + +namespace Dfe.PrepareConversions.Services.Helpers; + +public interface IAadAuthorisationHelper +{ + Task GetAccessToken(); +} + +public class AadAuthorisationHelper : IAadAuthorisationHelper +{ + private readonly IConfiguration _configuration; + + public AadAuthorisationHelper(IConfiguration configuration) + { + _configuration = configuration; + } + public async Task GetAccessToken() + { + var app = ConfidentialClientApplicationBuilder + .Create(_configuration["Sharepoint:ClientId"]) + .WithClientSecret(_configuration["Sharepoint:Secret"]) + .WithAuthority(AzureCloudInstance.AzurePublic, _configuration["Sharepoint:TenantId"]) + .Build(); + + var result = app.AcquireTokenForClient(new string[] { $"{_configuration["Sharepoint:Authority"]}/.default" }); + + return (await result.ExecuteAsync()).AccessToken; + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/FileUploadConstants.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/FileUploadConstants.cs new file mode 100644 index 000000000..95973733b --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/FileUploadConstants.cs @@ -0,0 +1,18 @@ +namespace Dfe.PrepareConversions.Services.Helpers; + +public static class FileUploadConstants +{ + public const string TopLevelApplicationFolderName = "sip_application"; + public const string TopLevelSchoolFolderName = "sip_applyingschools"; + public const string DioceseFilePrefixFieldName = "sip_adschoolfaithschoolfile"; + public const string FoundationConsentFilePrefixFieldName = "sip_adschoolsupportedfoundationfile"; + public const string ResolutionConsentfilePrefixFieldName = "sip_adschoolgoverningbodyconsent"; + public const string SchoolPFYRevenueStatusFile = "sip_pfyrevenuepreviousfinancialstatusfile"; + public const string SchoolPFYCapitalForwardStatusFile = "sip_pfyrevenuecapitalcarriedforwardfile"; + public const string SchoolCFYRevenueStatusFile = "sip_cfyrevenuecurrentfinancialstatusfile"; + public const string SchoolCFYCapitalForwardFile = "sip_cfyforecastcapitalcarriedforwardfile"; + public const string NFYForecastedRevenueFilePrefixFieldName = "sip_nfynextcurrentfinancialfile"; + public const string NFYForecastedCapitalFilePrefixFieldName = "sip_nfyforecastcapitalcarriedforwardfile"; + public const string JoinAMatTrustConsentFilePrefixFieldName = "sip_changestotrustconsent"; + public const string JoinAMatTrustGovernanceFilePrefixFieldName = "sip_formtrustgovernancefile"; +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs index faf5b32cd..c663b320b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs @@ -10,6 +10,7 @@ using Dfe.PrepareConversions.Routing; using Dfe.PrepareConversions.Security; using Dfe.PrepareConversions.Services; +using Dfe.PrepareConversions.Services.Helpers; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; @@ -21,6 +22,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Microsoft.FeatureManagement; using Microsoft.Identity.Web; using Microsoft.Identity.Web.UI; @@ -148,11 +150,20 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddSingleton(); + + services.Configure(Configuration.GetSection("Sharepoint")); + var sharepointOptions = Configuration.GetSection("Sharepoint").Get(); + services.AddHttpClient(client => + { + client.BaseAddress = new Uri(sharepointOptions.ApiUrl); + }); + Links.InializeProjectDocumentsEnabled(sharepointOptions.Enabled); // Initialize the TransfersUrl var serviceLinkOptions = Configuration.GetSection("ServiceLink").Get(); Links.InitializeTransfersUrl(serviceLinkOptions.TransfersUrl); - + } public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger logger) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/FilesViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/FilesViewModel.cs new file mode 100644 index 000000000..6877a43c8 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/FilesViewModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +namespace Dfe.PrepareConversions.ViewModels; + +public class FilesViewModel +{ + + public List FileNames { get; set; } + public string FilePrefixSection { get; set; } + public string SectionName { get; set; } + public string Urn { get; set; } + public string DownloadUrl { get; set; } + public Guid EntityId { get; set; } + public string ApplicationReference { get; set; } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs index 6a14b791a..842d459dd 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs @@ -12,6 +12,7 @@ public ProjectViewModel(AcademyConversionProject project) { Id = project.Id.ToString(); FormAMatProjectId = project.FormAMatProjectId; + SharePointId = project.SharePointId; IsFormAMat = project.IsFormAMat.HasValue && project.IsFormAMat.Value; ProjectStatus = ProjectListHelper.MapProjectStatus(project.ProjectStatus).Value; ProjectStatusColour = ProjectListHelper.MapProjectStatus(project.ProjectStatus).Colour; @@ -130,6 +131,7 @@ public ProjectViewModel(AcademyConversionProject project) public string Id { get; } public int? FormAMatProjectId { get; } + public Guid? SharePointId { get; } public string ProjectStatus { get; } public string ProjectStatusColour { get; } public string ApplicationReferenceNumber { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json b/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json index 075fa92a1..b68883d12 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json @@ -48,5 +48,12 @@ "UseAcademisationApplication": true, "ShowDirectedAcademyOrders": true }, - "MaintenanceMode": false + "MaintenanceMode": false, + "Sharepoint": { + "Enabled": false, + "ApiUrl": "", + "ClientId": "", + "Secret": "", + "Authority": "" + } } From 1bdfbbb3371e48f78563f37e23c491b685a776a4 Mon Sep 17 00:00:00 2001 From: plockwood Date: Fri, 7 Jun 2024 17:46:17 +0100 Subject: [PATCH 2/5] School/application folder changes --- .../Models/AcademyConversionProject.cs | 3 +- .../Configuration/SharePointApiOptions.cs | 11 --- .../Configuration/SharePointOptions.cs | 8 ++ .../Pages/ProjectDocuments/Index.cshtml | 25 +---- .../Pages/ProjectDocuments/Index.cshtml.cs | 48 +++------ .../Pages/Shared/_FilesPartial.cshtml | 24 ----- .../Services/FileService.cs | 99 ------------------- .../Helpers/AadAuthorisationHelper.cs | 32 ------ .../Services/Helpers/FileUploadConstants.cs | 18 ---- .../Dfe.PrepareConversions/Startup.cs | 11 +-- .../ViewModels/ProjectViewModel.cs | 6 +- .../Dfe.PrepareConversions/appsettings.json | 5 +- 12 files changed, 33 insertions(+), 257 deletions(-) delete mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointApiOptions.cs create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointOptions.cs delete mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FilesPartial.cshtml delete mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Services/FileService.cs delete mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/AadAuthorisationHelper.cs delete mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/FileUploadConstants.cs diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs index 80005be2d..f485207fb 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademyConversionProject.cs @@ -8,7 +8,8 @@ public class AcademyConversionProject public int Id { get; set; } public int? Urn { get; set; } public int? FormAMatProjectId { get; set; } - public Guid? SharePointId { 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; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointApiOptions.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointApiOptions.cs deleted file mode 100644 index 42db3465b..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointApiOptions.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Dfe.PrepareConversions.Configuration -{ - public class SharePointApiOptions - { - public bool Enabled { get; set; } - public string ApiUrl { get; set; } - public string ClientId { get; set; } - public string Secret { get; set; } - public string Authority { get; set; } - } -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointOptions.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointOptions.cs new file mode 100644 index 000000000..07641d3bd --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Configuration/SharePointOptions.cs @@ -0,0 +1,8 @@ +namespace Dfe.PrepareConversions.Configuration +{ + public class SharePointOptions + { + public bool Enabled { get; set; } + public string Url { get; set; } + } +} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml index d9dfa2b70..c1fdf5b4c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml @@ -1,6 +1,5 @@ @page "/project-documents/{id:int}" @using Dfe.PrepareConversions.Data.Models -@using Dfe.PrepareConversions.Services.Helpers @model Dfe.PrepareConversions.Pages.ProjectDocuments.IndexModel @{ ViewData["Title"] = "Project documents"; @@ -15,25 +14,9 @@
    -
    - - - - - + + Application level documents folder here
    + School level documents folder here
    +
    \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs index 112eceed8..efeefe54e 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs @@ -2,7 +2,6 @@ using Dfe.PrepareConversions.Data.Services; using Dfe.PrepareConversions.Models; using Dfe.PrepareConversions.Services; -using Dfe.PrepareConversions.Services.Helpers; using Dfe.PrepareConversions.ViewModels; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Primitives; @@ -12,63 +11,38 @@ using System.Net.Http; using System.Net; using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using static System.Net.WebRequestMethods; namespace Dfe.PrepareConversions.Pages.ProjectDocuments; public class IndexModel : BaseAcademyConversionProjectPageModel { - private readonly IFileService _fileService; + private readonly IConfiguration _configuration; public string ReturnPage { get; set; } public string ReturnId { get; set; } - public IndexModel(IAcademyConversionProjectRepository repository, IFileService fileService) : base(repository) + public IndexModel(IAcademyConversionProjectRepository repository, IConfiguration configuration) : base(repository) { - _fileService = fileService; + _configuration = configuration; } [BindProperty] - public List DioceseFileNames { get; set; } + public string ApplicationLevelDocumentsFolder { get; set; } [BindProperty] - public List ResolutionConsentFileNames { get; private set; } + public string SchoolLevelDocumentsFolder { get; private set; } public override async Task OnGetAsync(int id) { await base.OnGetAsync(id); + var rootSharePointFolder = _configuration["Sharepoint:Url"]; - DioceseFileNames = await _fileService.GetFiles(FileUploadConstants.TopLevelSchoolFolderName, Project.SharePointId.ToString(), Project.ApplicationReferenceNumber, FileUploadConstants.DioceseFilePrefixFieldName); - //TempDataHelper.StoreSerialisedValue($"{EntityId}-dioceseFiles", TempData, DioceseFileNames); - //FoundationConsentFileNames = await _fileUploadService.GetFiles(FileUploadConstants.TopLevelSchoolFolderName, EntityId.ToString(), ApplicationReference, FileUploadConstants.FoundationConsentFilePrefixFieldName); + //https://educationgovuk.sharepoint.com/sites/sip-dev/sip_application/Forms/AllItems.aspx?id=%2Fsites%2Fsip%2Ddev%2Fsip%5Fapplication%2FA2B%5F0027%5F63B137B6D21DEB11A813000D3A38AA47 - ResolutionConsentFileNames = await _fileService.GetFiles(FileUploadConstants.TopLevelSchoolFolderName, Project.SharePointId.ToString(), Project.ApplicationReferenceNumber, FileUploadConstants.ResolutionConsentfilePrefixFieldName); + 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(); } - - public async Task GetFile(string entityName, string recordId, string recordName, string fieldName, string fileName) - { - //if (String.IsNullOrEmpty(id)) - // return Request.CreateResponse(HttpStatusCode.BadRequest); - - var file = await _fileService.DownloadFile(entityName, recordId, recordName, fieldName, fileName); - - HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); - - response.Content = new StreamContent(GenerateStreamFromString(file)); - response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); - response.Content.Headers.ContentDisposition.FileName = fileName; - //response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf"); - - return response; - } - - public static Stream GenerateStreamFromString(string s) - { - var stream = new MemoryStream(); - var writer = new StreamWriter(stream); - writer.Write(s); - writer.Flush(); - stream.Position = 0; - return stream; - } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FilesPartial.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FilesPartial.cshtml deleted file mode 100644 index 689cf49d9..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_FilesPartial.cshtml +++ /dev/null @@ -1,24 +0,0 @@ -@model Dfe.PrepareConversions.ViewModels.FilesViewModel - - - @Model.SectionName files - -
    - - -@foreach (var fileName in Model.FileNames) -{ - - - - - - - - - - -
    -

    @fileName

    -
    -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/FileService.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/FileService.cs deleted file mode 100644 index b747b5310..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/FileService.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Dfe.PrepareConversions.Services.Helpers; -using Microsoft.VisualBasic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Dfe.PrepareConversions.Services; - -public interface IFileService -{ - Task> GetFiles(string entityName, string recordId, string recordName, string fieldName); - Task DownloadFile(string entityName, string recordId, string recordName, string fieldName, string fileName); -} - -public class FileService : IFileService -{ - private readonly HttpClient _httpClient; - private readonly IAadAuthorisationHelper _aadAuthorisationHelper; - - public FileService() { } - - public FileService(HttpClient httpClient, IAadAuthorisationHelper aadAuthorisationHelper) - { - _httpClient = httpClient; - _aadAuthorisationHelper = aadAuthorisationHelper; - } - - public async Task> GetFiles(string entityName, string recordId, string recordName, string fieldName) - { - var url = $"?entityName={entityName}&recordName={recordName}&recordId={recordId}&fieldName={fieldName}"; - - using var request = new HttpRequestMessage(HttpMethod.Get, url); - - var content = await DoHttpRequest(request); - - return ParseJResponse(content); - } - - public async Task DownloadFile(string entityName, string recordId, string recordName, string fieldName, string fileName) - { - var url = $@"download?entityName={entityName}&recordName={recordName}&recordId={recordId}&fieldName={fieldName}&fileName={fileName}"; - - using var request = new HttpRequestMessage(HttpMethod.Get, url); - var content = await DoHttpRequest(request); - - return content; - - } - - private async Task DoHttpRequest(HttpRequestMessage request) - { - var accessToken = await _aadAuthorisationHelper.GetAccessToken(); - _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); - - var response = await _httpClient.SendAsync(request); - var content = await response.Content.ReadAsStringAsync(); - - if (!response.IsSuccessStatusCode) - throw new Exception($"The file service failed with a status of {response.ReasonPhrase} {content}"); - - var receiveStream = await response.Content.ReadAsStreamAsync(); - using var readStream = new StreamReader(receiveStream, Encoding.UTF8); - return await readStream.ReadToEndAsync(); - } - - private List ParseJResponse(string content) - { - var jobject = JObject.Parse(content); - var jfiles = (JArray)jobject?.GetValue("Files", StringComparison.OrdinalIgnoreCase)!; - return jfiles.Select(x => (string)x).ToList(); - } - - internal static string GetJsonAsString(JObject jObject) - { - var sb = new StringBuilder(); - sb.Append("\""); - using (var sw = new StringWriter(sb)) - using (var writer = new JsonTextWriter(sw)) - { - writer.QuoteChar = '\''; - - var ser = new JsonSerializer(); - ser.Serialize(writer, jObject); - } - - sb.Append("\""); - - return sb.ToString(); - } -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/AadAuthorisationHelper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/AadAuthorisationHelper.cs deleted file mode 100644 index 2af505717..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/AadAuthorisationHelper.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Identity.Client; -using System.Threading.Tasks; - -namespace Dfe.PrepareConversions.Services.Helpers; - -public interface IAadAuthorisationHelper -{ - Task GetAccessToken(); -} - -public class AadAuthorisationHelper : IAadAuthorisationHelper -{ - private readonly IConfiguration _configuration; - - public AadAuthorisationHelper(IConfiguration configuration) - { - _configuration = configuration; - } - public async Task GetAccessToken() - { - var app = ConfidentialClientApplicationBuilder - .Create(_configuration["Sharepoint:ClientId"]) - .WithClientSecret(_configuration["Sharepoint:Secret"]) - .WithAuthority(AzureCloudInstance.AzurePublic, _configuration["Sharepoint:TenantId"]) - .Build(); - - var result = app.AcquireTokenForClient(new string[] { $"{_configuration["Sharepoint:Authority"]}/.default" }); - - return (await result.ExecuteAsync()).AccessToken; - } -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/FileUploadConstants.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/FileUploadConstants.cs deleted file mode 100644 index 95973733b..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/Helpers/FileUploadConstants.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Dfe.PrepareConversions.Services.Helpers; - -public static class FileUploadConstants -{ - public const string TopLevelApplicationFolderName = "sip_application"; - public const string TopLevelSchoolFolderName = "sip_applyingschools"; - public const string DioceseFilePrefixFieldName = "sip_adschoolfaithschoolfile"; - public const string FoundationConsentFilePrefixFieldName = "sip_adschoolsupportedfoundationfile"; - public const string ResolutionConsentfilePrefixFieldName = "sip_adschoolgoverningbodyconsent"; - public const string SchoolPFYRevenueStatusFile = "sip_pfyrevenuepreviousfinancialstatusfile"; - public const string SchoolPFYCapitalForwardStatusFile = "sip_pfyrevenuecapitalcarriedforwardfile"; - public const string SchoolCFYRevenueStatusFile = "sip_cfyrevenuecurrentfinancialstatusfile"; - public const string SchoolCFYCapitalForwardFile = "sip_cfyforecastcapitalcarriedforwardfile"; - public const string NFYForecastedRevenueFilePrefixFieldName = "sip_nfynextcurrentfinancialfile"; - public const string NFYForecastedCapitalFilePrefixFieldName = "sip_nfyforecastcapitalcarriedforwardfile"; - public const string JoinAMatTrustConsentFilePrefixFieldName = "sip_changestotrustconsent"; - public const string JoinAMatTrustGovernanceFilePrefixFieldName = "sip_formtrustgovernancefile"; -} diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs index c663b320b..92ca63991 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Startup.cs @@ -10,7 +10,6 @@ using Dfe.PrepareConversions.Routing; using Dfe.PrepareConversions.Security; using Dfe.PrepareConversions.Services; -using Dfe.PrepareConversions.Services.Helpers; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; @@ -150,14 +149,10 @@ public void ConfigureServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddSingleton(); - services.Configure(Configuration.GetSection("Sharepoint")); - var sharepointOptions = Configuration.GetSection("Sharepoint").Get(); - services.AddHttpClient(client => - { - client.BaseAddress = new Uri(sharepointOptions.ApiUrl); - }); + services.Configure(Configuration.GetSection("Sharepoint")); + var sharepointOptions = Configuration.GetSection("Sharepoint").Get(); + Links.InializeProjectDocumentsEnabled(sharepointOptions.Enabled); // Initialize the TransfersUrl diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs index 842d459dd..e585ac59b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewModels/ProjectViewModel.cs @@ -12,7 +12,8 @@ public ProjectViewModel(AcademyConversionProject project) { Id = project.Id.ToString(); FormAMatProjectId = project.FormAMatProjectId; - SharePointId = project.SharePointId; + ApplicationSharePointId = project.ApplicationSharePointId; + SchoolSharePointId = project.SchoolSharePointId; IsFormAMat = project.IsFormAMat.HasValue && project.IsFormAMat.Value; ProjectStatus = ProjectListHelper.MapProjectStatus(project.ProjectStatus).Value; ProjectStatusColour = ProjectListHelper.MapProjectStatus(project.ProjectStatus).Colour; @@ -131,7 +132,8 @@ public ProjectViewModel(AcademyConversionProject project) public string Id { get; } public int? FormAMatProjectId { get; } - public Guid? SharePointId { get; } + public Guid? SchoolSharePointId { get; } + public Guid? ApplicationSharePointId { get; } public string ProjectStatus { get; } public string ProjectStatusColour { get; } public string ApplicationReferenceNumber { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json b/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json index b68883d12..719d7122d 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json @@ -51,9 +51,6 @@ "MaintenanceMode": false, "Sharepoint": { "Enabled": false, - "ApiUrl": "", - "ClientId": "", - "Secret": "", - "Authority": "" + "Url": "" } } From a41511905b0cdd5ebba21c757197704e5a0deef4 Mon Sep 17 00:00:00 2001 From: plockwood Date: Mon, 10 Jun 2024 12:54:10 +0100 Subject: [PATCH 3/5] Application form documents tab and links --- .../Dfe.PrepareConversions/Models/Links.cs | 12 +++++----- .../Pages/ApplicationDocuments/Index.cshtml | 24 +++++++++++++++++++ .../Index.cshtml.cs | 9 +------ .../Pages/ProjectDocuments/Index.cshtml | 22 ----------------- .../Pages/Shared/_SubMenu.cshtml | 16 ++++++------- 5 files changed, 39 insertions(+), 44 deletions(-) create mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml rename Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/{ProjectDocuments => ApplicationDocuments}/Index.cshtml.cs (79%) delete mode 100644 Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs index d66b7f2b8..9d0a826bb 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Models/Links.cs @@ -10,8 +10,8 @@ public static class Links private static string _transfersUrl; public static string TransfersUrl => _transfersUrl; - private static bool _isProjectDocumentsEnabled; - public static bool IsProjectDocumentsEnabled => _isProjectDocumentsEnabled; + private static bool _isApplicationDocumentsEnabled; + public static bool IsApplicationDocumentsEnabled => _isApplicationDocumentsEnabled; private static LinkItem AddLinkItem(string page, string backText = "Back") { @@ -24,8 +24,8 @@ public static void InitializeTransfersUrl(string transfersUrl) _transfersUrl = transfersUrl; } - public static void InializeProjectDocumentsEnabled(bool isProjectDocumentsEnabled) { - _isProjectDocumentsEnabled = isProjectDocumentsEnabled; + public static void InializeProjectDocumentsEnabled(bool isApplicationDocumentsEnabled) { + _isApplicationDocumentsEnabled = isApplicationDocumentsEnabled; } public static LinkItem ByPage(string page) { @@ -72,9 +72,9 @@ public static class ProjectNotes public static readonly LinkItem NewNote = AddLinkItem(page: "/ProjectNotes/NewNote"); } - public static class ProjectDocuments + public static class ApplicationDocuments { - public static readonly LinkItem Index = AddLinkItem(page: "/ProjectDocuments/Index"); + public static readonly LinkItem Index = AddLinkItem(page: "/ApplicationDocuments/Index"); } public static class TaskList diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml new file mode 100644 index 000000000..bd93de677 --- /dev/null +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml @@ -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 +{ + @Links.ProjectList.Index.BackText +} + + + +
    +
    +

    + Application level documents folder here +

    + School level documents folder here +

    +
    + +
    \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml.cs similarity index 79% rename from Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs rename to Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml.cs index efeefe54e..d8d87d477 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ApplicationDocuments/Index.cshtml.cs @@ -6,15 +6,10 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Primitives; using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Net; using System.Threading.Tasks; using Microsoft.Extensions.Configuration; -using static System.Net.WebRequestMethods; -namespace Dfe.PrepareConversions.Pages.ProjectDocuments; +namespace Dfe.PrepareConversions.Pages.ApplicationDocuments; public class IndexModel : BaseAcademyConversionProjectPageModel { @@ -38,8 +33,6 @@ public override async Task OnGetAsync(int id) await base.OnGetAsync(id); var rootSharePointFolder = _configuration["Sharepoint:Url"]; - //https://educationgovuk.sharepoint.com/sites/sip-dev/sip_application/Forms/AllItems.aspx?id=%2Fsites%2Fsip%2Ddev%2Fsip%5Fapplication%2FA2B%5F0027%5F63B137B6D21DEB11A813000D3A38AA47 - ApplicationLevelDocumentsFolder = $"{rootSharePointFolder}sip_application/{Project.ApplicationReferenceNumber}_{Project.ApplicationSharePointId.Value.ToString("N").ToUpper()}"; SchoolLevelDocumentsFolder = $"{rootSharePointFolder}sip_applyingschools/{Project.ApplicationReferenceNumber}_{Project.SchoolSharePointId.Value.ToString("N").ToUpper()}"; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml deleted file mode 100644 index c1fdf5b4c..000000000 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/ProjectDocuments/Index.cshtml +++ /dev/null @@ -1,22 +0,0 @@ -@page "/project-documents/{id:int}" -@using Dfe.PrepareConversions.Data.Models -@model Dfe.PrepareConversions.Pages.ProjectDocuments.IndexModel -@{ - ViewData["Title"] = "Project documents"; -} - -@section BeforeMain -{ - @Links.ProjectList.Index.BackText -} - - - -
    -
    - - Application level documents folder here
    - School level documents folder here -
    - -
    \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml index d4b593b3e..d79369750 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/Shared/_SubMenu.cshtml @@ -36,7 +36,13 @@ School application form - +
  • + + Application documents + +
  • -
  • - - Project documents - -
  • + \ No newline at end of file From 3b0a427d197951e26607c6af2d1435ba3197518f Mon Sep 17 00:00:00 2001 From: plockwood Date: Mon, 10 Jun 2024 12:59:39 +0100 Subject: [PATCH 4/5] appsettings fix --- Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json b/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json index 1ebaa7d6a..06c67f4bf 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/appsettings.json @@ -49,7 +49,6 @@ "ShowDirectedAcademyOrders": true }, "notificationBannerMessage": "", - "MaintenanceMode": false "MaintenanceMode": false, "Sharepoint": { "Enabled": false, From eb47705607ba78f50f54ee48d432e08bc825609d Mon Sep 17 00:00:00 2001 From: plockwood Date: Mon, 10 Jun 2024 15:36:41 +0100 Subject: [PATCH 5/5] test fix --- .../Pages/TaskList/IndexIntegrationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/IndexIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/IndexIntegrationTests.cs index a36f2d1f2..4f71ca202 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/IndexIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/IndexIntegrationTests.cs @@ -27,7 +27,7 @@ public async Task Should_redirect_to_record_decision() { await OpenAndConfirmPathAsync($"/task-list/{_project.Id}/record-a-decision"); - await NavigateAsync("Record a decision", 1); + await NavigateAsync("Record a decision", 0); Document.Url.Should().Contain($"/task-list/{_project.Id}/decision/record-decision"); }