Skip to content

Commit

Permalink
Merge branch 'CON-1432-Employers-&-Providers-Collaborate-Feature' int…
Browse files Browse the repository at this point in the history
…o CON-3535-Provider-can-clone-vacancies-in-'Pending-employer-review'-status
  • Loading branch information
cofaulco committed Jun 2, 2021
2 parents cfd6afe + 332cbd0 commit af04016
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Threading.Tasks;
using Esfa.Recruit.Employer.Web.Configuration;
using Esfa.Recruit.Employer.Web.Configuration.Routing;
using Esfa.Recruit.Employer.Web.Extensions;
using Esfa.Recruit.Employer.Web.Orchestrators;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public ManageNotificationsAcknowledgementViewModel GetAcknowledgementViewModel(M
return new ManageNotificationsAcknowledgementViewModel
{
IsApplicationSubmittedSelected = editModel.IsApplicationSubmittedSelected,
IsVacancySentForEmployerReviewSelected = editModel.IsVacancySentForEmployerReviewSelected,
IsVacancyClosingSoonSelected = editModel.IsVacancyClosingSoonSelected,
IsVacancyRejectedSelected = editModel.IsVacancyRejectedSelected,
IsUserSubmittedVacanciesSelected = editModel.NotificationScope.GetValueOrDefault() == NotificationScope.UserSubmittedVacancies,
Expand All @@ -83,7 +84,8 @@ private UserNotificationPreferences GetDomainModel(ManageNotificationsEditModel
targetModel.NotificationTypes =
(sourceModel.IsApplicationSubmittedSelected ? NotificationTypes.ApplicationSubmitted : NotificationTypes.None)
| (sourceModel.IsVacancyClosingSoonSelected ? NotificationTypes.VacancyClosingSoon : NotificationTypes.None)
| (sourceModel.IsVacancyRejectedSelected ? NotificationTypes.VacancyRejected : NotificationTypes.None);
| (sourceModel.IsVacancyRejectedSelected ? NotificationTypes.VacancyRejected : NotificationTypes.None)
| (sourceModel.IsVacancySentForEmployerReviewSelected ? NotificationTypes.VacancySentForReview : NotificationTypes.None);

return targetModel;
}
Expand All @@ -95,6 +97,7 @@ private ManageNotificationsViewModel GetViewModelFromDomainModel(UserNotificatio
IsVacancyRejectedSelected = (preferences.NotificationTypes & NotificationTypes.VacancyRejected) == NotificationTypes.VacancyRejected,
IsVacancyClosingSoonSelected = (preferences.NotificationTypes & NotificationTypes.VacancyClosingSoon) == NotificationTypes.VacancyClosingSoon,
IsApplicationSubmittedSelected = (preferences.NotificationTypes & NotificationTypes.ApplicationSubmitted) == NotificationTypes.ApplicationSubmitted,
IsVacancySentForEmployerReviewSelected = (preferences.NotificationTypes & NotificationTypes.VacancySentForReview) == NotificationTypes.VacancySentForReview,
NotificationFrequency = preferences.NotificationFrequency,
NotificationScope = preferences.NotificationScope
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class ManageNotificationsAcknowledgementViewModel
{
public string UserEmail { get; set; }
public bool IsVacancyRejectedSelected { get; set; }
public bool IsVacancySentForEmployerReviewSelected { get; set; }
public bool IsVacancyClosingSoonSelected { get; set; }
public bool IsApplicationSubmittedSelected { get; set; }
public string Frequency { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ namespace Esfa.Recruit.Employer.Web.ViewModels.ManageNotifications
public class ManageNotificationsEditModel
{
public bool IsVacancyRejectedSelected { get; set; }
public bool IsVacancySentForEmployerReviewSelected { get; set; }
public bool IsVacancyClosingSoonSelected { get; set; }
public bool IsApplicationSubmittedSelected { get; set; }
public NotificationFrequency? NotificationFrequency { get; set; }
public NotificationScope? NotificationScope { get; set; }
public bool HasAnySubscription => IsVacancyRejectedSelected || IsVacancyClosingSoonSelected || IsApplicationSubmittedSelected;
public bool HasAnySubscription => IsVacancyRejectedSelected || IsVacancyClosingSoonSelected || IsApplicationSubmittedSelected || IsVacancySentForEmployerReviewSelected;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ namespace Esfa.Recruit.Employer.Web.ViewModels.ManageNotifications
public class ManageNotificationsViewModel
{
public bool IsVacancyRejectedSelected { get; set; }
public bool IsVacancySentForEmployerReviewSelected { get; set; }
public bool IsVacancyClosingSoonSelected { get; set; }
public bool IsApplicationSubmittedSelected { get; set; }
public NotificationFrequency? NotificationFrequency { get; set; }
public NotificationScope? NotificationScope { get; set; }
public bool HasAnySubscription => IsVacancyRejectedSelected || IsVacancyClosingSoonSelected || IsApplicationSubmittedSelected;
public bool HasAnySubscription => IsVacancyRejectedSelected || IsVacancyClosingSoonSelected || IsApplicationSubmittedSelected || IsVacancySentForEmployerReviewSelected;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
<span class="govuk-visually-hidden">Get notifications </span>When an advert is rejected after review
</label>
</div>
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" asp-for="IsVacancySentForEmployerReviewSelected" id="notifications-review" type="checkbox">
<label class="govuk-label govuk-checkboxes__label" for="notifications-review">
<span class="govuk-visually-hidden">Get notifications </span>When a provider sends an advert for review
</label>
</div>
<div asp-hide="true">
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" asp-for="IsVacancyClosingSoonSelected" id="notifications-closing" type="checkbox">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,19 @@
</div>

<div class="govuk-body">

@*User submitted and only one option selected*@
<p asp-show="(Model.IsUserSubmittedVacanciesSelected && Model.IsVacancyRejectedSelected && !Model.IsApplicationSubmittedSelected)"> We'll email <b>@Model.UserEmail</b> about any adverts you submit. You'll get emails when an advert is rejected after review. </p>
<p asp-show="(Model.IsUserSubmittedVacanciesSelected && !Model.IsVacancyRejectedSelected && Model.IsApplicationSubmittedSelected)"> We'll email <b>@Model.UserEmail</b> about any adverts you submit. You'll get emails when you receive new applications (@Model.Frequency). </p>

@*All organisation and only one option selected*@
<p asp-show="(!Model.IsUserSubmittedVacanciesSelected && Model.IsVacancyRejectedSelected && !Model.IsApplicationSubmittedSelected)"> We'll email <b>@Model.UserEmail</b> about all apprenticeship adverts for your organisation. You'll get emails when an advert is rejected after review. </p>
<p asp-show="(!Model.IsUserSubmittedVacanciesSelected && !Model.IsVacancyRejectedSelected && Model.IsApplicationSubmittedSelected)"> We'll email <b>@Model.UserEmail</b> about all apprenticeship adverts for your organisation. You'll get emails when you receive new applications (@Model.Frequency). </p>

<div asp-show="Model.IsVacancyRejectedSelected && Model.IsApplicationSubmittedSelected">
<p asp-show="Model.IsUserSubmittedVacanciesSelected"> We'll email <b>@Model.UserEmail</b> about any adverts you submit. You'll get emails when: </p>
<p asp-show="!Model.IsUserSubmittedVacanciesSelected"> We'll email <b>@Model.UserEmail</b> about all apprenticeship adverts for your organisation. You'll get emails when: </p>
<div>
<p asp-show="Model.IsUserSubmittedVacanciesSelected"> We'll email <b>@Model.UserEmail</b> about any adverts you submit. You'll get emails: </p>
<p asp-show="!Model.IsUserSubmittedVacanciesSelected"> We'll email <b>@Model.UserEmail</b> about all apprenticeship adverts for your organisation. You'll get emails: </p>

<ul class="govuk-list govuk-list--bullet">
<li>
an advert is rejected after review
<li asp-show="Model.IsVacancyRejectedSelected">
when an advert is rejected after review
</li>
<li asp-show="Model.IsVacancySentForEmployerReviewSelected">
when a provider sends an advert for review
</li>
<li>
you receive new applications (@Model.Frequency)
<li asp-show="Model.IsApplicationSubmittedSelected">
when there are new applications
</li>
</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,24 @@ public async Task WhenUserPreferencesAreNotSet()
result.IsApplicationSubmittedSelected.Should().BeFalse();
result.IsVacancyClosingSoonSelected.Should().BeFalse();
result.IsVacancyRejectedSelected.Should().BeFalse();
result.IsVacancySentForEmployerReviewSelected.Should().BeFalse();
result.NotificationFrequency.Should().BeNull();
result.NotificationScope.Should().BeNull();
}

[Theory]
[InlineData(NotificationTypes.None, false, false, false)]
[InlineData(NotificationTypes.ApplicationSubmitted, true, false, false)]
[InlineData(NotificationTypes.VacancyClosingSoon, false, true, false)]
[InlineData(NotificationTypes.VacancyRejected, false, false, true)]
[InlineData(NotificationTypes.VacancyRejected | NotificationTypes.VacancyClosingSoon | NotificationTypes.ApplicationSubmitted, true, true, true)]
[InlineData(NotificationTypes.VacancyClosingSoon | NotificationTypes.ApplicationSubmitted, true, true, false)]
[InlineData(NotificationTypes.VacancyRejected | NotificationTypes.VacancyClosingSoon, false, true, true)]
[InlineData(NotificationTypes.None, false, false, false, false)]
[InlineData(NotificationTypes.ApplicationSubmitted, true, false, false, false)]
[InlineData(NotificationTypes.VacancyClosingSoon, false, true, false, false)]
[InlineData(NotificationTypes.VacancyRejected, false, false, true, false)]
[InlineData(NotificationTypes.VacancySentForReview, false, false, false, true)]
[InlineData(NotificationTypes.VacancyRejected | NotificationTypes.VacancyClosingSoon | NotificationTypes.ApplicationSubmitted | NotificationTypes.VacancySentForReview, true, true, true, true)]
[InlineData(NotificationTypes.VacancyClosingSoon | NotificationTypes.ApplicationSubmitted, true, true, false, false)]
[InlineData(NotificationTypes.VacancyRejected | NotificationTypes.VacancyClosingSoon, false, true, true, false)]
[InlineData(NotificationTypes.VacancySentForReview | NotificationTypes.ApplicationSubmitted, true, false, false, true)]
[InlineData(NotificationTypes.VacancyRejected | NotificationTypes.VacancySentForReview, false, false, true, true)]
public async Task WhenUserPreferencesAreSet(NotificationTypes notificationTypes, bool expectedIsApplicationSubmittedSelected,
bool expectedIsVacancyClosingSoonSelected, bool expectedIsVacancyRejectedSelected)
bool expectedIsVacancyClosingSoonSelected, bool expectedIsVacancyRejectedSelected, bool expectIsVacancySentForReviewSelected)
{
_recruitVacancyClientMock
.Setup(c => c.GetUserNotificationPreferencesAsync(It.IsAny<string>()))
Expand All @@ -46,6 +50,7 @@ public async Task WhenUserPreferencesAreSet(NotificationTypes notificationTypes,
result.IsApplicationSubmittedSelected.Should().Be(expectedIsApplicationSubmittedSelected);
result.IsVacancyClosingSoonSelected.Should().Be(expectedIsVacancyClosingSoonSelected);
result.IsVacancyRejectedSelected.Should().Be(expectedIsVacancyRejectedSelected);
result.IsVacancySentForEmployerReviewSelected.Should().Be(expectIsVacancySentForReviewSelected);
}

private ManageNotificationsOrchestrator GetSut()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private CommunicationRequest GetRejectedVacancyCommunicationRequest(long vacancy
{
var communicationRequest = new CommunicationRequest(
CommunicationConstants.RequestType.VacancyRejectedByEmployer,
CommunicationConstants.ParticipantResolverNames.VacancyParticipantsResolverName,
CommunicationConstants.ParticipantResolverNames.ProviderParticipantsResolverName,
CommunicationConstants.ServiceName);
communicationRequest.AddEntity(CommunicationConstants.EntityTypes.Vacancy, vacancyReference);
communicationRequest.AddEntity(CommunicationConstants.EntityTypes.ApprenticeshipServiceUrl, vacancyReference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public async Task HandleAsync(string eventPayload)
private CommunicationRequest GetReviewedVacancyCommunicationRequest(long vacancyReference, long ukprn, string employerAccountId)
{
var communicationRequest = new CommunicationRequest(
CommunicationConstants.RequestType.VacancySubmittedForReviewed,
CommunicationConstants.ParticipantResolverNames.VacancyParticipantsResolverName,
CommunicationConstants.RequestType.VacancySubmittedForReview,
CommunicationConstants.ParticipantResolverNames.EmployerParticipantsResolverName,
CommunicationConstants.ServiceName);
communicationRequest.AddEntity(CommunicationConstants.EntityTypes.Vacancy, vacancyReference);
communicationRequest.AddEntity(CommunicationConstants.EntityTypes.ApprenticeshipServiceUrl, vacancyReference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static class RequestType
public const string VacancyRejected = nameof(VacancyRejected);
public const string ApplicationSubmitted = nameof(ApplicationSubmitted);
public const string VacancyWithdrawnByQa = nameof(VacancyWithdrawnByQa);
public const string VacancySubmittedForReviewed = nameof(VacancySubmittedForReviewed);
public const string VacancySubmittedForReview = nameof(VacancySubmittedForReview);
public const string ProviderBlockedProviderNotification = nameof(ProviderBlockedProviderNotification);
public const string ProviderBlockedEmployerNotificationForTransferredVacancies = nameof(ProviderBlockedEmployerNotificationForTransferredVacancies);
public const string ProviderBlockedEmployerNotificationForLiveVacancies = nameof(ProviderBlockedEmployerNotificationForLiveVacancies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<IEnumerable<CommunicationDataItem>> GetDataItemsAsync(object e
private CommunicationDataItem GetApplicationUrlDataItem(Vacancy vacancy)
{
var url = string.Empty;
if (vacancy.OwnerType == OwnerType.Employer)
if (vacancy.OwnerType == OwnerType.Employer || vacancy.Status == VacancyStatus.Review)
{
var baseUri = new Uri(_communicationsConfiguration.EmployersApprenticeshipServiceUrl);
var uri = new Uri(baseUri, vacancy.EmployerAccountId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public Task<string> GetTemplateIdAsync(CommunicationMessage message)
var templateId = string.Empty;
switch(message.RequestType)
{
case CommunicationConstants.RequestType.VacancySubmittedForReviewed:
case CommunicationConstants.RequestType.VacancySubmittedForReview:
templateId = CommunicationConstants.TemplateIds.VacancySubmittedForReview;
break;
case CommunicationConstants.RequestType.VacancyRejected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public async Task<CommunicationUserPreference> GetUserPreferenceAsync(string req
case CommunicationConstants.RequestType.ApplicationSubmitted:
SetPreferencesForApplicationSubmittedNotification(userPref, userPreference);
return userPref;
case CommunicationConstants.RequestType.VacancySubmittedForReview:
SetPreferencesForVacancySentForReviewNotification(userPref, userPreference);
return userPref;
case CommunicationConstants.RequestType.VacancyWithdrawnByQa:
case CommunicationConstants.RequestType.ProviderBlockedProviderNotification:
case CommunicationConstants.RequestType.ProviderBlockedEmployerNotificationForTransferredVacancies:
Expand All @@ -56,6 +59,17 @@ private void SetPreferencesForVacancyRejectedNotification(CommunicationUserPrefe
}
}

private void SetPreferencesForVacancySentForReviewNotification(CommunicationUserPreference userPref, UserNotificationPreferences userPreference)
{
if (userPreference == null) return;
if (userPreference.NotificationTypes.HasFlag(NotificationTypes.VacancySentForReview))
{
userPref.Channels = DeliveryChannelPreferences.EmailOnly;
userPref.Frequency = DeliveryFrequency.Immediate;
userPref.Scope = NotificationScope.Organisation;
}
}

private void SetPreferencesForApplicationSubmittedNotification(CommunicationUserPreference userPref, UserNotificationPreferences userPreference)
{
if (userPreference == null) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public enum NotificationTypes
None = 0,
VacancyRejected = 1,
VacancyClosingSoon = 1 << 1,
ApplicationSubmitted = 1 << 2
ApplicationSubmitted = 1 << 2,
VacancySentForReview = 1 << 3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ private async Task Handle(IApplicationReviewEvent notification)

var vacancy = await _vacancyRepository.GetVacancyAsync(notification.VacancyReference);

_logger.LogInformation("Handling {eventType} for ukprn: {ukprn} and vacancyReference: {vacancyReference}", notification.GetType().Name, vacancy.TrainingProvider.Ukprn.Value, notification.VacancyReference);
await _dashboardService.ReBuildDashboardAsync(vacancy.TrainingProvider.Ukprn.Value);
if (vacancy.TrainingProvider != null)
{
_logger.LogInformation("Handling {eventType} for ukprn: {ukprn} and vacancyReference: {vacancyReference}", notification.GetType().Name, vacancy.TrainingProvider.Ukprn.Value, notification.VacancyReference);
await _dashboardService.ReBuildDashboardAsync(vacancy.TrainingProvider.Ukprn.Value);
}
}

private async Task Handle(IVacancyEvent notification)
Expand All @@ -152,8 +155,11 @@ private async Task Handle(IVacancyEvent notification)

var vacancy = await _vacancyRepository.GetVacancyAsync(notification.VacancyId);

_logger.LogInformation("Handling {eventType} for ukprn: {ukprn} and vacancyId: {vacancyId}", notification.GetType().Name, vacancy.TrainingProvider.Ukprn.Value, notification.VacancyId);
await _dashboardService.ReBuildDashboardAsync(vacancy.TrainingProvider.Ukprn.Value);
if (vacancy.TrainingProvider != null)
{
_logger.LogInformation("Handling {eventType} for ukprn: {ukprn} and vacancyId: {vacancyId}", notification.GetType().Name, vacancy.TrainingProvider.Ukprn.Value, notification.VacancyId);
await _dashboardService.ReBuildDashboardAsync(vacancy.TrainingProvider.Ukprn.Value);
}
}
}
}
Loading

0 comments on commit af04016

Please sign in to comment.