Repository navigation
feat: restrict venue creation - #1212
Conversation
For the MVP each venue needs to be associated with a single chapter. For simplicity, this mirrors the event creation ui.
👇 Click on the image for a new way to code review
Legend |
It should be enough to use the chapterId query param and the venue's own id
There was a problem hiding this comment.
How much of the chapter - venue relation (venues are per chapter, one venue can be used only in one chapter), is expected in this PR? Venues are referencing single chapter, but the constrain isn't really enforced in any way.
Suggestions are for two unrelated, minor, things spotted.
Co-authored-by: Krzysztof G. <[email protected]>
I'm not entirely happy with how I've done this, so I'd welcome your thoughts. The idea is this: giving venues a foreign key referencing chapters enforces the requirement that each venue is associated with a single chapter. Making the [id, chapter_id] pair unique was a hack to make use of the One thing I was wondering is how else do think this should be enforced? Do we need further UI changes or did you have something else in mind? |
id is already unique and chapterId was only required so that the resolver 'needed' it, but this was an artificial need. Instead we can send the variable so that the authChecker can work and discard it once it reaches the resolver.
|
What I meant that it isn't enforced was that there were events in other chapters seeded with venues from chapter I thought about adding to the |
|
Got you. I was trying to do as little as possible in this PR, but thinking a little ahead would have been good... The approach you're suggesting sounds great; my hack stops being a hack if it's required by Prisma! How about this approach: revert the last commit, merge this (assuming you're otherwise happy) and then constrain the db to ensure that the event's venue is from the right chapter? |
This reverts commit 2051af4.

Update README.md).mainbranch of Chapter.Closes #1195
This is a little more extensive than most auth PRs, because of the reasons mentioned in the linked issue.
To ensure that the associated chapterId was available for the request, I put venue creation inside /dashboard/chapters/[chapterId]/ much like event creation. Similar story for editing events.
TODO:
Move event edit page inside /dashboard/chapters/[chapterId]/(necessary, but nothing to do with this)Make sure VenueForm gets passed(it's fine, thechapter_idonSubmitmethod is doing it)