WIP Functionality to request wines for next lottery #24

Merged
Adrianht merged 23 commits from feat/request-wine into master 2020-09-07 14:28:31 +00:00
Adrianht commented 2020-08-30 15:37:55 +00:00 (Migrated from github.com)

Idea

Create a route where users are able to search for wines they want to have included in the next lottery, with some functionality to see requested wines. Admins should also have some functionality to clear and pick selected wines to request for pickup at a vinmonopolet store.

Hopefully this will increase the quality of the wines/beverages aswell as increase the quantity of participants in the weekly lottery

Progress

  • Functionality to lookup and search for wines, then add them to the db
  • Route where users can see what wines have already been requested, here they should be able to +1 a wine they want thats already requested
  • Update so it works with #21
  • Admin functionality to delete a requested wine
    Admin functionality to pick requested wines and then send an order to vimonopolet for pickup of selected wines.
## Idea Create a route where users are able to search for wines they want to have included in the next lottery, with some functionality to see requested wines. Admins should also have some functionality to clear and pick selected wines to request for pickup at a vinmonopolet store. Hopefully this will increase the quality of the wines/beverages aswell as increase the quantity of participants in the weekly lottery ## Progress - [x] Functionality to lookup and search for wines, then add them to the db - [x] Route where users can see what wines have already been requested, here they should be able to +1 a wine they want thats already requested - [x] Update so it works with #21 - [x] Admin functionality to delete a requested wine ~~Admin functionality to pick requested wines and then send an order to vimonopolet for pickup of selected wines.~~
KevinMidboe (Migrated from github.com) reviewed 2020-09-04 13:34:06 +00:00
KevinMidboe (Migrated from github.com) commented 2020-09-04 10:33:15 +00:00

Move this to request.js and change endpoint to /request/all.

Move this to `request.js` and change endpoint to `/request/all`.
@@ -1,5 +1,51 @@
const fetch = require('node-fetch')
KevinMidboe (Migrated from github.com) commented 2020-09-04 10:37:03 +00:00

Change to 500x500

Change to 500x500
KevinMidboe (Migrated from github.com) commented 2020-09-04 10:37:44 +00:00

Reflect changes above.

Reflect changes above.
KevinMidboe commented 2020-09-07 08:10:37 +00:00 (Migrated from github.com)

Idea for checking if user is admin:

Proof of concept:
In middleware/mustBeAuthenticated we can set a Vinlottis-Admin header to true after the if test that returns an 401 if not authenticated.
Set header with: res.set("Vinlottis-Admin", true).

Implementation:
Obs! This will only work for endpoints that use the middleware mustBeAuthenticated.
We could:

  • create a new middleware e.g. "set header if admin" which is used (used = app(use) which means it's used for all0 requests) in server.js that adds the header to all requests.
  • Chain the new middleware "set header if admin" to be used on the specific route that needs to know if admin (in this case "/request/all") endpoint.
Idea for checking if user is admin: **Proof of concept:** In `middleware/mustBeAuthenticated` we can set a `Vinlottis-Admin` header to true after the if test that returns an 401 if not authenticated. Set header with: `res.set("Vinlottis-Admin", true)`. **Implementation:** Obs! This will only work for endpoints that use the middleware `mustBeAuthenticated`. We could: - create a new middleware e.g. "set header if admin" which is used (used = app(use) which means it's used for all0 requests) in `server.js` that adds the header to all requests. - Chain the new middleware "set header if admin" to be used on the specific route that needs to know if admin (in this case `"/request/all"`) endpoint.
KevinMidboe (Migrated from github.com) reviewed 2020-09-07 08:36:35 +00:00
KevinMidboe (Migrated from github.com) commented 2020-09-07 08:26:25 +00:00

Is this still used?

Is this still used?
KevinMidboe (Migrated from github.com) commented 2020-09-07 08:26:13 +00:00

Is this used?

Is this used?
@@ -1,5 +1,51 @@
const fetch = require('node-fetch')
KevinMidboe (Migrated from github.com) commented 2020-09-07 08:25:16 +00:00

Refactor this document to reflect changes to backend route setup.

TODO:

  • Define this endpoint in /api/router.js (e.g. /wineinfo/search).
  • Change this to be a named anonymous function.
  • Export this function at bottom of doc. (e.g. `module.exports = { NAME_OF_FUNCTION, NAME_OF_FUNCTION_2, ... }
Refactor this document to reflect changes to backend route setup. TODO: - Define this endpoint in `/api/router.js` (e.g. `/wineinfo/search`). - Change this to be a named anonymous function. - Export this function at bottom of doc. (e.g. `module.exports = { NAME_OF_FUNCTION, NAME_OF_FUNCTION_2, ... }
@@ -9,7 +9,6 @@ const User = require(path.join(__dirname + "/schemas/User"));
const apiRouter = require(path.join(__dirname + "/api/router.js"));
KevinMidboe (Migrated from github.com) commented 2020-09-07 08:28:15 +00:00

Reflect changes from #21 and move this to /api/router.js.

Reflect changes from #21 and move this to `/api/router.js`.
KevinMidboe (Migrated from github.com) commented 2020-09-07 08:29:47 +00:00

This is in the template which is scoped to this so we can write: wines == undefined. Also the length of a list will not be less that zero so change check to be wines.length == 0.

This is in the template which is scoped to `this` so we can write: `wines == undefined`. Also the length of a list will not be less that zero so change check to be `wines.length == 0`.
KevinMidboe (Migrated from github.com) commented 2020-09-07 08:31:38 +00:00

Shorthand would be this.wines = await allRequestedWines() || [];

Shorthand would be `this.wines = await allRequestedWines() || [];`
KevinMidboe (Migrated from github.com) commented 2020-09-07 08:33:01 +00:00

Could the item deleted be sent up here and we filter it away instead of making a new request?

Could the item deleted be sent up here and we filter it away instead of making a new request?
KevinMidboe (Migrated from github.com) commented 2020-09-07 08:34:04 +00:00

Rename too wineDeleted and emit the wine element.

Rename too `wineDeleted` and emit the wine element.
KevinMidboe (Migrated from github.com) commented 2020-09-07 08:35:18 +00:00

Vinnere ?

Vinnere ?
Adrianht (Migrated from github.com) reviewed 2020-09-07 13:53:58 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 13:53:57 +00:00

fixed

fixed
Adrianht (Migrated from github.com) reviewed 2020-09-07 13:54:27 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 13:54:27 +00:00

fixed

fixed
Adrianht (Migrated from github.com) reviewed 2020-09-07 13:55:35 +00:00
@@ -9,7 +9,6 @@ const User = require(path.join(__dirname + "/schemas/User"));
const apiRouter = require(path.join(__dirname + "/api/router.js"));
Adrianht (Migrated from github.com) commented 2020-09-07 13:55:35 +00:00

fixed

fixed
Adrianht (Migrated from github.com) reviewed 2020-09-07 13:55:42 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 13:55:41 +00:00

fixed

fixed
Adrianht (Migrated from github.com) reviewed 2020-09-07 13:55:48 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 13:55:47 +00:00

fixed

fixed
Adrianht (Migrated from github.com) reviewed 2020-09-07 13:55:53 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 13:55:52 +00:00

fixed

fixed
Adrianht (Migrated from github.com) reviewed 2020-09-07 13:55:58 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 13:55:58 +00:00

fixed

fixed
Adrianht (Migrated from github.com) reviewed 2020-09-07 13:56:07 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 13:56:06 +00:00

🤷‍♂️ fixed

🤷‍♂️ fixed
KevinMidboe commented 2020-09-07 13:56:54 +00:00 (Migrated from github.com)

Closes #19.

Closes #19.
KevinMidboe (Migrated from github.com) reviewed 2020-09-07 14:03:08 +00:00
KevinMidboe (Migrated from github.com) commented 2020-09-07 14:00:10 +00:00

Remove

Remove
KevinMidboe (Migrated from github.com) commented 2020-09-07 14:00:13 +00:00

Remove

Remove
KevinMidboe (Migrated from github.com) commented 2020-09-07 14:00:35 +00:00

Is this used?

Is this used?
KevinMidboe (Migrated from github.com) commented 2020-09-07 14:01:34 +00:00
      [this.wines, this.isAdmin] = await allRequestedWines() || [[], false]
```suggestion [this.wines, this.isAdmin] = await allRequestedWines() || [[], false] ```
Adrianht (Migrated from github.com) reviewed 2020-09-07 14:23:49 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 14:23:49 +00:00

fixed

fixed
Adrianht (Migrated from github.com) reviewed 2020-09-07 14:23:52 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 14:23:52 +00:00

fixed

fixed
Adrianht (Migrated from github.com) reviewed 2020-09-07 14:23:56 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 14:23:56 +00:00

fixed

fixed
Adrianht (Migrated from github.com) reviewed 2020-09-07 14:24:02 +00:00
Adrianht (Migrated from github.com) commented 2020-09-07 14:24:02 +00:00

fixed

fixed
KevinMidboe (Migrated from github.com) approved these changes 2020-09-07 14:27:12 +00:00
Sign in to join this conversation.
No description provided.