A platform for community discussion. Free, open, simple.
FEATURE: Refinements for recurring events RSVP and bulk invites (#43936)
Martin Brennanea9e58f6536b
diff --git a/plugins/discourse-events/app/controllers/discourse_events/invitees_controller.rb b/plugins/discourse-events/app/controllers/discourse_events/invitees_controller.rbindex 516c7c9daf8..e5d33ea49dd 100644--- a/plugins/discourse-events/app/controllers/discourse_events/invitees_controller.rb+++ b/plugins/discourse-events/app/controllers/discourse_events/invitees_controller.rb@@ -10,6 +10,8 @@ module DiscourseEventspost_id: params[:post_id],filter: params[:filter],type: params[:type],+ occurrence_starts_at: params[:occurrence_starts_at],+ recurrence_scope: params[:recurrence_scope] || "this_event",},guardian:,) dodiff --git a/plugins/discourse-events/app/jobs/regular/discourse_post_event_bulk_invite.rb b/plugins/discourse-events/app/jobs/regular/discourse_post_event_bulk_invite.rbindex 803b626aed0..1e0b4714c0f 100644--- a/plugins/discourse-events/app/jobs/regular/discourse_post_event_bulk_invite.rb+++ b/plugins/discourse-events/app/jobs/regular/discourse_post_event_bulk_invite.rb@@ -22,6 +22,8 @@ module Jobs@event = DiscourseEvents::Events::Event.find_by(id: args[:event_id])raise Discourse::InvalidParameters.new(:event_id) unless @event+ @recurring = ActiveModel::Type::Boolean.new.cast(args[:recurring]) || false+@guardian = Guardian.new(@current_user)@guardian.ensure_can_edit!(@event.post)@@ -71,11 +73,11 @@ module Jobsreturnend- attendance = invitee["attendance"] || "going"- status = DiscourseEvents::Events::Invitee.statuses[attendance.to_sym]+ attendance_status_name = invitee["attendance"] || "going"+ status = DiscourseEvents::Events::Invitee.statuses[attendance_status_name.to_sym]if status.nil?- save_log "Skipping '#{invitee["identifier"]}' due to unknown attendance: '#{attendance}'"+ save_log "Skipping '#{invitee["identifier"]}' due to unknown attendance: '#{attendance_status_name}'"@failed += 1returnend@@ -83,14 +85,16 @@ module Jobspost_id = @event.post.idusers.each do |user_id|- # Respect capacity: skip creating new going when full- if attendance == "going" && @event.at_capacity?+ event_invitee =+ DiscourseEvents::Events::Invitee.find_or_initialize_by(user_id: user_id, post_id: post_id)++ if attendance_status_name == "going" && @event.at_capacity? && !event_invitee.going?save_log "Skipping '#{invitee["identifier"]}' due to max attendees reached"@failed += 1nextend- create_attendance(user_id, post_id, status)+ create_attendance(event_invitee, status)end@processed += 1@@ -99,11 +103,10 @@ module Jobs@failed += 1end- def create_attendance(user_id, post_id, status)- invitee =- DiscourseEvents::Events::Invitee.find_or_initialize_by(user_id: user_id, post_id: post_id)+ def create_attendance(invitee, status)invitee.notified = falseinvitee.status = status+ invitee.recurring = @recurring && invitee.going?invitee.save!enddiff --git a/plugins/discourse-events/app/services/discourse_events/events/bulk_invite.rb b/plugins/discourse-events/app/services/discourse_events/events/bulk_invite.rbindex 47c8565d0a1..8192fb3da4b 100644--- a/plugins/discourse-events/app/services/discourse_events/events/bulk_invite.rb+++ b/plugins/discourse-events/app/services/discourse_events/events/bulk_invite.rb@@ -8,6 +8,7 @@ module DiscourseEventsparams doattribute :event_id, :integerattribute :invitees, :array+ attribute :recurring, :boolean, default: falsebefore_validation domax_invitees = SiteSetting.discourse_post_event_max_bulk_invitees@@ -47,6 +48,7 @@ module DiscourseEvents:discourse_post_event_bulk_invite,event_id: event.id,invitees: params.invitees,+ recurring: params.recurring,current_user_id: guardian.user.id,)enddiff --git a/plugins/discourse-events/app/services/discourse_events/events/csv_bulk_invite.rb b/plugins/discourse-events/app/services/discourse_events/events/csv_bulk_invite.rbindex 764d752cbb6..ca1b056a137 100644--- a/plugins/discourse-events/app/services/discourse_events/events/csv_bulk_invite.rb+++ b/plugins/discourse-events/app/services/discourse_events/events/csv_bulk_invite.rb@@ -7,6 +7,7 @@ module DiscourseEventsparams doattribute :event_id, :integer+ attribute :recurring, :boolean, default: false# Declared only so the steps can read it; the contract drops any# undeclared parameter.attribute :file@@ -44,11 +45,12 @@ module DiscourseEventsAction::ParseInviteesCsv.call(file: params.file)end- def enqueue_bulk_invite(event:, invitees:, guardian:)+ def enqueue_bulk_invite(event:, invitees:, guardian:, params:)Jobs.enqueue(:discourse_post_event_bulk_invite,event_id: event.id,invitees: invitees,+ recurring: params.recurring,current_user_id: guardian.user.id,)enddiff --git a/plugins/discourse-events/app/services/discourse_events/events/list_invitees.rb b/plugins/discourse-events/app/services/discourse_events/events/list_invitees.rbindex 8092f4be703..3f8d6230588 100644--- a/plugins/discourse-events/app/services/discourse_events/events/list_invitees.rb+++ b/plugins/discourse-events/app/services/discourse_events/events/list_invitees.rb@@ -6,13 +6,17 @@ module DiscourseEventsinclude Service::BaseMAX_INVITEES = 200+ RECURRENCE_SCOPES = %w[this_event first_event_only this_and_following].freezeparams doattribute :post_id, :integerattribute :filter, :string+ attribute :occurrence_starts_at, :datetime+ attribute :recurrence_scope, :string, default: "this_event"attribute :type, :symbolvalidates :post_id, presence: true+ validates :recurrence_scope, inclusion: { in: RECURRENCE_SCOPES }validates :type, inclusion: { in: Invitee.statuses.keys }, allow_blank: trueend@@ -34,6 +38,23 @@ module DiscourseEventsdef fetch_invitees(event:, params:)invitees = event.inviteesinvitees = invitees.with_status(params.type) if params.type.present?+ if event.recurring? && params.type == :going+ invitees =+ case params.recurrence_scope+ when "first_event_only"+ invitees.where(recurring: false)+ when "this_and_following"+ invitees.where(recurring: true)+ else+ occurrence_starts_at = params.occurrence_starts_at+ if occurrence_starts_at && event.starts_at&.to_i != occurrence_starts_at.to_i+ invitees.where(recurring: true)+ else+ invitees+ end+ end+ end+invitees = invitees.matching_username(params.filter) if params.filter.present?invitees.order(%i[status username_lower]).limit(MAX_INVITEES)enddiff --git a/plugins/discourse-events/assets/javascripts/discourse/components/csv-uploader.gjs b/plugins/discourse-events/assets/javascripts/discourse/components/csv-uploader.gjsindex 322305e7add..b9a6ccb2f8e 100644--- a/plugins/discourse-events/assets/javascripts/discourse/components/csv-uploader.gjs+++ b/plugins/discourse-events/assets/javascripts/discourse/components/csv-uploader.gjs@@ -16,6 +16,13 @@ export default class CsvUploader extends Component {autoStartUploads: false,uploadUrl: this.args.uploadUrl,preventDirectS3Uploads: true,+ perFileData: () => {+ if (typeof this.args.additionalParams === "function") {+ return this.args.additionalParams() || {};+ }++ return this.args.additionalParams || {};+ },uppyReady: () => {this.uppyUpload.uppyWrapper.uppyInstance.on("file-added", () => {this.dialog.confirm({diff --git a/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/index.gjs b/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/index.gjsindex 17818e2bdc8..3aae74a595b 100644--- a/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/index.gjs+++ b/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/index.gjs@@ -101,6 +101,9 @@ export default class DiscoursePostEvent extends Component {this.messageBus.subscribe(path, async (msg) => {const eventData = await this.discoursePostEventApi.event(msg.id);this.event.updateFromEvent(eventData);+ if (this.event.isFutureOccurrence) {+ this.event.filterForFutureOccurrence();+ }});return () => this.messageBus.unsubscribe(path);@@ -233,7 +236,7 @@ export default class DiscoursePostEvent extends Component {displayedStartsAt &&displayedStartsAt !== fetched.startsAt) {- this.#filterForFutureOccurrence(fetched);+ fetched.filterForFutureOccurrence();}fetched.startsAt = displayedStartsAt;@@ -246,26 +249,6 @@ export default class DiscoursePostEvent extends Component {}}- #filterForFutureOccurrence(event) {- event.sampleInvitees = event.sampleInvitees.filter(- (invitee) => invitee.status !== "going" || invitee.recurring- );-- const recurringCount = event.stats?.goingRecurring ?? 0;- if (event.stats) {- event.stats.going = recurringCount;- }- event.atCapacity =- event.maxAttendees != null && recurringCount >= event.maxAttendees;-- if (- event.watchingInvitee?.status === "going" &&- !event.watchingInvitee?.recurring- ) {- event.watchingInvitee = null;- }- }-<template>{{#let this.event as |event|}}<div class="discourse-post-event" ...attributes>diff --git a/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/invitees.gjs b/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/invitees.gjsindex 6f4ac2eb5e2..12fa9155ba6 100644--- a/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/invitees.gjs+++ b/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/invitees.gjs@@ -29,6 +29,7 @@ export default class DiscoursePostEventInvitees extends Component {this.modal.show(PostEventInvitees, {model: {event: this.args.event,+ isRecurring: Boolean(this.args.event.recurrence),title: this.args.event.title,extraClass: this.args.event.extraClass,},diff --git a/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/more-menu.gjs b/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/more-menu.gjsindex 31af35b80b5..687d395b6d7 100644--- a/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/more-menu.gjs+++ b/plugins/discourse-events/assets/javascripts/discourse/components/discourse-post-event/more-menu.gjs@@ -127,7 +127,10 @@ export default class DiscoursePostEventMoreMenu extends Component {this.menuApi.close();this.modal.show(PostEventBulkInvite, {- model: { event: this.args.event },+ model: {+ event: this.args.event,+ isRecurring: Boolean(this.args.event.recurrence),+ },});}@@ -227,6 +230,7 @@ export default class DiscoursePostEventMoreMenu extends Component {this.modal.show(PostEventInvitees, {model: {event: this.args.event,+ isRecurring: Boolean(this.args.event.recurrence),title: this.args.event.title,extraClass: this.args.event.extraClass,},diff --git a/plugins/discourse-events/assets/javascripts/discourse/components/modal/post-event-bulk-invite.gjs b/plugins/discourse-events/assets/javascripts/discourse/components/modal/post-event-bulk-invite.gjsindex 0440482a5d3..3d569289868 100644--- a/plugins/discourse-events/assets/javascripts/discourse/components/modal/post-event-bulk-invite.gjs+++ b/plugins/discourse-events/assets/javascripts/discourse/components/modal/post-event-bulk-invite.gjs@@ -24,7 +24,10 @@ export default class PostEventBulkInvite extends Component {formApi;- data = { invitees: [{ identifier: null, attendance: DEFAULT_ATTENDANCE }] };+ data = {+ invitees: [{ identifier: null, attendance: DEFAULT_ATTENDANCE }],+ recurring: false,+ };get bulkInviteStatuses() {return [@@ -53,6 +56,11 @@ export default class PostEventBulkInvite extends Component {this.formApi = api;}+ @action+ csvAdditionalParams() {+ return { recurring: this.formApi?.get("recurring") ?? false };+ }+@actionaddInvite(addItemToCollection) {const invitees = this.formApi?.get("invitees") ?? [];@@ -92,7 +100,10 @@ export default class PostEventBulkInvite extends Component {type: "POST",dataType: "json",contentType: "application/json",- data: JSON.stringify({ invitees: data.invitees }),+ data: JSON.stringify({+ invitees: data.invitees,+ recurring: data.recurring,+ }),});@@ -121,7 +132,13 @@ export default class PostEventBulkInvite extends Component {@title={{i18n "discourse_post_event.bulk_invite_modal.title"}}><:body>- <div class="bulk-invites">+ <Form+ class="bulk-invites-form"+ @data={{this.data}}+ @onRegisterApi={{this.registerApi}}+ @onSubmit={{this.sendBulkInvites}}+ as |form|+ ><p class="bulk-event-help">{{i18n(concat@@ -130,17 +147,12 @@ export default class PostEventBulkInvite extends Component {)}}</p>- <h3>{{i18n- "discourse_post_event.bulk_invite_modal.inline_title"- }}</h3>-- <Form- class="bulk-invites-form"- @data={{this.data}}- @onRegisterApi={{this.registerApi}}- @onSubmit={{this.sendBulkInvites}}- as |form|- >++ <div class="bulk-invites">+ <h3>{{i18n+ "discourse_post_event.bulk_invite_modal.inline_title"+ }}</h3>+<form.Collection @name="invitees" as |collection index|><div class="bulk-invite-row"><collection.Field@@ -224,31 +236,46 @@ export default class PostEventBulkInvite extends Component {@icon="plus"@label="discourse_post_event.bulk_invite_modal.add_attendee"/>+ {{#if @model.isRecurring}}+ <form.Field+ class="bulk-invite-recurrence"+ @format="full"+ @name="recurring"+ @title={{i18n+ "discourse_post_event.bulk_invite_modal.recurring"+ }}+ @type="checkbox"+ as |field|+ >+ <field.Control />+ </form.Field>+ {{/if}}<form.Submitclass="send-bulk-invites"@label="discourse_post_event.bulk_invite_modal.send_bulk_invites"/></form.Actions>- </Form>- </div>-- <div class="csv-bulk-invites">- <h3>{{i18n "discourse_post_event.bulk_invite_modal.csv_title"}}</h3>-- <div class="bulk-invite-actions">- <BulkInviteSampleCsvFile />-- <CsvUploader- @i18nPrefix="discourse_post_event.bulk_invite_modal"- @uploadDone={{this.uploadDone}}- @uploadUrl={{concat- "/discourse-post-event/events/"- @model.event.id- "/csv-bulk-invite"- }}- /></div>- </div>++ <div class="csv-bulk-invites">+ <h3>{{i18n "discourse_post_event.bulk_invite_modal.csv_title"}}</h3>++ <div class="bulk-invite-actions">+ <BulkInviteSampleCsvFile />++ <CsvUploader+ @additionalParams={{this.csvAdditionalParams}}+ @i18nPrefix="discourse_post_event.bulk_invite_modal"+ @uploadDone={{this.uploadDone}}+ @uploadUrl={{concat+ "/discourse-post-event/events/"+ @model.event.id+ "/csv-bulk-invite"+ }}+ />+ </div>+ </div>+ </Form></:body></DModal></template>diff --git a/plugins/discourse-events/assets/javascripts/discourse/components/modal/post-event-invitees/index.gjs b/plugins/discourse-events/assets/javascripts/discourse/components/modal/post-event-invitees/index.gjsindex 9705997e1c8..df5563babcd 100644--- a/plugins/discourse-events/assets/javascripts/discourse/components/modal/post-event-invitees/index.gjs+++ b/plugins/discourse-events/assets/javascripts/discourse/components/modal/post-event-invitees/index.gjs@@ -5,7 +5,7 @@ import { on } from "@ember/modifier";import { action } from "@ember/object";import { service } from "@ember/service";import { debounce } from "discourse/lib/decorators";-import { or } from "discourse/truth-helpers";+import { eq, or } from "discourse/truth-helpers";import DButton from "discourse/ui-kit/d-button";import DConditionalLoadingSpinner from "discourse/ui-kit/d-conditional-loading-spinner";import DModal from "discourse/ui-kit/d-modal";@@ -14,11 +14,44 @@ import { i18n } from "discourse-i18n";import ToggleInvitees from "../../toggle-invitees.gjs";import User from "./user.gjs";+const RecurrenceScopeFilter = <template>+ <ul class="nav nav-pills invitees-recurrence-filter">+ <li>+ <button+ class={{if (eq @scope "this_event") "active"}}+ type="button"+ {{on "click" (fn @toggle "this_event")}}+ >+ {{i18n "discourse_post_event.invitees_modal.this_event"}}+ </button>+ </li>+ <li>+ <button+ class={{if (eq @scope "first_event_only") "active"}}+ type="button"+ {{on "click" (fn @toggle "first_event_only")}}+ >+ {{i18n "discourse_post_event.invitees_modal.first_event_only"}}+ </button>+ </li>+ <li>+ <button+ class={{if (eq @scope "this_and_following") "active"}}+ type="button"+ {{on "click" (fn @toggle "this_and_following")}}+ >+ {{i18n "discourse_post_event.models.invitee.this_and_following"}}+ </button>+ </li>+ </ul>+</template>;+export default class PostEventInviteesModal extends Component {@service discoursePostEventApi;@tracked filter;@tracked isLoading = false;+ @tracked recurrenceScope = "this_event";@tracked type = "going";@tracked inviteesList;@@ -43,12 +76,34 @@ export default class PostEventInviteesModal extends Component {);}+ get recurringForNewInvitee() {+ if (!this.args.model.isRecurring || this.type !== "going") {+ return false;+ }++ return (+ this.recurrenceScope === "this_and_following" ||+ (this.recurrenceScope === "this_event" &&+ this.args.model.event.isFutureOccurrence)+ );+ }++ get showRecurrenceScopes() {+ return this.args.model.isRecurring && this.type === "going";+ }+@actiontoggleType(type) {this.type = type;this.fetchInvitees(this.filter);}+ @action+ toggleRecurrenceScope(scope) {+ this.recurrenceScope = scope;+ this.fetchInvitees(this.filter);+ }+@debounce(250)onFilterChanged(event) {this.filter = event.target.value;@@ -68,6 +123,7 @@ export default class PostEventInviteesModal extends Component {this.args.model.event,{status: this.type,+ recurring: this.recurringForNewInvitee,user_id: user.id,});@@ -81,7 +137,11 @@ export default class PostEventInviteesModal extends Component {this.inviteesList = await this.discoursePostEventApi.listEventInvitees(this.args.model.event,- { type: this.type, filter }+ {+ type: this.type,+ filter,+ recurrence_scope: this.recurrenceScope,+ });} finally {this.isLoading = false;@@ -108,6 +168,12 @@ export default class PostEventInviteesModal extends Component {/><ToggleInvitees @toggle={{this.toggleType}} @viewType={{this.type}} />+ {{#if this.showRecurrenceScopes}}+ <RecurrenceScopeFilter+ @scope={{this.recurrenceScope}}+ @toggle={{this.toggleRecurrenceScope}}+ />+ {{/if}}<DConditionalLoadingSpinner @condition={{this.isLoading}}>{{#if this.hasResults}}<ul class="invitees">diff --git a/plugins/discourse-events/assets/javascripts/discourse/models/discourse-post-event-event.js b/plugins/discourse-events/assets/javascripts/discourse/models/discourse-post-event-event.jsindex 6d45f54d9cc..8db86dce85f 100644--- a/plugins/discourse-events/assets/javascripts/discourse/models/discourse-post-event-event.js+++ b/plugins/discourse-events/assets/javascripts/discourse/models/discourse-post-event-event.js@@ -106,6 +106,7 @@ export default class DiscoursePostEventEvent {@tracked customFields;@tracked channel;@tracked imageUpload;+ @tracked isFutureOccurrence = false;@tracked _watchingInvitee;@tracked _sampleInvitees;@@ -234,6 +235,27 @@ export default class DiscoursePostEventEvent {return isPastEventTimeframe(this.allDay, this.startsAt, this.endsAt);}+ filterForFutureOccurrence() {+ this.isFutureOccurrence = true;+ this.sampleInvitees = this.sampleInvitees.filter(+ (invitee) => invitee.status !== "going" || invitee.recurring+ );++ const recurringCount = this.stats?.goingRecurring ?? 0;+ if (this.stats) {+ this.stats.going = recurringCount;+ }+ this.atCapacity =+ this.maxAttendees != null && recurringCount >= this.maxAttendees;++ if (+ this.watchingInvitee?.status === "going" &&+ !this.watchingInvitee?.recurring+ ) {+ this.watchingInvitee = null;+ }+ }+updateFromEvent(event) {this.name = event.name;this.startsAt = event.startsAt;diff --git a/plugins/discourse-events/assets/javascripts/discourse/services/discourse-post-event-api.js b/plugins/discourse-events/assets/javascripts/discourse/services/discourse-post-event-api.jsindex 5affafb0347..e5e0884a3a3 100644--- a/plugins/discourse-events/assets/javascripts/discourse/services/discourse-post-event-api.js+++ b/plugins/discourse-events/assets/javascripts/discourse/services/discourse-post-event-api.js@@ -1,4 +1,5 @@import Service from "@ember/service";+import moment from "moment";import { ajax } from "discourse/lib/ajax";import DiscoursePostEventEvent from "discourse/plugins/discourse-events/discourse/models/discourse-post-event-event";import DiscoursePostEventInvitee from "discourse/plugins/discourse-events/discourse/models/discourse-post-event-invitee";@@ -73,7 +74,10 @@ export default class DiscoursePostEventApi extends Service {}async listEventInvitees(event, data = {}) {- const result = await this.#getRequest(`/events/${event.id}/invitees`, data);+ const result = await this.#getRequest(`/events/${event.id}/invitees`, {+ ...data,+ occurrence_starts_at: this.#normalizedOccurrenceStartsAt(event),+ });return DiscoursePostEventInvitees.create(result);}@@ -108,6 +112,10 @@ export default class DiscoursePostEventApi extends Service {event.shouldDisplayInvitees =result.invitee.meta.event_should_display_invitees;+ if (event.isFutureOccurrence) {+ event.filterForFutureOccurrence();+ }+const capacity = Number(event.maxAttendees);if (!Number.isNaN(capacity) && capacity > 0) {event.atCapacity = Number(event.stats.going) >= capacity;@@ -127,7 +135,11 @@ export default class DiscoursePostEventApi extends Service {event.watchingInvitee = null;}- if (invitee?.status === "going" && Number(event.stats?.going) > 0) {+ if (+ invitee?.status === "going" &&+ (!event.isFutureOccurrence || invitee.recurring) &&+ Number(event.stats?.going) > 0+ ) {event.stats.going = Number(event.stats.going) - 1;}@@ -157,6 +169,10 @@ export default class DiscoursePostEventApi extends Service {event.shouldDisplayInvitees =result.invitee.meta.event_should_display_invitees;+ if (event.isFutureOccurrence) {+ event.filterForFutureOccurrence();+ }+const capacity = Number(event.maxAttendees);if (!Number.isNaN(capacity) && capacity > 0) {event.atCapacity = Number(event.stats.going) >= capacity;@@ -165,6 +181,23 @@ export default class DiscoursePostEventApi extends Service {return invitee;}+ #normalizedOccurrenceStartsAt(event) {+ if (!event.startsAt) {+ return null;+ }++ let startsAt;+ if (event.allDay) {+ startsAt = moment.utc(event.startsAt, "YYYY-MM-DD", true);+ } else if (event.showLocalTime) {+ startsAt = moment.tz(event.startsAt, event.timezone || "UTC");+ } else {+ startsAt = moment.parseZone(event.startsAt);+ }++ return startsAt.isValid() ? startsAt.utc().toISOString() : null;+ }+#getRequest(endpoint, data = {}) {return ajax(`${this.#basePath}${endpoint}`, {type: "GET",diff --git a/plugins/discourse-events/assets/stylesheets/common/discourse-post-event-bulk-invite-modal.scss b/plugins/discourse-events/assets/stylesheets/common/discourse-post-event-bulk-invite-modal.scssindex ce145bbeb93..5259b1c6498 100644--- a/plugins/discourse-events/assets/stylesheets/common/discourse-post-event-bulk-invite-modal.scss+++ b/plugins/discourse-events/assets/stylesheets/common/discourse-post-event-bulk-invite-modal.scss@@ -37,6 +37,7 @@.bulk-invites {margin-bottom: 2em;+ width: 100%;.send-bulk-invites {margin-right: auto;diff --git a/plugins/discourse-events/assets/stylesheets/common/discourse-post-event-invitees.scss b/plugins/discourse-events/assets/stylesheets/common/discourse-post-event-invitees.scssindex 35f212187fd..3761c628df6 100644--- a/plugins/discourse-events/assets/stylesheets/common/discourse-post-event-invitees.scss+++ b/plugins/discourse-events/assets/stylesheets/common/discourse-post-event-invitees.scss@@ -14,6 +14,12 @@margin: 0 0 -1px 0;}+ .invitees-recurrence-filter {+ display: flex;+ flex-wrap: wrap;+ margin: var(--space-2) 0 0;+ }+.filter {width: calc(100% - 2em);margin-bottom: 1em;diff --git a/plugins/discourse-events/config/locales/client.en.yml b/plugins/discourse-events/config/locales/client.en.ymlindex e11f85a38da..8a1dacd8339 100644--- a/plugins/discourse-events/config/locales/client.en.yml+++ b/plugins/discourse-events/config/locales/client.en.yml@@ -412,11 +412,13 @@ en:open_event: "Open event"destroy_event: "Destroy event"invitees_modal:- title_invited: "Event Participation"+ title_invited: "Event participation"title_participated: "List of users who participated"filter_placeholder: "Filter users"remove_invitee: "Remove invitee from list"add_invitee: "Add invitee to list"+ this_event: "This event"+ first_event_only: "First event only"bulk_invite_modal:confirm: "confirm"text: "Upload CSV file"@@ -432,6 +434,7 @@ en:group_selector_placeholder: "Choose a group..."user_selector_placeholder: "Choose user..."attendance_label: "Attendance"+ recurring: "Apply attendance to this event and all following events"inline_title: "Inline bulk invite"csv_title: "CSV bulk invite"upcoming_events:diff --git a/plugins/discourse-events/spec/jobs/regular/discourse_post_event/bulk_invite_spec.rb b/plugins/discourse-events/spec/jobs/regular/discourse_post_event/bulk_invite_spec.rbindex bf222d62550..78e887fc27c 100644--- a/plugins/discourse-events/spec/jobs/regular/discourse_post_event/bulk_invite_spec.rb+++ b/plugins/discourse-events/spec/jobs/regular/discourse_post_event/bulk_invite_spec.rb@@ -226,6 +226,38 @@ describe Jobs::DiscoursePostEventBulkInvite doinvitee_klass.statuses[:interested],)end++ it "updates recurrence scope when a going attendee is bulk invited again at capacity" do+ post_event_1.update!(max_attendees: 1)+ invitee_klass = DiscourseEvents::Events::Invitee+ invitee_klass.create_attendance!(invitee_4.id, post_event_1.id, :going)++ job_args = {+ event_id: post_event_1.id,+ invitees: [{ "identifier" => invitee_4.username, "attendance" => "going" }],+ recurring: true,+ current_user_id: user_1.id,+ }++ Jobs::DiscoursePostEventBulkInvite.new.execute(job_args)+ expect(invitee_klass.find_by(user_id: invitee_4.id)).to be_recurring++ Jobs::DiscoursePostEventBulkInvite.new.execute(job_args.merge(recurring: false))+ expect(invitee_klass.find_by(user_id: invitee_4.id)).not_to be_recurring+ end++ it "does not mark non-going attendees as recurring" do+ Jobs::DiscoursePostEventBulkInvite.new.execute(+ event_id: post_event_1.id,+ invitees: [{ "identifier" => invitee_3.username, "attendance" => "interested" }],+ recurring: true,+ current_user_id: user_1.id,+ )++ expect(+ DiscourseEvents::Events::Invitee.find_by(user_id: invitee_3.id),+ ).not_to be_recurring+ endendendenddiff --git a/plugins/discourse-events/spec/requests/events_controller_spec.rb b/plugins/discourse-events/spec/requests/events_controller_spec.rbindex 5fb11a013ce..aeec0212468 100644--- a/plugins/discourse-events/spec/requests/events_controller_spec.rb+++ b/plugins/discourse-events/spec/requests/events_controller_spec.rb@@ -640,12 +640,14 @@ module DiscourseEvents::Events{ "identifier" => "sam", "attendance" => "interested" },{ "identifier" => "the_foo_bar_group", "attendance" => "not_going" },],+ "recurring" => true,"current_user_id" => user.id,},) dopost "/discourse-post-event/events/#{event_1.id}/csv-bulk-invite.json",params: {file: fixture_file_upload(valid_file),+ recurring: true,}end@@ -698,6 +700,7 @@ module DiscourseEvents::Events{ "identifier" => "sam", "attendance" => "interested" },{ "identifier" => "the_foo_bar_group", "attendance" => "not_going" },],+ "recurring" => true,"current_user_id" => user.id,},) do@@ -708,6 +711,7 @@ module DiscourseEvents::Events{ "identifier" => "sam", "attendance" => "interested" },{ "identifier" => "the_foo_bar_group", "attendance" => "not_going" },],+ recurring: true,},as: :jsonend@@ -1033,6 +1037,7 @@ module DiscourseEvents::Events{ "identifier" => user1.username, "attendance" => "going" },{ "identifier" => user2.username, "attendance" => "going" },],+ "recurring" => false,"current_user_id" => user.id,},) dodiff --git a/plugins/discourse-events/spec/requests/invitees_controller_spec.rb b/plugins/discourse-events/spec/requests/invitees_controller_spec.rbindex 9cf6da2f0c5..9735872a976 100644--- a/plugins/discourse-events/spec/requests/invitees_controller_spec.rb+++ b/plugins/discourse-events/spec/requests/invitees_controller_spec.rb@@ -155,6 +155,72 @@ module DiscourseEvents::Eventsexpect(response.status).to eq(400)endend++ context "for a recurring event" do+ fab!(:single_occurrence_user, :user)+ fab!(:series_user, :user)+ let!(:recurring_event) do+ Fabricate(+ :event,+ post: post_1,+ original_starts_at: Time.utc(2026, 9, 29, 18, 30),+ recurrence: "every_weekday",+ timezone: "Europe/Madrid",+ )+ end++ before do+ Invitee.create_attendance!(single_occurrence_user.id, recurring_event.id, :going)+ Invitee.create_attendance!(series_user.id, recurring_event.id, :going, recurring: true)+ end++ it "returns all going attendees for the current occurrence" do+ get "/discourse-post-event/events/#{recurring_event.id}/invitees.json",+ params: {+ type: "going",+ occurrence_starts_at: recurring_event.starts_at.iso8601,+ }++ expect(+ response.parsed_body["invitees"].map { |invitee| invitee.dig("user", "username") },+ ).to contain_exactly(single_occurrence_user.username, series_user.username)+ end++ it "returns only recurring going attendees for a later occurrence" do+ get "/discourse-post-event/events/#{recurring_event.id}/invitees.json",+ params: {+ type: "going",+ occurrence_starts_at: (recurring_event.starts_at + 1.day).iso8601,+ recurrence_scope: "this_event",+ }++ expect(+ response.parsed_body["invitees"].map { |invitee| invitee.dig("user", "username") },+ ).to contain_exactly(series_user.username)+ end++ it "filters going attendees by explicit recurrence scope" do+ get "/discourse-post-event/events/#{recurring_event.id}/invitees.json",+ params: {+ type: "going",+ recurrence_scope: "first_event_only",+ }++ expect(+ response.parsed_body["invitees"].map { |invitee| invitee.dig("user", "username") },+ ).to contain_exactly(single_occurrence_user.username)++ get "/discourse-post-event/events/#{recurring_event.id}/invitees.json",+ params: {+ type: "going",+ recurrence_scope: "this_and_following",+ }++ expect(+ response.parsed_body["invitees"].map { |invitee| invitee.dig("user", "username") },+ ).to contain_exactly(series_user.username)+ end+ endenddescribe "#create" dodiff --git a/plugins/discourse-events/spec/services/discourse_events/events/bulk_invite_spec.rb b/plugins/discourse-events/spec/services/discourse_events/events/bulk_invite_spec.rbindex d47a95aa65d..b2e0bc57017 100644--- a/plugins/discourse-events/spec/services/discourse_events/events/bulk_invite_spec.rb+++ b/plugins/discourse-events/spec/services/discourse_events/events/bulk_invite_spec.rb@@ -89,6 +89,7 @@ RSpec.describe(DiscourseEvents::Events::BulkInvite) doargs: {event_id: event.id,invitees: invitees,+ recurring: false,current_user_id: admin.id,},) { result }@@ -107,6 +108,7 @@ RSpec.describe(DiscourseEvents::Events::BulkInvite) doargs: {event_id: event.id,invitees: invitees.first(2),+ recurring: false,current_user_id: admin.id,},) { result }diff --git a/plugins/discourse-events/spec/services/discourse_events/events/csv_bulk_invite_spec.rb b/plugins/discourse-events/spec/services/discourse_events/events/csv_bulk_invite_spec.rbindex 784c26863f8..c4575a40e59 100644--- a/plugins/discourse-events/spec/services/discourse_events/events/csv_bulk_invite_spec.rb+++ b/plugins/discourse-events/spec/services/discourse_events/events/csv_bulk_invite_spec.rb@@ -102,6 +102,7 @@ RSpec.describe(DiscourseEvents::Events::CsvBulkInvite) doargs: {event_id: event.id,invitees: [{ "identifier" => invited_user.username, "attendance" => "going" }],+ recurring: false,current_user_id: admin.id,},) { result }diff --git a/plugins/discourse-events/spec/system/page_objects/discourse_events/bulk_invite_modal.rb b/plugins/discourse-events/spec/system/page_objects/discourse_events/bulk_invite_modal.rbindex 4eb900e0f24..6f143c3680e 100644--- a/plugins/discourse-events/spec/system/page_objects/discourse_events/bulk_invite_modal.rb+++ b/plugins/discourse-events/spec/system/page_objects/discourse_events/bulk_invite_modal.rb@@ -38,6 +38,11 @@ module PageObjectsselfend+ def apply_to_following_events+ find(".bulk-invite-recurrence .form-kit__control-checkbox-label").click+ self+ end+def upload_csv(path)find(".csv-bulk-invites input.hidden-upload-field", visible: :all).set(path)selfdiff --git a/plugins/discourse-events/spec/system/page_objects/discourse_events/post_event.rb b/plugins/discourse-events/spec/system/page_objects/discourse_events/post_event.rbindex 37839e2ec94..a3b2c2bcf81 100644--- a/plugins/discourse-events/spec/system/page_objects/discourse_events/post_event.rb+++ b/plugins/discourse-events/spec/system/page_objects/discourse_events/post_event.rb@@ -82,6 +82,11 @@ module PageObjectshas_css?(".event-invitees-icon .going", text: count.to_s)end+ def open_invitees_modal+ find(".event-invitees-icon").click+ self+ end+def has_invitee_avatar?(username)has_css?(".event-invitees-avatars [data-user-card='#{username}']")enddiff --git a/plugins/discourse-events/spec/system/page_objects/modals/discourse_events/invitees.rb b/plugins/discourse-events/spec/system/page_objects/modals/discourse_events/invitees.rbnew file mode 100644index 00000000000..0b74434830b--- /dev/null+++ b/plugins/discourse-events/spec/system/page_objects/modals/discourse_events/invitees.rb@@ -0,0 +1,40 @@+# frozen_string_literal: true++module PageObjects+ module Modals+ module DiscourseEvents+ class Invitees < PageObjects::Modals::Base+ MODAL_SELECTOR = ".post-event-invitees-modal"++ def initialize+ super(body_selector: "", modal_selector: MODAL_SELECTOR)+ end++ def has_attendee?(user)+ has_css?("#{full_modal_selector} .invitees .username", text: user.username)+ end++ def has_no_attendee?(user)+ has_no_css?("#{full_modal_selector} .invitees .username", text: user.username)+ end++ def has_selected_scope?(scope)+ has_css?(+ "#{full_modal_selector} .invitees-recurrence-filter button.active",+ text: I18n.t("js.discourse_post_event.invitees_modal.#{scope}"),+ exact_text: true,+ )+ end++ def show_first_event_only+ find(+ "#{full_modal_selector} .invitees-recurrence-filter button",+ text: I18n.t("js.discourse_post_event.invitees_modal.first_event_only"),+ exact_text: true,+ ).click+ self+ end+ end+ end+ end+enddiff --git a/plugins/discourse-events/spec/system/post_event_spec.rb b/plugins/discourse-events/spec/system/post_event_spec.rbindex 774200b6846..0d588f8a7c7 100644--- a/plugins/discourse-events/spec/system/post_event_spec.rb+++ b/plugins/discourse-events/spec/system/post_event_spec.rb@@ -536,11 +536,14 @@ describe "Post event" doendcontext "when using bulk inline invite" do+ before { Jobs.run_immediately! }+let!(:post) doPostCreator.create(admin,title: "My test meetup event",- raw: "[event name='cool-event' status='public' start='2222-02-22 00:00' ]\n[/event]",+ raw:+ "[event name='cool-event' status='public' start='2222-02-22 00:00' recurrence='every_week']\n[/event]",)end@@ -560,6 +563,20 @@ describe "Post event" doexpect(bulk_invite_modal_page).to be_closedend+ it "can apply bulk attendance to every following occurrence" do+ visit(post.topic.url)++ post_event_page.open_bulk_invite_modal+ bulk_invite_modal_page+ .set_invitee_at_row(invitable_user_1.username, "going", 1)+ .apply_to_following_events+ .send_invites++ expect(+ DiscourseEvents::Events::Invitee.find_by(user_id: invitable_user_1.id, post_id: post.id),+ ).to be_recurring+ end+it "keeps a single row when removing the last invitee" dovisit(post.topic.url)@@ -579,15 +596,22 @@ describe "Post event" dovisit(post.topic.url)post_event_page.open_bulk_invite_modal- bulk_invite_modal_page.upload_csv(- "#{Rails.root.join("plugins/discourse-events/spec/fixtures/csv/bulk_invite.csv")}",- )- PageObjects::Components::Dialog.new.click_yes+ bulk_invite_modal_page.apply_to_following_events++ Tempfile.create(%w[bulk-invite .csv]) do |file|+ file.write("#{invitable_user_1.username},going\n")+ file.flush+ bulk_invite_modal_page.upload_csv(file.path)+ PageObjects::Components::Dialog.new.click_yes+ endexpect(bulk_invite_modal_page).to be_closedexpect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.discourse_post_event.bulk_invite_modal.success"),)+ expect(+ DiscourseEvents::Events::Invitee.find_by(user_id: invitable_user_1.id, post_id: post.id),+ ).to be_recurringendenddiff --git a/plugins/discourse-events/spec/system/upcoming_events_spec.rb b/plugins/discourse-events/spec/system/upcoming_events_spec.rbindex 962c8fe6c9f..ca14a5cf575 100644--- a/plugins/discourse-events/spec/system/upcoming_events_spec.rb+++ b/plugins/discourse-events/spec/system/upcoming_events_spec.rb@@ -36,6 +36,7 @@ describe "Upcoming Events" dofab!(:going_recurring_user, :user)fab!(:going_once_user, :user)let(:post_event_page) { PageObjects::Pages::DiscourseEvents::PostEvent.new }+ let(:invitees_modal) { PageObjects::Modals::DiscourseEvents::Invitees.new }it "filters non-recurring goings out of future occurrences",time: Time.utc(2026, 5, 12, 12, 0) do@@ -46,7 +47,8 @@ describe "Upcoming Events" douser: admin,category:,title: "Weekly stand-up event",- raw: "[event status='public' start='2026-05-14 14:00' recurrence='every_week']\n[/event]",+ raw:+ "[event status='public' start='2026-05-14 14:00' timezone='Australia/Brisbane' showLocalTime=true recurrence='every_week']\n[/event]",)event = DiscourseEvents::Events::Event.find(post.id)DiscourseEvents::Events::Invitee.create_attendance!(@@ -71,6 +73,15 @@ describe "Upcoming Events" doexpect(post_event_page).to have_going_count(1)expect(post_event_page).to have_invitee_avatar(going_recurring_user.username)expect(post_event_page).to have_no_invitee_avatar(going_once_user.username)++ post_event_page.open_invitees_modal+ expect(invitees_modal).to have_attendee(going_recurring_user)+ expect(invitees_modal).to have_no_attendee(going_once_user)+ expect(invitees_modal).to have_selected_scope(:this_event)++ invitees_modal.show_first_event_only+ expect(invitees_modal).to have_attendee(going_once_user)+ expect(invitees_modal).to have_no_attendee(going_recurring_user)endend