Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TMI2-697: handle draft adverts #125

Merged
merged 4 commits into from
Mar 6, 2024
Merged

Conversation

rachelswart
Copy link
Contributor

@rachelswart rachelswart commented Mar 4, 2024

Description

It checks the scheme version instead of the submission version inside addMandatoryQuestionsToSubmissionObject and
only adds grant adverts to grantAdvertDtos list if it has a status of PUBLISHED

Ticket # and link
TMI2-697: https://technologyprogramme.atlassian.net/browse/TMI2-697

Summary of the changes and the related issue. List any dependencies that are required for this change:

Type of change

Please check the relevant options.

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • This change requires a documentation update.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes:

  • Unit Test

  • Integration Test (if applicable)

  • End to End Test (if applicable)

Screenshots (if appropriate):

Please attach screenshots of the change if it is a UI change:

Checklist:

  • If I have listed dependencies above, I have ensured that they are present in the target branch.
  • I have performed a self-review of my code.
  • I have commented my code in hard-to-understand areas.
  • I have made corresponding changes to the documentation where applicable.
  • I have ran cypress tests and they all pass locally.

@dylanwrightCO
Copy link
Contributor

dylanwrightCO commented Mar 4, 2024

Will this work for v1 schemes?

On the frontend in the page 'redirect-from-find.page.tsx' we call the applicant be (/grant-adverts) which returns an isInternal field in the dto. This is then used to redirect the user to the external url:

if (version === 1) {
      const redirectUrl = isInternal
        ? `${process.env.HOST}${routes.applications}/${grantApplicationId}`
        : externalSubmissionUrl;
      res.redirect(redirectUrl);
    }

The backend method that determines this value is:

public boolean doesSchemeHaveApplication(final GrantScheme grantScheme) { return grantApplicationRepository.findByGrantScheme(grantScheme).isPresent(); }

which doesn't take into account the application status.

Jamie also pointed out that in find fe (/apply/[pid]) we do the same check:

const isV1External =
    advertSummary.data.schemeVersion === 1 &&
    advertSummary.data.internalApplication === false;

  const redirectUrl =
    newMandatoryQuestionsEnabled === 'true' && !isV1External
      ? `${applicantUrl}/api/redirect-from-find?slug=${path}&grantWebpageUrl=${grantDetail.fields.grantWebpageUrl}`
      : grantDetail.fields.grantWebpageUrl;

Which coincidently uses the same method doesSchemeHaveApplication(), so we need to update this to consider the status of the application

.map(grantAdvert -> grantAdvertService.grantAdvertToDto(grantAdvert, jwtPayload.getSub(), grantSchemeId))
.map(grantAdvert ->
grantAdvert.getStatus().equals(GrantAdvertStatus.PUBLISHED) ?
grantAdvertService.grantAdvertToDto(grantAdvert, jwtPayload.getSub(), grantSchemeId) : null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this end up putting null values in the list? Not sure if that matters later on or not but if it does its probably not ideal

@rachelswart rachelswart merged commit 83d0fcf into develop Mar 6, 2024
1 check passed
iaincooper-tco pushed a commit that referenced this pull request Mar 8, 2024
* checks scheme version instead of submission version and only returns published adverts

* removed comment

* updated method to check for application status

* replaced null logic with filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants