Events stored in the database instead of YAML files - first draft - #487
Events stored in the database instead of YAML files - first draft#487kcomandich wants to merge 13 commits into
Conversation
| @@ -1,3 +1,4 @@ | |||
| @use "@37signals/lexxy/dist/stylesheets/lexxy.css"; | |||
There was a problem hiding this comment.
Copied this from the main site because we now need the lexxy styles for editing the description field in the Melbourne site, and the styles are not shared.
c8b6c90 to
0b8ef91
Compare
mcgain
left a comment
There was a problem hiding this comment.
Bunch of nit-picking sorry, but they are worth addressing
| end | ||
|
|
||
| def self.upcoming(amount = nil) | ||
| all.select(&:today_or_in_the_future?).slice(0..amount&.-(1)) |
There was a problem hiding this comment.
I think because we're using all here and not all_by_date that the returned event might not actually be the next one. I think all will just return in database insertion order, then today_or_in_the_future? will ensure it's upcoming, but not necessarily the next one by date.
In reality, it is likely that events will be added in the correct order, but if a newer event were to be added, then we'd end up displaying the wrong one.
I suspect this used to be fine, because the yaml events would be ordered by date, but that's not necessarily true of the db.
This is also true of past
There was a problem hiding this comment.
This isn't super important to fix in this PR. It'll be fine in the short term, can be fixed in a followup IMO
| all.reject(&:today_or_in_the_future?).reverse.slice(0..amount&.-(1)) | ||
| end | ||
|
|
||
| def self.last(amount = 1) |
There was a problem hiding this comment.
This overrides the ActiveRecord method last, which when given no argument, returns only a single object, rather than an array. Here, we're always returning an array and so break user expectations of the api.
Also, this is probably susceptible to the same issue as upcoming, so an all_by_date is probably necessary here and might allow you to avoid the reverse.
9c68ff4 to
1e2f75e
Compare
…n Melbourne::Events
Add 'Edit' and 'Delete' buttons to database_events/show Add 'Add New' button to database_events/index
…event_presenter The times used to be hardcoded into the view, now they are in the database so they need formatting
… user is meetup_admin
…being hardcoded in the presenter
1e2f75e to
2360201
Compare
Move events from a YAML file to the database, and provide a way to create/edit/delete events
There are a few remaining items to finish before it's ready to use, but I wanted to make sure I'm on the right track.
See discussion on #342. Implementation so far:
Note that UUIDs from the events.yml file don't appear to be used, LMK if they should be.
Still to do/fix:
Thanks to @mcgain for advising! 🙏 🎉
Screenshots:
Clone of the Melbourne event/show page, using events table, with Edit and Delete buttons:
New/Edit Event form:
Clone of the Melbourne events page, using events table, with New button:
Clone of the Melbourne home page, using events table: