Commit Graph

195 Commits

Author SHA1 Message Date
Sam bdf8869a01
FEATURE: Add event location/description and "My Events" filter (#746)
This pull request introduces two major new features to the calendar plugin: the ability to add a location/description to an event, and a new "My Events" view on the upcoming events page.

### Event Location

You can now add a `location` to an event. This is a free-text field that can be used for a physical address, a URL, or any other location details.

*   A `location` field has been added to the event builder modal.
*   The location is displayed in the event details in the post, complete with a new "location-pin" icon. URLs within the location field are automatically linked.
*   This is supported by a database migration to add the `location` column, and updates to the event model, serializer, and parser.

### Event description 

You can now add a `description ` to an event. This is a free-text field that can be used to describe your event.

*   A `description` field has been added to the event builder modal.
*   The description  is displayed in the event details in the post, complete with a new "circle-info" icon. URLs within the location field are automatically linked. It supports linebreaks.
*   This is supported by a database migration to add the `description` column, and updates to the event model, serializer, and parser.

### "My Events" Filter

The `/upcoming-events` page now includes tabs to switch between "All events" and "My events".

*   The "My events" tab shows all upcoming events that the current user is "Going" to.
*   This creates a personalized calendar for users to easily see their own upcoming schedule.
*   A new `/upcoming-events/mine` route has been added, and the backend event finder now supports filtering by an `attending_user`.


### Other Improvements

*   The calendar view on the `/upcoming-events` page now defaults to a "list" view on mobile for a better experience.
*   The "Open Event" and "Close Event" actions now have a disabled/saving state to provide better feedback during the operation.
*   System tests have been added to cover the new functionality.
2025-06-25 10:20:38 +02:00
Krzysztof Kotlarek 42d6ccf44d
FIX: allow create events for everyone group (#726)
When `discourse_post_event_allowed_on_groups` is set to `everyone`, everyone should be able to create post events.
2025-05-02 15:47:21 +08:00
Jarek Radosz fc3f4071ff
DEV: Update linting (#704) 2025-03-17 10:55:49 +00:00
David Taylor c8934ed60d
Revert "DEV: Update linting (#701)" (#702)
This reverts commit 2a97c179c4.

Causing problems with color-definitions compilation
2025-03-13 16:48:36 +00:00
Jarek Radosz 2a97c179c4
DEV: Update linting (#701) 2025-03-13 15:07:46 +00:00
Kelv a82cce2a65
DEV: Update deprecated Font Awesome icon names (#661) 2024-12-04 02:43:08 +01:00
Keegan George 81e1c8e3c4
SECURITY: Fix XSS in calendar event name (#607)
We need to sanitize event names to prevent XSS from occurring in events.
2024-09-12 10:22:05 -07:00
Régis Hanol f268eccaa0
PERF: removed N*2+1 in availability topic (#599)
WE "recently" did a few changes in the way we use the availability topic

- We used to have 1 topic per year, but have now moved to just using one topic and deleted past posts
- We used to delete past automatic holidays, but we don't anymore since we use them to keep track of #leave days used
- There are more employees covering more regions

All three changes made the query that list all the events to be displayed in the availability topic go 💥

It used to be

- 1 query to list all events from 6 months ago up to 6 months in the future
- 1 query for every events to load the associated user
- 1 query for every events to load the associated's user timezone

So basically, a N*2 + 1 😅

This commit fixes the issue by doing

- 1 query to get all "standalone" events (those associated to a post)
- 1 query to get all the users timezones (just the ones who have an holiday in the current period).
- 1 query to get all the "automatic" events (aka. holidays that are comming from the holidays gem).

So we went from N*2 + 1 down to 3 🚀
2024-08-14 18:11:24 +02:00
Loïc Guitaut 3dc9e8458a
DEV: Update rubocop-discourse to version 3.8.0 (#576) 2024-05-28 11:15:47 +02:00
Osama Sayegh 4d671540db
DEV: Remove RRule gem dependency because it's a core dependency now (#555)
The `rrule` gem is moved into core's Gemfile so we no longer need it here, see https://github.com/discourse/discourse/pull/26531.
2024-04-05 14:17:15 +03:00
Loïc Guitaut 665d35f914 DEV: Fix new Rubocop offenses 2024-03-05 16:54:54 +01:00
Natalie Tay 84ef46a38c
SECURITY: Hide invitees from users who are not allowed to see the event post (#544) 2024-02-22 11:32:47 +08:00
Ted Johansson ee6ad02d0b
DEV: Exclude system users when serializing group timezones (#533)
The post_serializer_spec was calling Group.refresh_automatic_groups!(:admins), relying on that call booting system users from the group.

This change makes it so the implementation excludes any system users instead.
2024-01-25 07:42:46 +08:00
Jarek Radosz 2201b254ff
DEV: Update linting (#503) 2024-01-15 11:24:00 +00:00
Vinoth Kannan 5e77d77239
FIX: include year in holiday identifier to differentiate yearly recurring events. (#523)
We must include the year identifier since now we can use same topic to track holidays for multiple years. Also, we don't need to load old public holiday events for more than 6 months.
2024-01-10 01:44:17 +05:30
Daniel Waterworth 0dc75a1ccb
Merge pull request from GHSA-65f2-9ghp-x8h8 2024-01-08 16:43:14 -05:00
Neil Lalonde a0af35fca8
Fix holidays not showing in group timezones (#512) 2023-12-22 13:59:46 -05:00
Juan David Martínez Cubillos ffe812b2a9
FIX: Event sorting shows oldest events first (#429)
* FIX: Event sorting shows oldest events first

---------

Co-authored-by: Jean Perez <jmperez127@gmail.com>
2023-12-14 11:31:37 -04:00
Jean d27e52e340
FEATURE: customizable event colors by tags and adjustable max rows in calendar (#482)
* FEATURE: customizable event colors by tags and adjustable max rows
2023-12-01 10:10:34 -04:00
Krzysztof Kotlarek 07ff8f4f1b
FEATURE: Show all upcoming events for the next year (#483)
Display upcoming recurrent events for a year.
In addition, download calendar is creating recurrent entries.
2023-11-30 13:56:05 +11:00
Krzysztof Kotlarek ce74ed4879
FIX: regional public holidays day early (#486)
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.
2023-11-22 14:44:42 +11:00
Isaac Janzen 21986cc399
DEV: Upgrade post-event-builder modal to Component API (#480) 2023-11-14 14:02:38 -07:00
Bianca Nenciu 7e9b77a750
DEV: Use new API to preload category custom fields (#475) 2023-11-09 18:51:56 +02:00
Martin Brennan f9f8e9d719
DEV: Metadata update for plugin.rb (#470)
* Update plugin.rb metadata

* Update plugin.rb

---------

Co-authored-by: AlexDev <104522507+alexdevlaeminck@users.noreply.github.com>
2023-11-07 17:29:23 -08:00
Bianca Nenciu 0d5a12cb40
FIX: Preload category custom fields (#472) 2023-11-02 16:56:32 +02:00
Renato Atilio f57b09ce8b
FEATURE: upcoming events list component (#463)
* FEATURE: upcoming events list component
2023-10-30 15:34:12 -03:00
David Taylor 9788310906
SECURITY: Properly escape user input when generating email HTML (#455) 2023-10-16 15:00:44 +01: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