Skip to content

Commit c461f4b

Browse files
authored
Merge pull request #2667 from TechnologyEnhancedLearning/Develop/Fixes/TD-3885-CorrectingIssueRelatedToPromptFilterAndUATLiveFilter
TD 3885 correcting issue related to prompt filter and UAT live filter
2 parents cf967bb + df5d132 commit c461f4b

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/AllDelegatesControllerTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Microsoft.AspNetCore.Http;
1818
using NUnit.Framework;
1919
using Microsoft.Extensions.Configuration;
20+
using Microsoft.AspNetCore.Hosting;
2021

2122
public class AllDelegatesControllerTests
2223
{
@@ -32,6 +33,7 @@ public class AllDelegatesControllerTests
3233
private IUserDataService userDataService = null!;
3334
private IGroupsService groupsService = null!;
3435
private IConfiguration? configuration;
36+
private IWebHostEnvironment? env;
3537

3638
[SetUp]
3739
public void Setup()
@@ -46,6 +48,7 @@ public void Setup()
4648
configuration = A.Fake<IConfiguration>();
4749
httpRequest = A.Fake<HttpRequest>();
4850
httpResponse = A.Fake<HttpResponse>();
51+
env = A.Fake<IWebHostEnvironment>();
4952

5053
const string cookieValue = "ActiveStatus|Active|false";
5154

@@ -56,7 +59,8 @@ public void Setup()
5659
jobGroupsDataService,
5760
paginateService,
5861
groupsService,
59-
configuration
62+
configuration,
63+
env
6064
)
6165
.WithMockHttpContext(httpRequest, CookieName, cookieValue, httpResponse)
6266
.WithMockUser(true)

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/AllDelegatesController.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Microsoft.FeatureManagement.Mvc;
1919
using Microsoft.Extensions.Configuration;
2020
using DigitalLearningSolutions.Data.Extensions;
21+
using Microsoft.AspNetCore.Hosting;
2122

2223
[FeatureGate(FeatureFlags.RefactoredTrackingSystem)]
2324
[Authorize(Policy = CustomPolicies.UserCentreAdmin)]
@@ -26,14 +27,15 @@
2627
[Route("TrackingSystem/Delegates/All")]
2728
public class AllDelegatesController : Controller
2829
{
29-
private const string DelegateFilterCookieName = "DelegateFilter";
30+
private string DelegateFilterCookieName = "DelegateFilter";
3031
private readonly IDelegateDownloadFileService delegateDownloadFileService;
3132
private readonly IJobGroupsDataService jobGroupsDataService;
3233
private readonly PromptsService promptsService;
3334
private readonly IPaginateService paginateService;
3435
private readonly IUserDataService userDataService;
3536
private readonly IGroupsService groupsService;
3637
private readonly IConfiguration configuration;
38+
private readonly IWebHostEnvironment env;
3739

3840
public AllDelegatesController(
3941
IDelegateDownloadFileService delegateDownloadFileService,
@@ -42,7 +44,8 @@ public AllDelegatesController(
4244
IJobGroupsDataService jobGroupsDataService,
4345
IPaginateService paginateService,
4446
IGroupsService groupsService,
45-
IConfiguration configuration
47+
IConfiguration configuration,
48+
IWebHostEnvironment env
4649
)
4750
{
4851
this.delegateDownloadFileService = delegateDownloadFileService;
@@ -52,6 +55,7 @@ IConfiguration configuration
5255
this.paginateService = paginateService;
5356
this.groupsService = groupsService;
5457
this.configuration = configuration;
58+
this.env = env;
5559
}
5660

5761
[NoCaching]
@@ -76,6 +80,8 @@ public IActionResult Index(
7680

7781
sortBy ??= DefaultSortByOptions.Name.PropertyName;
7882
sortDirection ??= GenericSortingHelper.Ascending;
83+
84+
DelegateFilterCookieName += env.EnvironmentName;
7985
existingFilterString = FilteringHelper.GetFilterString(
8086
existingFilterString,
8187
newFilterToAdd,
@@ -95,10 +101,8 @@ public IActionResult Index(
95101
var promptsWithOptions = customPrompts.Where(customPrompt => customPrompt.Options.Count > 0);
96102
var availableFilters = AllDelegatesViewModelFilterOptions.GetAllDelegatesFilterViewModels(jobGroups, promptsWithOptions, groups);
97103

98-
var CurrentSiteBaseUrl = configuration.GetCurrentSystemBaseUrl();
99-
100-
if (((TempData["allDelegatesCentreId"] != null && TempData["allDelegatesCentreId"].ToString() != User.GetCentreId().ToString())
101-
|| (TempData["LastBaseUrl"] != null && (TempData["LastBaseUrl"].ToString() != CurrentSiteBaseUrl))) && existingFilterString != null)
104+
if (existingFilterString != null && TempData["allDelegatesCentreId"] != null &&
105+
TempData["allDelegatesCentreId"].ToString() != User.GetCentreId().ToString())
102106
{
103107
if (existingFilterString.Contains("Answer"))
104108
existingFilterString = FilterHelper.RemoveNonExistingPromptFilters(availableFilters, existingFilterString);
@@ -169,8 +173,8 @@ public IActionResult Index(
169173
{
170174
groupId = null;
171175
existingFilterString = FilterHelper.RemoveNonExistingFilterOptions(availableFilters, existingFilterString);
172-
}
173-
}
176+
}
177+
}
174178

175179
if (filter.Contains("Answer1"))
176180
answer1 = filterValue;
@@ -217,14 +221,13 @@ public IActionResult Index(
217221

218222
result.Page = page;
219223
TempData["Page"] = result.Page;
220-
TempData["LastBaseUrl"] = configuration.GetCurrentSystemBaseUrl();
221224

222225
var model = new AllDelegatesViewModel(
223226
result,
224227
customPrompts,
225228
availableFilters
226229
);
227-
230+
228231
model.TotalPages = (int)(resultCount / itemsPerPage) + ((resultCount % itemsPerPage) > 0 ? 1 : 0);
229232
model.MatchingSearchResults = resultCount;
230233

0 commit comments

Comments
 (0)