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-3470-Employer-can-choose-to-receive-email-when-a-provider-submits-an-advert-for-review
  • Loading branch information
Paul Howes committed May 21, 2021
2 parents 24cc550 + 4de94eb commit c72137c
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ public async Task<IActionResult> ApproveJobAdvert(ApproveJobAdvertViewModel vm)
}

[HttpGet("reject-advert", Name = RouteNames.RejectJobAdvert_Get)]
public IActionResult RejectJobAdvert(VacancyRouteModel vm)
{
return View(new RejectJobAdvertViewModel());
public async Task<IActionResult> RejectJobAdvert(VacancyRouteModel vm)
{
var viewModel = await _orchestrator.GetVacancyRejectJobAdvertAsync(vm);

return View(viewModel);
}


Expand All @@ -128,7 +130,8 @@ public async Task<IActionResult> RejectJobAdvert(RejectJobAdvertViewModel vm)
{
if (!ModelState.IsValid)
{
return View("RejectJobAdvert");
var viewModel = await _orchestrator.GetVacancyRejectJobAdvertAsync(vm);
return View("RejectJobAdvert", viewModel);
}

if (vm.RejectJobAdvert.GetValueOrDefault())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ public async Task<OrchestratorResponse<RejectVacancyResponse>> RejectJobAdvertAs

public async Task<JobAdvertConfirmationViewModel> GetVacancyConfirmationJobAdvertAsync(VacancyRouteModel vrm)
{
var vacancy = await _vacancyClient.GetVacancyAsync(vrm.VacancyId);

Utility.CheckAuthorisedAccess(vacancy, vrm.EmployerAccountId);
var vacancy = await _vacancyClient.GetVacancyAsync(vrm.VacancyId);

var vm = new JobAdvertConfirmationViewModel
{
Expand All @@ -196,6 +194,18 @@ public async Task<JobAdvertConfirmationViewModel> GetVacancyConfirmationJobAdver
return vm;
}

public async Task<RejectJobAdvertViewModel> GetVacancyRejectJobAdvertAsync(VacancyRouteModel vrm)
{
var vacancy = await _vacancyClient.GetVacancyAsync(vrm.VacancyId);

var vm = new RejectJobAdvertViewModel
{
TrainingProviderName = vacancy.TrainingProvider.Name
};

return vm;
}

private void FlattenErrors(IList<EntityValidationError> errors)
{
//Flatten Qualification errors to its ViewModel parent instead. 'Qualifications[1].Grade' becomes 'Qualifications'
Expand Down
2 changes: 1 addition & 1 deletion src/Employer/Employer.Web/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void CheckAuthorisedAccess(Vacancy vacancy, string employerAccount
{
if (!vacancy.EmployerAccountId.Equals(employerAccountId, StringComparison.OrdinalIgnoreCase))
throw new AuthorisationException(string.Format(ExceptionMessages.VacancyUnauthorisedAccess, employerAccountId, vacancy.EmployerAccountId, vacancy.Title, vacancy.Id));
if (vacancy.Status != VacancyStatus.Review && vacancy.OwnerType != OwnerType.Employer)
if (!vacancy.CanEmployerAndProviderCollabarate && vacancy.OwnerType != OwnerType.Employer)
throw new AuthorisationException(string.Format(ExceptionMessages.UserIsNotTheOwner, OwnerType.Employer));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ public class RejectJobAdvertViewModel : VacancyRouteModel
{
[Required(ErrorMessage = "Select if you want to reject this job advert")]
public bool? RejectJobAdvert { get; set; }

public string TrainingProviderName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ViewBag.Title = "Are you sure you want to approve this job advert?"; }
Are you sure you want to approve this job advert?
</h1>
</div>
<p>We'll do a final review and post it on 'Find an apprenticeship'.</p>
<p class="govuk-body">We'll do a final review and post it on 'Find an apprenticeship'.</p>
<form asp-route="@RouteNames.ApproveJobAdvert_Post">
<div esfa-validation-marker-for="ApproveJobAdvert" class="govuk-form-group">
<fieldset class="govuk-fieldset">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
</div>

<div asp-show="@Model.ApprovedJobAdvert">
<p>We'll do a final review and then post it on 'Find an apprenticeship'.</p>
<p class="govuk-body">We'll do a final review and then post it on 'Find an apprenticeship'.</p>
</div>

<div asp-show="@Model.RejectedJobAdvert">
<p>This job advert has gone back to @Model.TrainingProviderName. You may want to tell them why youve rejected it.</p>
<p class="govuk-body">This job advert has gone back to @Model.TrainingProviderName. You may want to tell them why you've rejected it.</p>
</div>

<h2 class="govuk-heading-m">What happens next</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ViewBag.Title = "Are you sure you want to reject this job advert?"; }
Are you sure you want to reject this job advert?
</h1>
</div>
<p>We'll do a final review and post it on 'Find an apprenticeship'.</p>
<p class="govuk-body">This job advert will go back to @Model.TrainingProviderName. You may want to tell them why you're rejecting it.</p>
<form asp-route="@RouteNames.RejectJobAdvert_Post">
<div esfa-validation-marker-for="RejectJobAdvert" class="govuk-form-group">
<fieldset class="govuk-fieldset">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ public class VacancyPreviewViewModel : DisplayVacancyViewModel

public bool ShowIncompleteSections => ((HasIncompleteMandatorySections || HasIncompleteOptionalSections) && !Review.HasBeenReviewed) || HasSoftValidationErrors;
public ReviewSummaryViewModel Review { get; set; } = new ReviewSummaryViewModel();
public string SubmitButtonText => Review.HasBeenReviewed
? "Resubmit vacancy"
: RequiresEmployerReview
? Status == VacancyStatus.Rejected
? "Resubmit vacancy to employer"
: "Send to employer"

public string SubmitButtonText => RequiresEmployerReview
? Status == VacancyStatus.Rejected
? "Resubmit vacancy to employer"
: "Send to employer"
: Review.HasBeenReviewed
? "Resubmit vacancy"
: "Submit vacancy";
public bool ApplicationInstructionsRequiresEdit => IsEditRequired(FieldIdentifiers.ApplicationInstructions);
public bool ApplicationMethodRequiresEdit => IsEditRequired(FieldIdentifiers.ApplicationMethod);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public async Task Handle(SubmitVacancyCommand message, CancellationToken cancell
if(vacancy.CanSubmit == false)
throw new InvalidOperationException(string.Format(InvalidStateExceptionMessageFormat, vacancy.Id, vacancy.Status));

if(vacancy.OwnerType != message.SubmissionOwner)
if(vacancy.OwnerType != message.SubmissionOwner && vacancy.Status != VacancyStatus.Review)
throw new InvalidOperationException(string.Format(InvalidOwnerExceptionMessageFormat, vacancy.Id, message.SubmissionOwner, vacancy.OwnerType));

var now = _timeProvider.Now;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task<string> GetEmployerNameAsync(Vacancy vacancy)

public async Task<string> GetEmployerDescriptionAsync(Vacancy vacancy)
{
if (!vacancy.CanEmployerEdit)
if (!vacancy.CanGetEmployerProfileAboutOrganisation)
return vacancy.EmployerDescription;

var profile = await _employerProfileRepository.GetAsync(vacancy.EmployerAccountId, vacancy.AccountLegalEntityPublicHashedId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public class Vacancy
Status == VacancyStatus.Review)
&& IsDeleted == false;

public bool CanGetEmployerProfileAboutOrganisation => (Status == VacancyStatus.Draft ||
Status == VacancyStatus.Referred)
&& IsDeleted == false;

/// <summary>
/// The vacancy is being edited
/// We can only submit draft & referred & rejected vacancies that have not been deleted
Expand Down Expand Up @@ -120,6 +124,8 @@ public class Vacancy

public bool CanReview => Status == VacancyStatus.Review && IsDeleted == false;

public bool CanEmployerAndProviderCollabarate => (Status == VacancyStatus.Review || Status == VacancyStatus.Rejected);

public bool IsDisabilityConfident => DisabilityConfident == DisabilityConfident.Yes;

/// <summary>
Expand Down

0 comments on commit c72137c

Please sign in to comment.