When a public holiday is created, it is created in a specific user time zone.
https://github.com/discourse/discourse-calendar/blob/main/jobs/scheduled/create_holiday_events.rb#L71
When calendar is set as fullDay, we would like to display Christmas always 25th of December.
To achieve that, we need to have information about timezone, parse date in that timezone, and leave only year, month and day.
I added a test case to cover one bug scenario. User from Los Angeles have seen that user from Italy was celebrating Christmas Day on 24th of December instead of 25th.
Adds the option to enable a timezone adjustment for calendar events.
This will make it so events render offset from the grid to reflect the
appropriate start and end moments according to the viewer's timezone.
Return an empty array instead of nil when the plugin store has not yet
been populated with `users_on_holiday`.
At the moment, the `currently_away` report fails if the
`UpdateHolidayUsernames` never gets the chance to update `users_on_holiday`.
Before, the calendar plugin was setting this custom holiday flair in many places in Discourse. Starting from this PR, the calendar plugin will be setting user status in core instead.
Note that from now we start to show holiday's end date. If a user has several holiday events simultaneously (this can happen easily, for example, if a user is on vacation and today is a public holiday in their country), the date will be taken from the longest event.
Note also that there is an edge case that's not handled in this PR - if a user has several holidays one after another (let's say they are sick this week and has a vacation on the next week), it would be nice to show as the end date of the holiday the ending date of the second holiday. For now, the plugin uses the end date of the current holiday in such cases, but I'll improve it in one of the next PRs.
Also, in this PR, I directly use methods of the user model from Core. We definitely need API calls instead. This fix is also coming soon.
This was causing an error on topic lists after a zeitwerk reload. Using the official plugin API takes care of reloading correctly.
Followup to 139fdd9cc3
FEATURE:
- Added custom fields `sort_topics_by_event_start_date` and `disable_topic_resorting`
- Sort topics of event categories by event start date. Event categories have custom field `sort_topics_by_event_start_date` set to true.
- Disable re-sorting of categories with custom field `disable_topic_resorting`
- Event date displayed beside the Topic title can optionally be set to show the local date-time, instead of relative date-time.
-
Renamed the 'DestroyPastEvents' job to 'DeleteExpiredPostEvents' and changed its behavior
to only delete posts (and their replies) that have an expired event.
Previously it would also delete expired 'CalendarEvents' but that was messing with our automated
holidays tracking.
Used 'post.reply_ids' to retrieve all the replies to a post, and not only the direct replies.
This helps keep the topic cleaner by removing the whole reply chain.
* DEV: Add backend functionality to enable/disable holidays
This will add two backend endpoints, one to disable holidays and
another to enable holidays.
I also introduced a new `Holiday` service that is responsible for
getting the holidays and attaching a new `disabled` attribute to the
holidays. The `#index` action has been updated to use this new service,
so it will return this new `disabled` attribute.
* DEV: Only add enabled holidays to the calendar
I updated this job so that it will use the new `Holiday` service, which
will return the holidays like before but with a new `disabled` field,
which this job will use to only add enabled holidays to the calendar.
* FEATURE: Allow admins to disable/enable holidays
The main thing I added here is a new component `admin-holiday-list-item`
that is responsible for displaying a holiday, and an enable or disable
button and the corresponding functionality.
Adds two new endpoints available to admins:
* `/admin/discourse-calendar/holiday-regions` - this will return a list of holiday regions (as defined by the Holidays gem)
* `/admin/discourse-calendar/holiday-regions/:id/holidays` - this will return all of the holidays for a given region
The 'holidays-region' custom field used to be visible only to staff
members, but editable by the current user. This meant that the user
could edit the value, but could not see the value after it was set.
This caused the input field from their user preferences page to be
always blank for regular users.
Allow calendar to disrespect timezones and always display full day for standalone and group events.
Standalone events are saved in specific timezone: https://github.com/discourse/discourse-calendar/blob/main/app/models/calendar_event.rb#L62
However, we don't store information about timezone. It is essential to have that information to calculate date properly. Therefore, a new column was added.