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

feat: only allow applications in application period #53

Merged

Conversation

Xtrah
Copy link
Member

@Xtrah Xtrah commented Mar 24, 2022

Closes #43

Summary of changes

  • Throw error if applications are posted outside of application period
  • Update applicationPeriodStatus check to include the end date in the application period
  • Force MongoDB to use applicationperiod as collection instead of defaulting to applicationperiods

@Xtrah Xtrah added the backend 🍑 Backend tasks label Mar 24, 2022
@Xtrah Xtrah linked an issue Mar 24, 2022 that may be closed by this pull request
@Xtrah Xtrah force-pushed the 43-update-backend-to-only-allow-applications-in-application-period branch from c903c96 to b77b267 Compare March 24, 2022 20:43
Copy link
Collaborator

@LiviaValenti LiviaValenti left a comment

Choose a reason for hiding this comment

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

Nice 📈 Will test it locally tomorrow 🧪

backend/utils/applicationPeriodStatus.ts Outdated Show resolved Hide resolved
backend/controllers/applicationController.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@SanderArntzen SanderArntzen left a comment

Choose a reason for hiding this comment

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

Nice changes, good catch on the end date for period status check.
Can't test it locally before the test-user is authorized again in the dev-environment, so can't approve the PR yet

@Xtrah Xtrah assigned LiviaValenti and unassigned Xtrah Mar 25, 2022
@Xtrah Xtrah requested a review from LiviaValenti March 25, 2022 10:41
Copy link
Contributor

@SanderArntzen SanderArntzen left a comment

Choose a reason for hiding this comment

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

The code changes behaves as expected when tested locally. Nice!

Copy link
Collaborator

@LiviaValenti LiviaValenti left a comment

Choose a reason for hiding this comment

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

Nice work! I can see we have some issues with error-handling. E.g. when the application period does not exist. I also noticed if you send a bad request (e.g. no body) to the applications-endpoint it crashes the app 👀

Can be partially fixed by adding a proper catch with some responses after .then in postApplication, but its a tiny bit hacky 😕

E.g.

.catch((err) => { if(err.name === 'ValidationError'){ return res.status(400).json({ message: err.message }) } return res.status(500).json({ message: "Unable to save application" }) })

backend/controllers/applicationController.ts Show resolved Hide resolved
Copy link
Collaborator

@LiviaValenti LiviaValenti left a comment

Choose a reason for hiding this comment

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

Copy link
Collaborator

@LiviaValenti LiviaValenti left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 @SanderArntzen, can you test one last time?

Copy link
Contributor

@SanderArntzen SanderArntzen left a comment

Choose a reason for hiding this comment

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

The error-handling for when application period doesn't exist, and sending a uncomplete body to POST application, works now. Good job 👍

@Xtrah Xtrah merged commit 75e08ed into dev Mar 26, 2022
@Xtrah Xtrah deleted the 43-update-backend-to-only-allow-applications-in-application-period branch March 26, 2022 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend 🍑 Backend tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update backend to only allow applications in application period
3 participants