Commit Graph

169 Commits

Author SHA1 Message Date
AlexDev b039cac72e
Update plugin.rb metadata 2023-10-11 13:42:26 -07:00
Jan Cernik 3fa341639b
FEATURE: Display calendar events adjusted for timezones (#432)
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.
2023-09-11 11:42:18 -03:00
Jarek Radosz 6761e2c84f
DEV: Clean up the plugin (#426) 2023-08-01 22:32:30 +02:00
David Taylor 8d1c24c76e
DEV: Resolve add_to_serializer deprecations (#403)
26b7f8a63b
2023-04-24 16:06:34 +01:00
Bianca Nenciu f45a1ee588
DEV: Update plugin to match latest guidelines (#396) 2023-03-22 20:48:04 +02:00
Bianca Nenciu 8f69c1165b
DEV: Update plugin to match latest guidelines (#390)
- Define extension modules
- Use different files instead of plugin.rb
- Make sure plugin is disabled according to the setting
2023-02-23 15:25:06 +02:00
Jan Cernik e932c9fb43
FIX: The event doesn't load after creating it (#375) 2023-01-13 16:03:10 -03:00
Selase Krakani 35a2d0b498
FIX: Make users_on_holiday return type consistent (#373)
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`.
2023-01-10 12:22:44 +00:00
David Taylor 3e9ab14bcd
DEV: Introduce syntax_tree for ruby formatting (#363) 2022-12-29 13:30:41 +01:00
Jan Cernik f4f16d958e
FEATURE: Add option to bump topic (#344)
It allows you to set an auto-bump topic timer based on the start date of an event
2022-12-01 09:14:07 -03:00
David Taylor 9045f0644a
DEV: Fix Zeitwerk reloading in development (#349)
These overrides are not using the DiscoursePluginRegistry, and therefore need to be re-applied after a Zeitwerk reload to prevent errors
2022-11-23 10:01:26 +00:00
Andrei Prigorshnev 7adaec219f
SECURITY: Bump the version (#346)
Due to the security fix ca5ae3e7e0
2022-11-14 20:31:50 +04:00
Andrei Prigorshnev e0efb16264
DEV: Drop hidden setting which was making holiday status public (#337) 2022-10-28 14:51:35 +04:00
Andrei Prigorshnev ccb4993e57
FEATURE: when user is on holiday set user status in core (#333)
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.
2022-10-24 16:57:53 +04:00
David Taylor d0908b9b2e
DEV: Ensure ends_at preloading persists in development (#327)
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
2022-09-28 11:17:33 +01:00
Frank 6820f7a433
Feature/sort by event start date (#320)
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.
 -
2022-09-23 06:02:48 +08:00
David Taylor 139fdd9cc3
DEV: Ensure topic_list custom field preloading persists in development (#324)
This was causing an error on topic lists after a zeitwerk reload. Using the official plugin API takes care of reloading correctly.
2022-09-22 10:27:48 +01:00
David Taylor 799c3515ce
FEATURE: Allow post events to be edited based on post guardian (#303)
If someone has edit access on a post (e.g. they're TL4), then it makes sense for them to be able to edit the attached event
2022-07-25 14:57:53 +01:00
Régis Hanol 23dd3830bd
FIX: delete event posts not automatic holidays (#292)
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.
2022-07-01 11:02:19 +02:00
Shaun d31e07c01c
Allow admins to enable and disable holidays (#283)
* 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.
2022-06-28 19:43:20 -03:00
David Taylor 67b81b3d69
DEV: Add hidden setting which makes holiday status public (#288)
This is a temporary addition, pending a more radical refactoring of the holiday-emoji-flair system.
2022-06-17 18:26:42 +01:00
Shaun 910ce2dde6
FEATURE: Allow admins to view holidays by region (#275) 2022-06-03 13:26:14 -04:00
Shaun 0e154a62a0
DEV: Add API endpoints for holidays (#269)
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
2022-05-17 10:26:19 -04:00
Bianca Nenciu c2fd735037
FIX: Make region visible to current user too (#267)
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.
2022-05-16 16:05:24 +03:00
Joffrey JAFFEUX 7d10944055
FEATURE: adds support for timezone (recurring and non recurring) (#237) 2022-03-03 12:03:21 +01:00
Loïc Guitaut c3a09e2ec5 DEV: Update the rrule gem (Rails 7+ compatibility) 2022-03-02 10:42:58 +01:00
Joffrey JAFFEUX 20d012516c
FEATURE: adds a currently away report (#234) 2022-02-25 15:46:45 +01:00
Jarek Radosz ad1fc42773
DEV: Drop old code (#230)
Resolving some post-release TODOs
2022-02-24 01:15:49 +01:00
Jarek Radosz aeb12bf7de
DEV: Update rrule gem (#229) 2022-02-24 01:14:23 +01:00
Jarek Radosz d93343e997
DEV: Remove old ics code (#231) 2022-02-23 23:38:38 +01:00
Jarek Radosz b7e0441e77
DEV: Enable js transpilation (#222) 2022-02-10 22:23:38 +01:00
Krzysztof Kotlarek e852072f30
FEATURE: fullDay calendar option (#207)
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.
2022-01-06 09:51:11 +01:00
Roman Rizzi 365a90912e
DEV: Use Procs instead of lambdas for the consolidation rule. (#202)
Using procs lets us pass additional arguments to the function without breaking existing ones.
2021-12-22 15:23:02 -03:00
Joffrey JAFFEUX 0b423413e4
DEV: adds support for event url in event_started trigger (#194) 2021-12-14 09:19:55 +01:00
Roman Rizzi 13549ac176
FEATURE: Re-use existing invite and reminders notifications. (#191)
Instead of creating new notifications for recurring events, we use our consolidation API to bump existing ones.
2021-12-10 11:28:43 -03:00
Joffrey JAFFEUX c9644eb476
DEV: adds event started triggerable for automation (#193) 2021-12-07 20:39:31 +01:00
Joffrey JAFFEUX 28e156d55d
DEV: whiteList is deprecated (#186) 2021-10-27 15:11:05 +02:00
Krzysztof Kotlarek 5c9e7b3044
FIX: small region preferences select (#176)
Reduce size of user region preferences
2021-10-06 10:13:05 +11:00
Alan Guo Xiang Tan 14a7649840 Fix plugin's compatibility with older discourse versions.
Follow-up to d469260bf9
2021-06-17 09:13:22 +08:00
Alan Guo Xiang Tan 10456a93a2
FIX: Holidays gem not required in Sidekiq. 2021-06-09 10:49:09 +08:00
Alan Guo Xiang Tan d469260bf9 PERF: N+1 queries while loading `Post#event` in a topic. 2021-06-07 15:20:08 +08:00
Alan Guo Xiang Tan 0e3431f111 Hard fork holidays/holidays gem into plugin.
The original gem does not seem to be maintained anymore so we're pulling
this into the plugin so that we can update the definitions easily.
2021-06-07 10:54:52 +08:00
Sam aa7086b14c
DEV: update holiday definitions (#130) 2021-05-05 12:17:00 +10:00
Vinoth Kannan 3b1f1ea5ed
FIX: retrieve custom fields from preloaded data to stop N+1 issue. (#128)
All the preloaded custom fields are stored in `TopicView`'s post_custom_fields property. To prevent N+1 we should use that instead of `post.custom_fields` method.
2021-05-03 09:06:25 +02:00
Dan Ungureanu 776e3d1b9d
FIX: Show holiday name only once (#120) 2021-04-23 19:16:29 +03:00
Dan Ungureanu 4d9d30fe18
FIX: Handle multiple holidays in the same day (#118)
If a user had two holidays in the same day, the calendar would show
only of them, but the username would be shown twice. This ensures the
calendar shows both holidays and the username only once.
2021-04-14 11:42:21 +03:00
Gerhard Schlager 11397e2910
DEV: Fix flaky spec (#103) 2021-02-09 18:24:26 +01:00
Krzysztof Kotlarek 21d536de5d
FIX: randomly failing export CSV spec (#81)
The test is failing because of an incorrect order. I added an order by `created_by`.

Also, I needed to split create_invitess because it is using the same date for `created_at`

```ruby
def create_invitees(attrs)
  timestamp = Time.now
  attrs.map! do |attr|
    {
      post_id: self.id, created_at: timestamp, updated_at: timestamp
    }.merge(attr)
  end

  self.invitees.insert_all!(attrs)
end
```
2020-12-14 10:52:03 +11:00
Régis Hanol 94600a8508 FIX: properly handle holidays in the same week
UX: sort usernames in grouped holidays
2020-11-27 18:06:40 +01:00
Krzysztof Kotlarek 9f69f273ad
FIX: move post events into separate tables (#70)
* FIX: correctly destroys standalone calendar events (#66)

Standalone events are mostly created for holidays where we create a calendar event not associated to any post of of the topic, before this change, the loop was exited before collecting the ID of the calendar event to be destroyed.
2020-11-25 09:32:51 +11:00