9 Commits
Author SHA1 Message Date
zemion 4f02425a28 docs(calendar): complete German reference coverage
Module Package Release / publish-packages (push) Successful in 12s
2026-08-23 20:19:13 +02:00
zemion a2a9e8e814 feat: add governed Calendar DSAR coverage 2026-08-20 23:27:27 +02:00
zemion 93fb8aeff8 feat: reconcile scheduling calendar holds 2026-08-20 07:44:15 +02:00
zemion 4bbf80e634 feat(webui): complete calendar quick access 2026-08-19 19:48:51 +02:00
zemion 734501281e style: use shared WebUI foundation tokens 2026-08-18 21:32:50 +02:00
zemion 35671dec73 Adopt shared WebUI structural primitives 2026-08-18 13:17:28 +02:00
zemion f9385519f3 Adopt shared WebUI layout primitives 2026-08-18 11:30:39 +02:00
zemion a6e10fd120 Adopt shared WebUI layout primitives 2026-08-18 10:42:51 +02:00
zemion b6f939eaba Contribute Calendar to Quick Access 2026-08-06 19:02:55 +02:00
27 changed files with 2753 additions and 186 deletions
+9
View File
@@ -81,6 +81,15 @@ and appointment modules. It is not yet a CalDAV network server: external clients
cannot use GovOPlaN itself as their CalDAV endpoint, and scheduling inbox/outbox cannot use GovOPlaN itself as their CalDAV endpoint, and scheduling inbox/outbox
delivery remains owned by the scheduling and mail integration work. delivery remains owned by the scheduling and mail integration work.
Calendar also publishes `privacy.dsar.calendar`. Core's governed
data-subject-request workflow can use it to find tenant-scoped organizer,
attendee, preference, synchronization, outbox, and migration metadata. The
provider isolates the matching party and omits raw ICS, connector locators,
credentials, tokens, worker claims, and unrelated attendees. It classifies
synchronized and correlated state as retained evidence, leaves shared event
changes for manual review, and can safely delete only the subject's personal
view preference after revalidating tenant and ownership.
## Development ## Development
Install through the core environment: Install through the core environment:
+29
View File
@@ -191,6 +191,35 @@ the same tenant scope.
## Integration Points ## Integration Points
## Data-subject requests and retention boundaries
Calendar implements the optional `privacy.dsar.calendar` capability used by
Core's governed data-subject-request workflow. A search is bounded to the
effective tenant and matches normalized organizer or attendee email, direct
membership references, and independently corroborated namespaced Calendar
collection or event references. Only the matching party fragment is projected;
unrelated attendees and unrelated events in the same collection are not copied
into the case.
The projection includes safe event and collection context, personal view
preferences, subject-owned synchronization configuration, outbox outcomes, and
migration state. It never includes raw ICS or complete iCalendar objects,
collection URLs, remote resource hrefs or ETags, sync tokens, usernames,
credential references or ciphertext, idempotency keys, worker leases, provider
error text, or opaque metadata. An authorized reviewer must use Calendar's own
screens when excluded content is necessary to decide the request.
Synchronized, correlated, deleted, queued, and migrated state is classified as
retained evidence with an explicit reason. Local collections and events and
active credential metadata remain manual-review items because erasure can
affect recurrence, other attendees, institutional scheduling, remote systems,
and retention duties. The only executable provider action is deletion of the
subject's personal view preference; execution locks and revalidates its tenant
and owner and is idempotent. Event, attendee, credential, outbox, and migration
records are never mutated directly by the DSAR provider. Related meeting-poll,
mail, and delivery data remains owned by Scheduling, Poll, Mail, and their own
providers.
### Scheduling ### Scheduling
`govoplan-scheduling` should use calendar for: `govoplan-scheduling` should use calendar for:
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@govoplan/calendar-webui", "name": "@govoplan/calendar-webui",
"version": "0.1.18", "version": "0.1.20",
"private": true, "private": true,
"type": "module", "type": "module",
"main": "webui/src/index.ts", "main": "webui/src/index.ts",
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "govoplan-calendar" name = "govoplan-calendar"
version = "0.1.18" version = "0.1.20"
description = "GovOPlaN calendar module with VEVENT storage and WebUI integration." description = "GovOPlaN calendar module with VEVENT storage and WebUI integration."
readme = "README.md" readme = "README.md"
requires-python = ">=3.12" requires-python = ">=3.12"
+1 -1
View File
@@ -2,4 +2,4 @@
__all__ = ["__version__"] __all__ = ["__version__"]
__version__ = "0.1.18" __version__ = "0.1.20"
@@ -11,6 +11,7 @@ from sqlalchemy.orm import Session
from govoplan_core.core.calendar import ( from govoplan_core.core.calendar import (
CalendarCapabilityError, CalendarCapabilityError,
CalendarEventRef, CalendarEventRef,
CalendarEventReleaseRef,
CalendarEventRequest, CalendarEventRequest,
CalendarExternalProfileProvider, CalendarExternalProfileProvider,
CalendarExternalProfileRef, CalendarExternalProfileRef,
@@ -37,6 +38,7 @@ from govoplan_calendar.backend.service import (
CalendarError, CalendarError,
create_sync_source, create_sync_source,
create_event, create_event,
delete_event,
list_calendars as list_calendar_collections, list_calendars as list_calendar_collections,
list_freebusy, list_freebusy,
update_event, update_event,
@@ -312,6 +314,96 @@ class SqlCalendarSchedulingProvider(CalendarSchedulingProvider):
outbox_operation_id=outbox_operation_id, outbox_operation_id=outbox_operation_id,
) )
def promote_event(
self,
session: object,
*,
tenant_id: str,
user_id: str | None,
event_id: str,
request: CalendarEventRequest,
) -> CalendarEventRef:
try:
payload = CalendarEventUpdateRequest(
calendar_id=request.calendar_id,
summary=request.summary,
description=request.description,
location=request.location,
status=request.status,
transparency=request.transparency,
classification=request.classification,
start_at=request.start_at,
end_at=request.end_at,
timezone=request.timezone,
attendees=[dict(item) for item in request.attendees],
categories=list(request.categories),
related_to=[dict(item) for item in request.related_to],
metadata=dict(request.metadata),
)
event = update_event(
session,
tenant_id=tenant_id,
user_id=user_id,
event_id=event_id,
payload=payload,
)
except (CalendarError, TypeError, ValueError) as exc:
raise CalendarCapabilityError(str(exc)) from exc
external_state, outbox_operation_id = _external_state(event)
return CalendarEventRef(
id=event.id,
calendar_id=event.calendar_id,
uid=event.uid,
external_state=external_state,
outbox_operation_id=outbox_operation_id,
)
def release_event(
self,
session: object,
*,
tenant_id: str,
user_id: str | None,
event_id: str,
) -> CalendarEventReleaseRef:
if not isinstance(session, Session):
raise CalendarCapabilityError("Calendar release requires a database session")
event = (
session.query(CalendarEvent)
.filter(
CalendarEvent.tenant_id == tenant_id,
CalendarEvent.id == event_id,
)
.first()
)
if event is None:
return CalendarEventReleaseRef(
event_id=event_id,
already_released=True,
external_state="not_found",
)
was_released = event.deleted_at is not None
if not was_released:
try:
delete_event(
session,
tenant_id=tenant_id,
event_id=event_id,
user_id=user_id,
)
except CalendarError as exc:
raise CalendarCapabilityError(str(exc)) from exc
session.flush()
external_state, outbox_operation_id = _external_state(event)
return CalendarEventReleaseRef(
event_id=event_id,
already_released=was_released,
external_state=(
external_state if external_state != "local" else "local_released"
),
outbox_operation_id=outbox_operation_id,
)
class SqlCalendarExternalProfileProvider(CalendarExternalProfileProvider): class SqlCalendarExternalProfileProvider(CalendarExternalProfileProvider):
"""Configure groupware profiles while Calendar retains event semantics.""" """Configure groupware profiles while Calendar retains event semantics."""
@@ -0,0 +1,888 @@
from __future__ import annotations
from collections.abc import Mapping, Sequence
from datetime import datetime, timezone
from sqlalchemy import Text, cast, func, or_
from sqlalchemy.orm import Session
from govoplan_calendar.backend.db.models import (
CalendarCollection,
CalendarEvent,
CalendarMigrationBatch,
CalendarMigrationResource,
CalendarOutboxOperation,
CalendarSyncCredential,
CalendarSyncSource,
CalendarViewPreference,
)
from govoplan_core.core.dsar import (
DsarErasureActionRef,
DsarExecutionResultRef,
DsarRecordRef,
DsarSubjectRef,
dsar_capability_name,
)
CALENDAR_DSAR_CAPABILITY = dsar_capability_name("calendar")
_MAX_RECORDS = 5_000
_SECRET_PARTS = (
"authorization",
"credential",
"idempotency",
"lease",
"password",
"secret",
"token",
)
_LOCATOR_PARTS = ("href", "path", "url")
class CalendarDsarProvider:
provider_id = "calendar"
module_id = "calendar"
def search_subject(
self,
session: object,
*,
tenant_id: str,
subject: DsarSubjectRef,
) -> Sequence[DsarRecordRef]:
db = _session(session)
subject_user_id = _subject_user_id(subject)
subject_email = _subject_email(subject)
references = _calendar_references(subject)
if subject_user_id is None and subject_email is None and not references:
return ()
records: list[DsarRecordRef] = []
def append(record: DsarRecordRef) -> None:
if len(records) >= _MAX_RECORDS:
raise ValueError(
"Calendar DSAR match limit exceeded; narrow the subject selectors."
)
records.append(record)
events = _matching_events(
db,
tenant_id=tenant_id,
subject_user_id=subject_user_id,
subject_email=subject_email,
event_id=references.get("event"),
)
event_ids = {row.id for row in events}
collection_ids = {row.calendar_id for row in events}
if references.get("collection"):
collection_ids.add(references["collection"])
collections = _matching_collections(
db,
tenant_id=tenant_id,
subject_user_id=subject_user_id,
collection_ids=collection_ids,
)
collection_ids = {row.id for row in collections}
owned_collection_ids = {
row.id
for row in collections
if subject_user_id is not None
and (
(row.owner_type == "user" and row.owner_id == subject_user_id)
or row.created_by_user_id == subject_user_id
)
}
outbox_by_event = _outbox_by_event(
db,
tenant_id=tenant_id,
event_ids=event_ids,
)
for collection in collections:
match_fields = _matching_fields(
collection,
subject_user_id,
("created_by_user_id",),
)
if (
subject_user_id is not None
and collection.owner_type == "user"
and collection.owner_id == subject_user_id
):
match_fields.insert(0, "owner_id")
immutable = collection.deleted_at is not None
append(
_record(
"calendar_collection",
collection.id,
"calendar_collection",
collection.name,
{
"match_fields": match_fields,
"event_context": collection.id
in {row.calendar_id for row in events},
"slug": collection.slug,
"name": collection.name,
"description": collection.description,
"timezone": collection.timezone,
"color": collection.color,
"owner_type": collection.owner_type,
"visibility": collection.visibility,
"is_default": collection.is_default,
"deleted_at": _iso(collection.deleted_at),
},
observed_at=collection.updated_at,
immutable=immutable,
retention_reason=(
"Deleted collection state is retained until Calendar lifecycle cleanup completes."
if immutable
else None
),
source_path="/calendar",
)
)
for event in events:
organizer = _matching_party(event.organizer, subject_email)
attendees = _matching_parties(event.attendees, subject_email)
actor_fields = _matching_fields(
event,
subject_user_id,
("created_by_user_id", "updated_by_user_id"),
)
immutable = bool(
event.deleted_at
or event.source_kind != "local"
or event.correlation_key
or event.producer_module
or outbox_by_event.get(event.id)
)
append(
_record(
"calendar_event",
event.id,
"calendar_event",
event.summary,
{
"match_fields": actor_fields
+ (["organizer"] if organizer else [])
+ (["attendees"] if attendees else []),
"calendar_id": event.calendar_id,
"uid": event.uid,
"recurrence_id": event.recurrence_id,
"sequence": event.sequence,
"summary": event.summary,
"description": event.description,
"location": event.location,
"status": event.status,
"transparency": event.transparency,
"classification": event.classification,
"start_at": _iso(event.start_at),
"end_at": _iso(event.end_at),
"duration_seconds": event.duration_seconds,
"all_day": event.all_day,
"timezone": event.timezone,
"organizer": organizer,
"matching_attendees": attendees,
"categories": _safe_value(event.categories),
"rrule": _safe_value(event.rrule),
"rdate": _safe_value(event.rdate),
"exdate": _safe_value(event.exdate),
"reminders": _safe_value(event.reminders),
"attachment_count": len(event.attachments or ()),
"source_kind": event.source_kind,
"producer_module": event.producer_module,
"producer_resource_type": event.producer_resource_type,
"producer_resource_id": event.producer_resource_id,
"deleted_at": _iso(event.deleted_at),
},
observed_at=event.updated_at,
immutable=immutable,
retention_reason=(
"Synchronized, correlated, deleted, or externally queued event state is retained as Calendar execution evidence."
if immutable
else None
),
source_path="/calendar",
)
)
for operations in outbox_by_event.values():
for operation in operations:
append(
_record(
"calendar_outbox_operation",
operation.id,
"calendar_sync_evidence",
f"Calendar {operation.operation_kind} operation",
{
"event_id": operation.event_id,
"operation_kind": operation.operation_kind,
"payload_fingerprint": operation.payload_fingerprint,
"status": operation.status,
"attempt_count": operation.attempt_count,
"max_attempts": operation.max_attempts,
"available_at": _iso(operation.available_at),
"last_attempt_at": _iso(operation.last_attempt_at),
"completed_at": _iso(operation.completed_at),
"reconciled_at": _iso(operation.reconciled_at),
},
observed_at=operation.updated_at,
immutable=True,
retention_reason="Calendar outbox outcomes are synchronization and recovery evidence.",
)
)
self._append_user_resources(
db,
append=append,
tenant_id=tenant_id,
subject_user_id=subject_user_id,
)
self._append_sync_and_migration_resources(
db,
append=append,
tenant_id=tenant_id,
subject_user_id=subject_user_id,
owned_collection_ids=owned_collection_ids,
)
return tuple(records)
def plan_erasure(
self,
session: object,
*,
tenant_id: str,
subject: DsarSubjectRef,
records: Sequence[DsarRecordRef],
) -> Sequence[DsarErasureActionRef]:
del session
subject_user_id = _subject_user_id(subject)
actions: list[DsarErasureActionRef] = []
for record in records:
if (
record.provider_id != self.provider_id
or record.module_id != self.module_id
):
raise ValueError("Calendar DSAR received a foreign provider record.")
actions.append(
_action(
f"calendar:{'retain' if record.immutable_evidence else 'review'}:{record.resource_type}:{record.resource_id}",
"retain" if record.immutable_evidence else "manual_review",
record,
f"{'Retain' if record.immutable_evidence else 'Review'} {record.title}",
record.retention_reason
or "Calendar content can span recurrence, attendees, synchronized resources, and external recovery state; review it through Calendar lifecycle controls.",
executable=False,
)
)
if (
record.resource_type == "calendar_view_preference"
and "user_id" in record.data.get("match_fields", ())
and subject_user_id is not None
):
actions.append(
_action(
f"calendar:delete:calendar_view_preference:{record.resource_id}",
"delete",
record,
"Delete personal Calendar view preference",
"The personal presentation preference can be removed without changing events or synchronization evidence.",
executable=True,
irreversible=True,
metadata={
"subject_user_id": subject_user_id,
"tenant_id": tenant_id,
},
)
)
action_ids = [action.action_id for action in actions]
if len(action_ids) != len(set(action_ids)):
raise ValueError("Calendar DSAR produced duplicate action ids.")
return tuple(actions)
def execute_erasure(
self,
session: object,
*,
tenant_id: str,
subject: DsarSubjectRef,
actions: Sequence[DsarErasureActionRef],
request_id: str,
) -> Sequence[DsarExecutionResultRef]:
db = _session(session)
subject_user_id = _subject_user_id(subject)
results: list[DsarExecutionResultRef] = []
for action in actions:
if (
subject_user_id is None
or action.provider_id != self.provider_id
or action.module_id != self.module_id
or action.metadata.get("subject_user_id") != subject_user_id
or action.metadata.get("tenant_id") != tenant_id
):
results.append(
_blocked(action, "The Calendar DSAR action is stale or invalid.")
)
continue
if action.action_id.startswith("calendar:delete:calendar_view_preference:"):
results.append(
_delete_view_preference(
db,
tenant_id=tenant_id,
subject_user_id=subject_user_id,
action=action,
request_id=request_id,
)
)
else:
results.append(
_blocked(action, "Calendar does not execute this action kind.")
)
db.flush()
return tuple(results)
def _append_user_resources(
self,
db: Session,
*,
append: object,
tenant_id: str,
subject_user_id: str | None,
) -> None:
if subject_user_id is None:
return
for preference in _bounded_rows(
db.query(CalendarViewPreference)
.filter(
CalendarViewPreference.tenant_id == tenant_id,
CalendarViewPreference.user_id == subject_user_id,
)
.order_by(CalendarViewPreference.id)
):
append( # type: ignore[operator]
_record(
"calendar_view_preference",
preference.id,
"personal_calendar_preference",
"Calendar view preference",
{
"match_fields": ["user_id"],
"dim_weekends": preference.dim_weekends,
"dim_off_hours": preference.dim_off_hours,
"workday_start_hour": preference.workday_start_hour,
"workday_end_hour": preference.workday_end_hour,
"continuous_virtualization": preference.continuous_virtualization,
"continuous_overscan_weeks": preference.continuous_overscan_weeks,
"alternate_continuous_months": preference.alternate_continuous_months,
},
observed_at=preference.updated_at,
source_path="/settings?section=calendar",
)
)
for credential in _bounded_rows(
db.query(CalendarSyncCredential)
.filter(
CalendarSyncCredential.tenant_id == tenant_id,
CalendarSyncCredential.created_by_user_id == subject_user_id,
)
.order_by(CalendarSyncCredential.id)
):
append( # type: ignore[operator]
_record(
"calendar_sync_credential",
credential.id,
"calendar_sync_configuration",
credential.label or "Calendar sync credential",
{
"match_fields": ["created_by_user_id"],
"credential_kind": credential.credential_kind,
"label": credential.label,
"deleted_at": _iso(credential.deleted_at),
},
observed_at=credential.updated_at,
immutable=credential.deleted_at is not None,
retention_reason=(
"Retired credential metadata remains synchronization governance evidence."
if credential.deleted_at is not None
else None
),
)
)
def _append_sync_and_migration_resources(
self,
db: Session,
*,
append: object,
tenant_id: str,
subject_user_id: str | None,
owned_collection_ids: set[str],
) -> None:
if owned_collection_ids:
for source in _bounded_rows(
db.query(CalendarSyncSource)
.filter(
CalendarSyncSource.tenant_id == tenant_id,
CalendarSyncSource.calendar_id.in_(owned_collection_ids),
)
.order_by(CalendarSyncSource.id)
):
append( # type: ignore[operator]
_record(
"calendar_sync_source",
source.id,
"calendar_sync_configuration",
source.display_name or source.source_kind,
{
"calendar_id": source.calendar_id,
"source_kind": source.source_kind,
"display_name": source.display_name,
"auth_type": source.auth_type,
"sync_enabled": source.sync_enabled,
"sync_interval_seconds": source.sync_interval_seconds,
"sync_direction": source.sync_direction,
"conflict_policy": source.conflict_policy,
"last_attempt_at": _iso(source.last_attempt_at),
"last_synced_at": _iso(source.last_synced_at),
"next_sync_at": _iso(source.next_sync_at),
"last_status": source.last_status,
"deleted_at": _iso(source.deleted_at),
},
observed_at=source.updated_at,
immutable=True,
retention_reason="External source configuration and synchronization state require coordinated Calendar review.",
)
)
migration_conditions = []
if subject_user_id is not None:
migration_conditions.append(
CalendarMigrationBatch.created_by_user_id == subject_user_id
)
if owned_collection_ids:
migration_conditions.extend(
(
CalendarMigrationBatch.source_calendar_id.in_(owned_collection_ids),
CalendarMigrationBatch.target_calendar_id.in_(owned_collection_ids),
)
)
if not migration_conditions:
return
batches = _bounded_rows(
db.query(CalendarMigrationBatch)
.filter(
CalendarMigrationBatch.tenant_id == tenant_id,
or_(*migration_conditions),
)
.order_by(CalendarMigrationBatch.id)
)
batch_ids = {row.id for row in batches}
for batch in batches:
append( # type: ignore[operator]
_record(
"calendar_migration_batch",
batch.id,
"calendar_migration_evidence",
f"Calendar migration {batch.id}",
{
"match_fields": _matching_fields(
batch, subject_user_id, ("created_by_user_id",)
),
"migration_kind": batch.migration_kind,
"status": batch.status,
"phase": batch.phase,
"total_resources": batch.total_resources,
"total_events": batch.total_events,
"completed_at": _iso(batch.completed_at),
},
observed_at=batch.updated_at,
immutable=True,
retention_reason="Remote-move authorization and outcome state is immutable migration evidence.",
)
)
if not batch_ids:
return
for resource in _bounded_rows(
db.query(CalendarMigrationResource)
.filter(CalendarMigrationResource.batch_id.in_(batch_ids))
.order_by(CalendarMigrationResource.id)
):
append( # type: ignore[operator]
_record(
"calendar_migration_resource",
resource.id,
"calendar_migration_evidence",
"Calendar migration resource",
{
"batch_id": resource.batch_id,
"status": resource.status,
"event_count": len(resource.event_ids or ()),
},
observed_at=resource.updated_at,
immutable=True,
retention_reason="Per-resource move state is immutable migration and recovery evidence.",
)
)
def _matching_events(
session: Session,
*,
tenant_id: str,
subject_user_id: str | None,
subject_email: str | None,
event_id: str | None,
) -> list[CalendarEvent]:
conditions = []
if event_id:
conditions.append(CalendarEvent.id == event_id)
if subject_user_id:
conditions.extend(
(
CalendarEvent.created_by_user_id == subject_user_id,
CalendarEvent.updated_by_user_id == subject_user_id,
)
)
if subject_email:
pattern = f"%{_escape_like(subject_email)}%"
conditions.extend(
(
func.lower(cast(CalendarEvent.organizer, Text)).like(
pattern, escape="\\"
),
func.lower(cast(CalendarEvent.attendees, Text)).like(
pattern, escape="\\"
),
)
)
if not conditions:
return []
candidates = _bounded_rows(
session.query(CalendarEvent)
.filter(CalendarEvent.tenant_id == tenant_id, or_(*conditions))
.order_by(CalendarEvent.id)
)
return [
row
for row in candidates
if row.id == event_id
or (
subject_user_id is not None
and (
row.created_by_user_id == subject_user_id
or row.updated_by_user_id == subject_user_id
)
)
or _matching_party(row.organizer, subject_email)
or _matching_parties(row.attendees, subject_email)
]
def _matching_collections(
session: Session,
*,
tenant_id: str,
subject_user_id: str | None,
collection_ids: set[str],
) -> list[CalendarCollection]:
conditions = []
if collection_ids:
conditions.append(CalendarCollection.id.in_(collection_ids))
if subject_user_id:
conditions.extend(
(
(CalendarCollection.owner_type == "user")
& (CalendarCollection.owner_id == subject_user_id),
CalendarCollection.created_by_user_id == subject_user_id,
)
)
if not conditions:
return []
return _bounded_rows(
session.query(CalendarCollection)
.filter(CalendarCollection.tenant_id == tenant_id, or_(*conditions))
.order_by(CalendarCollection.id)
)
def _outbox_by_event(
session: Session,
*,
tenant_id: str,
event_ids: set[str],
) -> dict[str, list[CalendarOutboxOperation]]:
if not event_ids:
return {}
result: dict[str, list[CalendarOutboxOperation]] = {}
for row in _bounded_rows(
session.query(CalendarOutboxOperation)
.filter(
CalendarOutboxOperation.tenant_id == tenant_id,
CalendarOutboxOperation.event_id.in_(event_ids),
)
.order_by(CalendarOutboxOperation.id)
):
result.setdefault(str(row.event_id), []).append(row)
return result
def _matching_party(value: object, email: str | None) -> dict[str, object] | None:
if email is None or not isinstance(value, Mapping):
return None
address = _party_email(value)
if address != email:
return None
params = value.get("params")
safe_params: dict[str, object] = {}
if isinstance(params, Mapping):
for key in ("CN", "CUTYPE", "PARTSTAT", "ROLE", "RSVP"):
if key in params:
safe_params[key] = _safe_value(params[key])
return {
"email": address,
"name": value.get("name") or _first_value(safe_params.get("CN")),
"participation_status": _first_value(safe_params.get("PARTSTAT")),
"role": _first_value(safe_params.get("ROLE")),
"rsvp": _first_value(safe_params.get("RSVP")),
}
def _matching_parties(
values: object,
email: str | None,
) -> list[dict[str, object]]:
if not isinstance(values, list):
return []
return [party for value in values[:512] if (party := _matching_party(value, email))]
def _party_email(value: Mapping[object, object]) -> str | None:
candidate = value.get("email") or value.get("address") or value.get("value")
if not isinstance(candidate, str):
return None
if candidate.casefold().startswith("mailto:"):
candidate = candidate[7:]
return _normalized_email(candidate)
def _safe_value(value: object, *, depth: int = 0) -> object:
if depth >= 5:
return "[depth-limited]"
if isinstance(value, Mapping):
result: dict[str, object] = {}
for key, item in list(value.items())[:128]:
normalized = str(key).casefold()
if any(part in normalized for part in _SECRET_PARTS + _LOCATOR_PARTS):
continue
result[str(key)] = _safe_value(item, depth=depth + 1)
return result
if isinstance(value, list):
return [_safe_value(item, depth=depth + 1) for item in value[:256]]
if isinstance(value, str):
return value[:2_000]
if value is None or isinstance(value, (bool, int, float)):
return value
return str(value)[:2_000]
def _delete_view_preference(
session: Session,
*,
tenant_id: str,
subject_user_id: str,
action: DsarErasureActionRef,
request_id: str,
) -> DsarExecutionResultRef:
row = (
session.query(CalendarViewPreference)
.filter(
CalendarViewPreference.id == action.resource_id,
CalendarViewPreference.tenant_id == tenant_id,
)
.with_for_update()
.one_or_none()
)
if row is None:
return _result(
action,
"unchanged",
"The Calendar view preference was already absent.",
{"request_id": request_id},
)
if row.user_id != subject_user_id:
return _blocked(action, "The Calendar preference owner changed after planning.")
session.delete(row)
return _result(
action,
"executed",
"The personal Calendar view preference was deleted.",
{"request_id": request_id},
)
def _calendar_references(subject: DsarSubjectRef) -> dict[str, str]:
aliases = {
"calendar.collection": "collection",
"calendar.event": "event",
}
return {
target: value
for key, target in aliases.items()
if (value := str(subject.external_references.get(key) or "").strip())
}
def _subject_user_id(subject: DsarSubjectRef) -> str | None:
candidates = [subject.membership_id] if subject.membership_id else []
for key in (
"calendar.user",
"calendar.membership",
"access.membership",
"membership_id",
):
value = str(subject.external_references.get(key) or "").strip()
if value:
candidates.append(value)
normalized = {value.strip() for value in candidates if value.strip()}
return normalized.pop() if len(normalized) == 1 else None
def _subject_email(subject: DsarSubjectRef) -> str | None:
candidates = [subject.email] if subject.email else []
for key in ("calendar.email", "calendar.attendee_email"):
value = str(subject.external_references.get(key) or "").strip()
if value:
candidates.append(value)
normalized = {
email for value in candidates if (email := _normalized_email(value)) is not None
}
return normalized.pop() if len(normalized) == 1 else None
def _normalized_email(value: object) -> str | None:
if not isinstance(value, str):
return None
normalized = value.strip().casefold()
if normalized.startswith("mailto:"):
normalized = normalized[7:]
return normalized or None
def _first_value(value: object) -> object:
if isinstance(value, list):
return value[0] if value else None
return value
def _matching_fields(
row: object,
subject_user_id: str | None,
fields: Sequence[str],
) -> list[str]:
if subject_user_id is None:
return []
return [field for field in fields if getattr(row, field) == subject_user_id]
def _record(
resource_type: str,
resource_id: str,
category: str,
title: str,
data: Mapping[str, object],
*,
observed_at: datetime | None = None,
immutable: bool = False,
retention_reason: str | None = None,
source_path: str | None = None,
) -> DsarRecordRef:
return DsarRecordRef(
provider_id="calendar",
module_id="calendar",
resource_type=resource_type,
resource_id=resource_id,
category=category,
title=title,
data=data,
observed_at=observed_at,
immutable_evidence=immutable,
retention_reason=retention_reason,
source_path=source_path,
)
def _action(
action_id: str,
kind: str,
record: DsarRecordRef,
title: str,
rationale: str,
*,
executable: bool,
irreversible: bool = False,
metadata: Mapping[str, object] | None = None,
) -> DsarErasureActionRef:
return DsarErasureActionRef(
action_id=action_id,
provider_id="calendar",
module_id="calendar",
kind=kind, # type: ignore[arg-type]
resource_type=record.resource_type,
resource_id=record.resource_id,
title=title,
rationale=rationale,
executable=executable,
irreversible=irreversible,
metadata=metadata or {},
)
def _result(
action: DsarErasureActionRef,
status: str,
summary: str,
evidence: Mapping[str, object] | None = None,
) -> DsarExecutionResultRef:
return DsarExecutionResultRef(
action_id=action.action_id,
status=status, # type: ignore[arg-type]
summary=summary,
evidence=evidence or {},
)
def _blocked(action: DsarErasureActionRef, summary: str) -> DsarExecutionResultRef:
return _result(action, "blocked", summary)
def _session(value: object) -> Session:
if not isinstance(value, Session):
raise TypeError("Calendar DSAR provider requires a SQLAlchemy session.")
return value
def _bounded_rows(query: object) -> list[object]:
rows = query.limit(_MAX_RECORDS + 1).all() # type: ignore[attr-defined]
if len(rows) > _MAX_RECORDS:
raise ValueError(
"Calendar DSAR match limit exceeded; narrow the subject selectors."
)
return rows
def _escape_like(value: str) -> str:
return value.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_")
def _iso(value: datetime | None) -> str | None:
if value is None:
return None
if value.tzinfo is None:
value = value.replace(tzinfo=timezone.utc)
return value.isoformat()
__all__ = ["CALENDAR_DSAR_CAPABILITY", "CalendarDsarProvider"]
+436 -35
View File
@@ -6,7 +6,10 @@ from pathlib import Path
from sqlalchemy import inspect from sqlalchemy import inspect
from govoplan_calendar.backend.db import models as calendar_models # noqa: F401 - populate Calendar ORM metadata from govoplan_calendar.backend.db import models as calendar_models # noqa: F401 - populate Calendar ORM metadata
from govoplan_core.core.access import CAPABILITY_AUTH_PERMISSION_EVALUATOR, CAPABILITY_AUTH_PRINCIPAL_RESOLVER from govoplan_core.core.access import (
CAPABILITY_AUTH_PERMISSION_EVALUATOR,
CAPABILITY_AUTH_PRINCIPAL_RESOLVER,
)
from govoplan_core.core.calendar import ( from govoplan_core.core.calendar import (
CALENDAR_AVAILABILITY_READ_SCOPE, CALENDAR_AVAILABILITY_READ_SCOPE,
CALENDAR_EVENT_WRITE_SCOPE, CALENDAR_EVENT_WRITE_SCOPE,
@@ -15,9 +18,14 @@ from govoplan_core.core.calendar import (
CAPABILITY_CALENDAR_OUTBOX, CAPABILITY_CALENDAR_OUTBOX,
CAPABILITY_CALENDAR_SCHEDULING, CAPABILITY_CALENDAR_SCHEDULING,
) )
from govoplan_core.core.module_guards import drop_table_retirement_provider, persistent_table_uninstall_guard from govoplan_core.core.module_guards import (
drop_table_retirement_provider,
persistent_table_uninstall_guard,
)
from govoplan_core.core.modules import ( from govoplan_core.core.modules import (
CapabilityDocumentation,
DocumentationCondition, DocumentationCondition,
DocumentationLink,
DocumentationTopic, DocumentationTopic,
FrontendModule, FrontendModule,
FrontendRoute, FrontendRoute,
@@ -28,6 +36,8 @@ from govoplan_core.core.modules import (
ModuleManifest, ModuleManifest,
NavItem, NavItem,
PermissionDefinition, PermissionDefinition,
ProductAreaContribution,
QuickAccessTool,
RoleTemplate, RoleTemplate,
) )
from govoplan_core.core.search import SearchSourceProviderRegistration from govoplan_core.core.search import SearchSourceProviderRegistration
@@ -42,6 +52,7 @@ from govoplan_core.core.provider_governance import (
) )
from govoplan_core.core.views import ViewSurface from govoplan_core.core.views import ViewSurface
from govoplan_core.db.base import Base from govoplan_core.db.base import Base
from govoplan_calendar.backend.dsar_provider import CALENDAR_DSAR_CAPABILITY
from govoplan_calendar.backend.search_source import create_calendar_search_source from govoplan_calendar.backend.search_source import create_calendar_search_source
@@ -105,6 +116,7 @@ CALENDAR_ARCHITECTURE = ModuleArchitectureDeclaration(
), ),
) )
def _read_only_calendar_provider( def _read_only_calendar_provider(
*, *,
provider_id: str, provider_id: str,
@@ -244,13 +256,27 @@ CALENDAR_EXTERNAL_PROVIDERS = (
ProviderObjectDeclaration( ProviderObjectDeclaration(
object_type="calendar_collection", object_type="calendar_collection",
field_groups=("identity", "display", "sync_state", "resource_mapping"), field_groups=("identity", "display", "sync_state", "resource_mapping"),
authority_modes=("external_authoritative", "external_mirror", "governed_sync"), authority_modes=(
"external_authoritative",
"external_mirror",
"governed_sync",
),
default_authority_mode="governed_sync", default_authority_mode="governed_sync",
), ),
ProviderObjectDeclaration( ProviderObjectDeclaration(
object_type="calendar_event", object_type="calendar_event",
field_groups=("identity", "schedule", "recurrence", "participants", "content"), field_groups=(
authority_modes=("external_authoritative", "external_mirror", "governed_sync"), "identity",
"schedule",
"recurrence",
"participants",
"content",
),
authority_modes=(
"external_authoritative",
"external_mirror",
"governed_sync",
),
default_authority_mode="governed_sync", default_authority_mode="governed_sync",
), ),
), ),
@@ -267,19 +293,37 @@ CALENDAR_EXTERNAL_PROVIDERS = (
outcome_unknown="A timed-out remote write is outcome-unknown and is reconciled before retry.", outcome_unknown="A timed-out remote write is outcome-unknown and is reconciled before retry.",
outcome_unknown_supported=True, outcome_unknown_supported=True,
evidence="The Open-Xchange profile reference, mapping references, operation intent, ETag, and reconciliation result are retained.", evidence="The Open-Xchange profile reference, mapping references, operation intent, ETag, and reconciliation result are retained.",
audit_event_types=("calendar.sync.requested", "calendar.sync.completed", "calendar.sync.conflict", "calendar.sync.reconciled"), audit_event_types=(
"calendar.sync.requested",
"calendar.sync.completed",
"calendar.sync.conflict",
"calendar.sync.reconciled",
),
correction="A later conditional update or tombstone corrects external state after reconciliation.", correction="A later conditional update or tombstone corrects external state after reconciliation.",
rollback="Remote effects are not treated as transactionally rollback-safe.", rollback="Remote effects are not treated as transactionally rollback-safe.",
compensation="A compensating event update or delete may be queued after remote state is known.", compensation="A compensating event update or delete may be queued after remote state is known.",
reconciliation="Read by CalDAV href and VEVENT UID, compare ETag and content, then classify the result.", reconciliation="Read by CalDAV href and VEVENT UID, compare ETag and content, then classify the result.",
outage="The local projection remains available with stale markers and durable pending writes.", outage="The local projection remains available with stale markers and durable pending writes.",
classifications=("internal", "confidential", "restricted"), classifications=("internal", "confidential", "restricted"),
purposes=("calendar collaboration", "availability", "resource booking", "meeting coordination"), purposes=(
"calendar collaboration",
"availability",
"resource booking",
"meeting coordination",
),
retention="Calendar event, outbox, audit, profile-binding, and credential retention remain independent policies.", retention="Calendar event, outbox, audit, profile-binding, and credential retention remain independent policies.",
secret_handling="Calendar stores only scoped credential references or encrypted Calendar-owned credentials.", secret_handling="Calendar stores only scoped credential references or encrypted Calendar-owned credentials.",
), ),
capability_names=(CAPABILITY_CALENDAR_EXTERNAL_PROFILES, CAPABILITY_CALENDAR_OUTBOX, CAPABILITY_CALENDAR_SCHEDULING), capability_names=(
interface_names=("calendar.external_profiles", "calendar.outbox", "calendar.scheduling"), CAPABILITY_CALENDAR_EXTERNAL_PROFILES,
CAPABILITY_CALENDAR_OUTBOX,
CAPABILITY_CALENDAR_SCHEDULING,
),
interface_names=(
"calendar.external_profiles",
"calendar.outbox",
"calendar.scheduling",
),
documentation_topic_ids=("calendar.external-sources-and-sync",), documentation_topic_ids=("calendar.external-sources-and-sync",),
), ),
_read_only_calendar_provider( _read_only_calendar_provider(
@@ -320,10 +364,18 @@ def _calendar_retirement_provider(session: object | None, module_id: str):
return plan return plan
def executor(execute_session: object, execute_module_id: str) -> None: def executor(execute_session: object, execute_module_id: str) -> None:
if not hasattr(execute_session, "get_bind") or not hasattr(execute_session, "query"): if not hasattr(execute_session, "get_bind") or not hasattr(
raise RuntimeError("No database session is available for Calendar credential retirement.") execute_session, "query"
if inspect(execute_session.get_bind()).has_table(calendar_models.CalendarSyncCredential.__tablename__): ):
from govoplan_calendar.backend.service import delete_calendar_credentials_for_retirement raise RuntimeError(
"No database session is available for Calendar credential retirement."
)
if inspect(execute_session.get_bind()).has_table(
calendar_models.CalendarSyncCredential.__tablename__
):
from govoplan_calendar.backend.service import (
delete_calendar_credentials_for_retirement,
)
delete_calendar_credentials_for_retirement(execute_session) delete_calendar_credentials_for_retirement(execute_session)
base_executor(execute_session, execute_module_id) base_executor(execute_session, execute_module_id)
@@ -353,15 +405,51 @@ def _permission(scope: str, label: str, description: str) -> PermissionDefinitio
PERMISSIONS = ( PERMISSIONS = (
_permission("calendar:calendar:read", "View calendars", "List tenant calendar collections and metadata."), _permission(
_permission("calendar:calendar:write", "Manage calendars", "Create and edit tenant calendar collections."), "calendar:calendar:read",
_permission("calendar:calendar:admin", "Administer calendars", "Delete calendars and manage tenant-level calendar settings."), "View calendars",
_permission("calendar:event:read", "View calendar events", "List and inspect calendar events."), "List tenant calendar collections and metadata.",
_permission(CALENDAR_EVENT_WRITE_SCOPE, "Manage calendar events", "Create and edit calendar events."), ),
_permission("calendar:event:delete", "Delete calendar events", "Delete or cancel calendar events where policy allows it."), _permission(
_permission("calendar:event:import", "Import iCalendar events", "Import VEVENT data from iCalendar sources."), "calendar:calendar:write",
_permission("calendar:event:export", "Export iCalendar events", "Export events as text/calendar VEVENT data."), "Manage calendars",
_permission(CALENDAR_AVAILABILITY_READ_SCOPE, "Read availability", "Read free/busy and availability data for integrations."), "Create and edit tenant calendar collections.",
),
_permission(
"calendar:calendar:admin",
"Administer calendars",
"Delete calendars and manage tenant-level calendar settings.",
),
_permission(
"calendar:event:read",
"View calendar events",
"List and inspect calendar events.",
),
_permission(
CALENDAR_EVENT_WRITE_SCOPE,
"Manage calendar events",
"Create and edit calendar events.",
),
_permission(
"calendar:event:delete",
"Delete calendar events",
"Delete or cancel calendar events where policy allows it.",
),
_permission(
"calendar:event:import",
"Import iCalendar events",
"Import VEVENT data from iCalendar sources.",
),
_permission(
"calendar:event:export",
"Export iCalendar events",
"Export events as text/calendar VEVENT data.",
),
_permission(
CALENDAR_AVAILABILITY_READ_SCOPE,
"Read availability",
"Read free/busy and availability data for integrations.",
),
) )
ROLE_TEMPLATES = ( ROLE_TEMPLATES = (
@@ -405,11 +493,32 @@ def _tenant_summary(session, tenant_id: str) -> dict[str, int]:
) )
return { return {
"calendars": session.query(CalendarCollection).filter(CalendarCollection.tenant_id == tenant_id, CalendarCollection.deleted_at.is_(None)).count(), "calendars": session.query(CalendarCollection)
"calendar_events": session.query(CalendarEvent).filter(CalendarEvent.tenant_id == tenant_id, CalendarEvent.deleted_at.is_(None)).count(), .filter(
"calendar_sync_sources": session.query(CalendarSyncSource).filter(CalendarSyncSource.tenant_id == tenant_id, CalendarSyncSource.deleted_at.is_(None)).count(), CalendarCollection.tenant_id == tenant_id,
"calendar_sync_credentials": session.query(CalendarSyncCredential).filter(CalendarSyncCredential.tenant_id == tenant_id, CalendarSyncCredential.deleted_at.is_(None)).count(), CalendarCollection.deleted_at.is_(None),
"calendar_view_preferences": session.query(CalendarViewPreference).filter(CalendarViewPreference.tenant_id == tenant_id).count(), )
.count(),
"calendar_events": session.query(CalendarEvent)
.filter(
CalendarEvent.tenant_id == tenant_id, CalendarEvent.deleted_at.is_(None)
)
.count(),
"calendar_sync_sources": session.query(CalendarSyncSource)
.filter(
CalendarSyncSource.tenant_id == tenant_id,
CalendarSyncSource.deleted_at.is_(None),
)
.count(),
"calendar_sync_credentials": session.query(CalendarSyncCredential)
.filter(
CalendarSyncCredential.tenant_id == tenant_id,
CalendarSyncCredential.deleted_at.is_(None),
)
.count(),
"calendar_view_preferences": session.query(CalendarViewPreference)
.filter(CalendarViewPreference.tenant_id == tenant_id)
.count(),
"calendar_outbox_pending": session.query(CalendarOutboxOperation) "calendar_outbox_pending": session.query(CalendarOutboxOperation)
.filter( .filter(
CalendarOutboxOperation.tenant_id == tenant_id, CalendarOutboxOperation.tenant_id == tenant_id,
@@ -459,11 +568,20 @@ def _calendar_outbox_provider(context: ModuleContext) -> object:
def _calendar_external_profile_provider(context: ModuleContext) -> object: def _calendar_external_profile_provider(context: ModuleContext) -> object:
del context del context
from govoplan_calendar.backend.capabilities import SqlCalendarExternalProfileProvider from govoplan_calendar.backend.capabilities import (
SqlCalendarExternalProfileProvider,
)
return SqlCalendarExternalProfileProvider() return SqlCalendarExternalProfileProvider()
def _calendar_dsar_provider(context: ModuleContext) -> object:
del context
from govoplan_calendar.backend.dsar_provider import CalendarDsarProvider
return CalendarDsarProvider()
def _caldav_provider_states(context): def _caldav_provider_states(context):
from govoplan_calendar.backend.provider_state import caldav_provider_states from govoplan_calendar.backend.provider_state import caldav_provider_states
@@ -497,14 +615,28 @@ def _open_xchange_provider_states(context):
manifest = ModuleManifest( manifest = ModuleManifest(
id="calendar", id="calendar",
name="Calendar", name="Calendar",
version="0.1.18", version="0.1.20",
required_capabilities=(CAPABILITY_AUTH_PRINCIPAL_RESOLVER, CAPABILITY_AUTH_PERMISSION_EVALUATOR), required_capabilities=(
optional_dependencies=("mail", "tasks", "scheduling", "appointments", "workflow_engine", "notifications", "dms", "connectors", "search"), CAPABILITY_AUTH_PRINCIPAL_RESOLVER,
CAPABILITY_AUTH_PERMISSION_EVALUATOR,
),
optional_dependencies=(
"mail",
"tasks",
"scheduling",
"appointments",
"workflow_engine",
"notifications",
"dms",
"connectors",
"search",
),
provides_interfaces=( provides_interfaces=(
ModuleInterfaceProvider(name="calendar.outbox", version="0.1.8"), ModuleInterfaceProvider(name="calendar.outbox", version="0.1.8"),
ModuleInterfaceProvider(name="calendar.scheduling", version="0.1.8"), ModuleInterfaceProvider(name="calendar.scheduling", version="0.1.9"),
ModuleInterfaceProvider(name="calendar.invitations", version="0.2.0"), ModuleInterfaceProvider(name="calendar.invitations", version="0.2.0"),
ModuleInterfaceProvider(name="calendar.external_profiles", version="0.1.0"), ModuleInterfaceProvider(name="calendar.external_profiles", version="0.1.0"),
ModuleInterfaceProvider(name=CALENDAR_DSAR_CAPABILITY, version="0.1.0"),
), ),
requires_interfaces=( requires_interfaces=(
ModuleInterfaceRequirement( ModuleInterfaceRequirement(
@@ -554,6 +686,126 @@ manifest = ModuleManifest(
), ),
), ),
documentation=( documentation=(
DocumentationTopic(
id="calendar.privacy.data-subject-requests",
title="Review Calendar data in a data-subject request",
summary="Collect tenant-scoped event, participation, preference, synchronization, and migration metadata without disclosing connector secrets.",
body=(
"Calendar's DSAR provider searches the effective tenant by normalized organizer or attendee email, direct membership references, and namespaced Calendar collection or event references. "
"It returns only the matching organizer or attendee fragment alongside authorized event and collection context, personal view preferences, owned synchronization configuration, durable outbox outcomes, and migration evidence. It excludes raw ICS, complete iCalendar payloads, collection URLs, remote hrefs and ETags, sync tokens, credentials, encrypted secrets, worker leases, idempotency material, provider error text, and unrelated participants or events. "
"Synchronized, correlated, deleted, queued, and migrated state remains retained with a reason because it is institutional delivery, reconciliation, or recovery evidence. Local event, collection, and active credential metadata requires coordinated manual review. The provider can idempotently delete the subject's personal Calendar view preference after revalidating tenant and ownership; it never mutates an event, attendee list, synchronized resource, credential, or migration record directly."
),
layer="configured",
documentation_types=("admin",),
audience=(
"privacy_officer",
"calendar_manager",
"records_manager",
"operator",
),
order=17,
conditions=(
DocumentationCondition(
required_modules=("calendar", "access"),
any_scopes=(
"access:privacy:read",
"access:privacy:manage",
"access:privacy:erase",
),
),
),
links=(
DocumentationLink(
label="Data-subject requests",
href="/admin?section=tenant-data-subject-requests",
kind="runtime",
),
DocumentationLink(
label="Calendar integration concept",
href="govoplan-calendar/docs/CALENDAR_INTEGRATION_CONCEPT.md",
kind="repository",
),
),
related_modules=("access", "audit", "ops", "scheduling"),
translations={
"de": {
"title": "Calendar-Daten in einer Betroffenenanfrage prüfen",
"summary": (
"Mandantenbezogene Ereignis-, Teilnahme-, Präferenz-, Synchronisations- und Migrationsmetadaten erfassen, ohne "
"Connector-Geheimnisse offenzulegen."
),
"body": (
"Der DSAR-Provider von Calendar durchsucht den wirksamen Mandanten anhand normalisierter E-Mail-Adressen von "
"Organisierenden oder Teilnehmenden, direkter Mitgliedschaftsverweise und namensraumgebundener Calendar-Sammlungs- oder "
"Ereignisverweise. Er liefert nur den passenden Organisierenden- oder Teilnehmendenausschnitt zusammen mit berechtigtem "
"Ereignis- und Sammlungskontext, persönlichen Ansichtspräferenzen, eigener Synchronisationskonfiguration, dauerhaften "
"Outbox-Ergebnissen und Migrationsnachweisen. Ausgeschlossen sind rohe ICS- und vollständige iCalendar-Daten, "
"Sammlungs-URLs, entfernte hrefs und ETags, Synchronisationstoken, Zugangsdaten, verschlüsselte Geheimnisse, Worker-Leases, "
"Idempotenzmaterial, Provider-Fehlertexte sowie unbeteiligte Personen oder Ereignisse. Synchronisierte, korrelierte, "
"gelöschte, eingereihte und migrierte Zustände bleiben mit Begründung erhalten, weil sie institutionelle Liefer-, Abgleich- "
"oder Wiederherstellungsnachweise sind. Lokale Ereignis-, Sammlungs- und aktive Zugangsdatenmetadaten erfordern eine "
"koordinierte manuelle Prüfung. Nach erneuter Prüfung von Mandant und Eigentum darf der Provider die persönliche "
"Calendar-Ansichtspräferenz idempotent löschen; Ereignisse, Teilnehmerlisten, synchronisierte Ressourcen, Zugangsdaten "
"oder Migrationsdatensätze verändert er niemals direkt."
),
}
},
metadata={
"kind": "workflow",
"route": "/admin?section=tenant-data-subject-requests",
"screen": "Data-subject requests",
"help_contexts": ["admin.privacy.data-subject-requests"],
"prerequisites": [
"The privacy request and Calendar selectors have been independently authorized and corroborated.",
"The reviewer understands the effective Calendar retention and synchronization-evidence obligations.",
],
"steps": [
"Run the Calendar provider search and review the isolated event, participation, preference, sync, outbox, and migration records.",
"Keep every evidence retention reason with the case decision and coordinate any content change through Calendar lifecycle controls.",
"Execute only an approved personal view-preference deletion.",
"Review related Scheduling or Mail records through their owning DSAR providers when those modules are installed.",
],
"limitations": [
"Raw ICS and connector locators are not embedded in the JSON export; authorized Calendar review remains authoritative.",
"Event and attendee erasure is manual because recurrence, shared participation, external synchronization, and institutional retention can overlap.",
],
},
),
DocumentationTopic(
id="calendar.quick-access-and-product-area",
title="Calendar in product navigation and Quick Access",
summary="Use Calendar in Meetings and decisions and keep an optional compact agenda beside current work.",
body=(
"Calendar contributes its workspace to Meetings and decisions. When Quick Access is enabled, "
"the owner-rendered agenda shows at most seven authorized events across the current or explicitly selected temporal "
"context and links to the full workspace. Event selection returns a typed Calendar reference; accounts with event-write "
"permission can launch the full owner-rendered creation dialog at that date. Calendar rechecks tenant, scope, private "
"collection ownership or group membership, and the requested time range on every read. View and Quick Access settings "
"affect presentation only."
),
layer="configured",
documentation_types=("user", "admin"),
audience=("user", "calendar_manager", "administrator"),
related_modules=("quick_access", "views"),
translations={
"de": {
"title": "Kalender in Produktnavigation und Schnellzugriff",
"summary": "Den Kalender unter Termine und Entscheidungen sowie optional als kompakte Agenda neben der aktuellen Arbeit verwenden.",
"body": (
"Calendar ordnet seinen Arbeitsbereich Termine und Entscheidungen zu. Ist der Schnellzugriff aktiviert, "
"zeigt die vom Kalender gerenderte Agenda höchstens sieben berechtigte Termine im aktuellen oder ausdrücklich "
"gewählten Zeitkontext. Die Terminauswahl liefert eine typisierte Kalenderreferenz; mit Schreibberechtigung lässt "
"sich der vollständige Termineditor für dieses Datum öffnen. Calendar prüft Mandant, Berechtigung, private "
"Kalendereigentümerschaft beziehungsweise Gruppenmitgliedschaft und Zeitraum bei jedem Abruf erneut."
),
}
},
metadata={
"kind": "reference",
"help_contexts": ["calendar.quick_access.agenda"],
},
order=18,
),
DocumentationTopic( DocumentationTopic(
id="calendar.search.events", id="calendar.search.events",
title="Search authorized calendar events", title="Search authorized calendar events",
@@ -568,16 +820,48 @@ manifest = ModuleManifest(
documentation_types=("admin", "user"), documentation_types=("admin", "user"),
audience=("user", "calendar_manager", "administrator"), audience=("user", "calendar_manager", "administrator"),
related_modules=("search",), related_modules=("search",),
translations={
"de": {
"title": "Berechtigte Kalenderereignisse durchsuchen",
"summary": (
"Ereignistitel, Zeitpläne, Orte und Beschreibungen für die berechtigungsbewusste Plattform-Suche bereitstellen."
),
"body": (
"Ist Search installiert, liefert Calendar nicht gelöschte Ereignisse aus sichtbaren Kalendern. Jedes Ergebnis bleibt "
"mandantengebunden und prüft vor der Ausgabe erneut die aktuelle Leseberechtigung für Ereignisse sowie bei privaten "
"Kalendern Eigentum oder Gruppenmitgliedschaft. Festgeschriebene Ereignisänderungen aktualisieren den abgeleiteten Index "
"über die Plattform-Event-Outbox; ein Neuaufbau von Search verändert niemals Calendar-Daten."
),
}
},
order=19, order=19,
), ),
DocumentationTopic( DocumentationTopic(
id="calendar.manage-calendars-and-events", id="calendar.manage-calendars-and-events",
title="Use calendars and events", title="Use calendars and events",
summary="Create calendar collections and work with all-day or timed events in continuous, month, week, workweek, and day views.", summary="Create calendar collections and work with all-day or timed events in continuous, month, week, workweek, and day views.",
body="Calendar remembers the selected view and preferences. Events can be created, edited, moved, resized, repeated, imported, exported, or deleted when the current account has the corresponding permission. All-day events use dates rather than local clock times; timed events retain their timezone-aware start and end values.", body="Calendar remembers the selected view and preferences. Events can be created, edited, moved, resized, repeated, imported, exported, or deleted when the current account has the corresponding permission. All-day events use dates rather than local clock times; timed events retain their timezone-aware start and end values. Scheduling may promote a selected tentative hold in place and submit unused holds for idempotent release through the neutral Calendar capability. Calendar owns the resulting local tombstone, synchronized outbox operation, retry and reconciliation evidence; an already released or absent event is an accepted replay rather than a duplicate failure.",
documentation_types=("user",), documentation_types=("user",),
audience=("user", "calendar_manager"), audience=("user", "calendar_manager"),
related_modules=("scheduling", "notifications"), related_modules=("scheduling", "notifications"),
translations={
"de": {
"title": "Kalender und Ereignisse verwenden",
"summary": (
"Kalendersammlungen anlegen und ganztägige oder zeitgebundene Ereignisse in fortlaufender, Monats-, Wochen-, "
"Arbeitswochen- und Tagesansicht bearbeiten."
),
"body": (
"Calendar merkt sich gewählte Ansicht und Präferenzen. Ereignisse können mit der entsprechenden Berechtigung angelegt, "
"bearbeitet, verschoben, in ihrer Dauer geändert, wiederholt, importiert, exportiert oder gelöscht werden. Ganztägige "
"Ereignisse verwenden Datumswerte statt lokaler Uhrzeiten; zeitgebundene Ereignisse bewahren zeitzonenbezogene Start- und "
"Endwerte. Scheduling darf eine ausgewählte vorläufige Vormerkung direkt bestätigen und nicht verwendete Vormerkungen "
"über die neutrale Calendar-Fähigkeit idempotent freigeben. Calendar besitzt den entstehenden lokalen Löschmarker, die "
"synchronisierte Outbox-Operation sowie Wiederholungs- und Abgleichsnachweise; ein bereits freigegebenes oder fehlendes "
"Ereignis gilt bei Wiederholung als akzeptiert und nicht als doppelter Fehler."
),
}
},
metadata={ metadata={
"kind": "reference", "kind": "reference",
"help_contexts": [ "help_contexts": [
@@ -604,6 +888,29 @@ manifest = ModuleManifest(
documentation_types=("admin", "user"), documentation_types=("admin", "user"),
audience=("user", "calendar_manager", "operator"), audience=("user", "calendar_manager", "operator"),
related_modules=("connectors", "audit", "ops"), related_modules=("connectors", "audit", "ops"),
translations={
"de": {
"title": "Externe Kalender verbinden und synchronisieren",
"summary": (
"Calendar unterstützt lokale Sammlungen, bidirektionale CalDAV- und Open-Xchange-Profile sowie schreibgeschützte "
"ICS-/webcal-, Microsoft-Graph- und Exchange-Web-Services-Quellen."
),
"body": (
"Jede externe Quelle hält URL, Synchronisationsrichtung, Status und Zugangsdatenverweis gemeinsam mit der "
"Calendar-Sammlung. Open-Xchange verwendet den bewährten CalDAV-Transport und bewahrt dabei Connector-Profil-, "
"Identitäts-/Gruppenzuordnungs- und Ressourcenkalenderverweise. Manuelle und geplante Synchronisation zeichnet begrenzte "
"Ergebnisse auf. Geplante Quellen- und Outbox-Worker teilen Arbeit nach Mandantenberechtigung; wird Calendar deaktiviert, "
"bleiben angenommene Vorgänge erhalten und verlangen Betriebshandeln, statt einen entfernten Provider anzusprechen. "
"CalDAV-Schreibvorgänge verwenden bedingte Anfragen und dauerhaften Outbox-Zustand. Konflikte und unbekannte Ergebnisse "
"erfordern Synchronisation oder ausdrücklichen Abgleich statt blinder Wiederholung. Das Verschieben zwischen zwei "
"bidirektionalen CalDAV-Kalendern ist ein administrativ genehmigter Migrationsstapel: Alle Zielressourcen müssen kopiert "
"sein, bevor eine Quellressource bedingt mit ihrem aufgezeichneten ETag gelöscht wird. Änderungen an Kalender und "
"Ereignissen bleiben gesperrt, während Fortschritt, Konflikte, Abbruchmöglichkeit und Nachweise sichtbar sind. Das "
"Entfernen einer externen Quelle entfernt die Verbindung; das Löschen eines lokalen Kalenders löscht dessen Ereignisse "
"nach Bestätigung oder Übertragung."
),
}
},
metadata={ metadata={
"kind": "reference", "kind": "reference",
"help_contexts": [ "help_contexts": [
@@ -640,6 +947,23 @@ manifest = ModuleManifest(
), ),
), ),
related_modules=("campaigns", "mail", "audit"), related_modules=("campaigns", "mail", "audit"),
translations={
"de": {
"title": "Campaign-Einladungen und Antworten nachverfolgen",
"summary": (
"Akzeptierte Campaign-Einladungslieferungen als korrelierte VEVENTs spiegeln und den Teilnahmestatus in Calendar "
"maßgeblich halten."
),
"body": (
"Campaign kann vor der Zustellung einen METHOD:REQUEST-Anhang erzeugen und das korrelierte Calendar-Ereignis erst nach "
"Annahme der Lieferung anlegen oder aktualisieren. Calendar speichert Korrelation, PARTSTAT der Teilnehmenden, "
"Antwortzeit, begrenzte Nachweise, Synchronisationszustand und etwaiges eingeschränktes Verhalten. Beobachtet Mail einen "
"berechtigten IMAP-Ordner, werden METHOD:REPLY-Teile idempotent an Calendar weitergeleitet. Campaign-Berichte fragen den "
"aktuellen Zustand gesammelt ab, statt ihn in Campaign-Datensätze zu kopieren. Wiederkehrende Campaign-Einladungsserien "
"bleiben ein eigener Ablauf."
),
}
},
metadata={"kind": "workflow"}, metadata={"kind": "workflow"},
), ),
DocumentationTopic( DocumentationTopic(
@@ -657,6 +981,22 @@ manifest = ModuleManifest(
documentation_types=("admin", "user"), documentation_types=("admin", "user"),
audience=("calendar_manager", "operator", "tenant_admin"), audience=("calendar_manager", "operator", "tenant_admin"),
related_modules=("ops", "audit"), related_modules=("ops", "audit"),
translations={
"de": {
"title": "Synchronisierte Kalenderschreibvorgänge wiederherstellen",
"summary": (
"Ungelöste CalDAV-Schreibvorgänge prüfen und ausschließlich die neueste sichere Ressourcengeneration wiederherstellen."
),
"body": (
"Calendar-Administrierende öffnen Ausgehende Änderungen in den Einstellungen eines synchronisierten Kalenders. Die "
"begrenzte Historie erläutert Versuche, Konflikte, endgültig fehlgeschlagene Arbeit, veraltete Generationen, deaktivierte "
"Quellen und aktive Worker-Leases. Wiederholen reiht einen fehlgeschlagenen Sollzustand erneut ein, Abgleichen vergleicht "
"ihn mit der entfernten Ressource und Verwerfen gibt den lokalen Sollzustand nach einer getrennten Warnung auf, sodass die "
"nächste vollständige Synchronisation den entfernten Zustand übernehmen kann. Automatische Auslieferung und fällige "
"Quellenausführung bleiben reine Worker-Operationen für Dienstkonten und werden nicht als interaktive Steuerungen angeboten."
),
}
},
metadata={ metadata={
"kind": "runbook", "kind": "runbook",
"help_contexts": [ "help_contexts": [
@@ -674,8 +1014,26 @@ manifest = ModuleManifest(
CAPABILITY_CALENDAR_SCHEDULING: _calendar_scheduling_provider, CAPABILITY_CALENDAR_SCHEDULING: _calendar_scheduling_provider,
CAPABILITY_CALENDAR_INVITATIONS: _calendar_invitation_provider, CAPABILITY_CALENDAR_INVITATIONS: _calendar_invitation_provider,
CAPABILITY_CALENDAR_EXTERNAL_PROFILES: _calendar_external_profile_provider, CAPABILITY_CALENDAR_EXTERNAL_PROFILES: _calendar_external_profile_provider,
CALENDAR_DSAR_CAPABILITY: _calendar_dsar_provider,
}, },
nav_items=(NavItem(path="/calendar", label="Calendar", icon="calendar", required_any=("calendar:event:read",), order=55),), capability_documentation={
CALENDAR_DSAR_CAPABILITY: CapabilityDocumentation(
label="Calendar data-subject request provider",
summary="Finds isolated Calendar participation and lifecycle metadata and classifies governed erasure actions.",
contract_version="0.1.0",
documentation_types=("admin",),
audience=("privacy_officer", "calendar_manager", "records_manager"),
),
},
nav_items=(
NavItem(
path="/calendar",
label="Calendar",
icon="calendar",
required_any=("calendar:event:read",),
order=55,
),
),
frontend=FrontendModule( frontend=FrontendModule(
module_id="calendar", module_id="calendar",
package_name="@govoplan/calendar-webui", package_name="@govoplan/calendar-webui",
@@ -687,7 +1045,15 @@ manifest = ModuleManifest(
order=55, order=55,
), ),
), ),
nav_items=(NavItem(path="/calendar", label="Calendar", icon="calendar", required_any=("calendar:event:read",), order=55),), nav_items=(
NavItem(
path="/calendar",
label="Calendar",
icon="calendar",
required_any=("calendar:event:read",),
order=55,
),
),
view_surfaces=( view_surfaces=(
ViewSurface( ViewSurface(
id="calendar.navigation", id="calendar.navigation",
@@ -781,6 +1147,41 @@ manifest = ModuleManifest(
label="Calendar preferences", label="Calendar preferences",
order=45, order=45,
), ),
ViewSurface(
id="calendar.quick_access.agenda",
module_id="calendar",
kind="quick_access",
label="Calendar Quick Access",
order=50,
),
),
product_areas=(
ProductAreaContribution(
id="meetings-decisions",
module_id="calendar",
label="i18n:govoplan-core.product_area.meetings_decisions",
icon="calendar",
description="i18n:govoplan-core.product_area.meetings_decisions_description",
surface_ids=("calendar.nav.calendar", "calendar.route.calendar"),
order=50,
),
),
quick_access_tools=(
QuickAccessTool(
id="calendar.agenda",
module_id="calendar",
category_id="calendar",
label="i18n:govoplan-calendar.calendar.adab5090",
description="i18n:govoplan-calendar.quick_access_description",
surface_id="calendar.quick_access.agenda",
icon="calendar",
full_page_path="/calendar",
required_any=("calendar:event:read",),
order=10,
modes=("browse", "create"),
returned_reference_kinds=("calendar.event",),
help_context_id="calendar.quick_access.agenda",
),
), ),
), ),
migration_spec=MigrationSpec( migration_spec=MigrationSpec(
+71 -6
View File
@@ -221,6 +221,7 @@ def _visible_events_for_delta(
calendar_id: str | None, calendar_id: str | None,
start_at: datetime | None, start_at: datetime | None,
end_at: datetime | None, end_at: datetime | None,
visible_calendar_ids: set[str] | None = None,
) -> list[CalendarEvent]: ) -> list[CalendarEvent]:
if not event_ids: if not event_ids:
return [] return []
@@ -229,6 +230,10 @@ def _visible_events_for_delta(
CalendarEvent.id.in_(event_ids), CalendarEvent.id.in_(event_ids),
CalendarEvent.deleted_at.is_(None), CalendarEvent.deleted_at.is_(None),
) )
if visible_calendar_ids is not None:
if not visible_calendar_ids:
return []
query = query.filter(CalendarEvent.calendar_id.in_(visible_calendar_ids))
if calendar_id: if calendar_id:
query = query.filter(CalendarEvent.calendar_id == calendar_id) query = query.filter(CalendarEvent.calendar_id == calendar_id)
if start_at is not None: if start_at is not None:
@@ -246,8 +251,16 @@ def _full_event_delta_response(
calendar_id: str | None, calendar_id: str | None,
start_at: datetime | None, start_at: datetime | None,
end_at: datetime | None, end_at: datetime | None,
visible_calendar_ids: set[str] | None = None,
) -> CalendarEventDeltaResponse: ) -> CalendarEventDeltaResponse:
events = list_events(session, tenant_id=tenant_id, calendar_id=calendar_id, start_at=start_at, end_at=end_at) events = list_events(
session,
tenant_id=tenant_id,
calendar_id=calendar_id,
start_at=start_at,
end_at=end_at,
visible_calendar_ids=visible_calendar_ids,
)
return CalendarEventDeltaResponse( return CalendarEventDeltaResponse(
events=[_event_response(event) for event in events], events=[_event_response(event) for event in events],
deleted=[], deleted=[],
@@ -257,6 +270,37 @@ def _full_event_delta_response(
) )
def _principal_visible_calendar_ids(
session: Session,
principal: ApiPrincipal,
) -> set[str]:
return {
calendar.id
for calendar in list_calendars(
session,
tenant_id=principal.tenant_id,
user_id=principal.user.id,
group_ids=principal.group_ids,
can_admin=principal.has("calendar:calendar:admin"),
)
}
def _event_entry_matches_visible_calendars(
entry,
visible_calendar_ids: set[str],
) -> bool:
payload = entry.payload or {}
return any(
calendar_id in visible_calendar_ids
for calendar_id in (
payload.get("calendar_id"),
payload.get("previous_calendar_id"),
)
if isinstance(calendar_id, str)
)
def _event_delta_entries(session: Session, *, tenant_id: str, since: str, limit: int): def _event_delta_entries(session: Session, *, tenant_id: str, since: str, limit: int):
try: try:
since_sequence = decode_sequence_watermark(since) since_sequence = decode_sequence_watermark(since)
@@ -858,10 +902,12 @@ def api_list_events(
start_at: datetime | None = Query(default=None), start_at: datetime | None = Query(default=None),
end_at: datetime | None = Query(default=None), end_at: datetime | None = Query(default=None),
expand_recurring: bool = Query(default=False), expand_recurring: bool = Query(default=False),
limit: int | None = Query(default=None, ge=1, le=500),
principal: ApiPrincipal = Depends(get_api_principal), principal: ApiPrincipal = Depends(get_api_principal),
session: Session = Depends(get_session), session: Session = Depends(get_session),
): ):
_require_scope(principal, "calendar:event:read") _require_scope(principal, "calendar:event:read")
visible_calendar_ids = _principal_visible_calendar_ids(session, principal)
if expand_recurring: if expand_recurring:
if start_at is None or end_at is None: if start_at is None or end_at is None:
raise HTTPException( raise HTTPException(
@@ -878,6 +924,8 @@ def api_list_events(
calendar_id=calendar_id, calendar_id=calendar_id,
start_at=start_at, start_at=start_at,
end_at=end_at, end_at=end_at,
visible_calendar_ids=visible_calendar_ids,
limit=limit,
) )
return CalendarEventListResponse( return CalendarEventListResponse(
events=[ events=[
@@ -890,7 +938,15 @@ def api_list_events(
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
detail=str(exc), detail=str(exc),
) from exc ) from exc
events = list_events(session, tenant_id=principal.tenant_id, calendar_id=calendar_id, start_at=start_at, end_at=end_at) events = list_events(
session,
tenant_id=principal.tenant_id,
calendar_id=calendar_id,
start_at=start_at,
end_at=end_at,
visible_calendar_ids=visible_calendar_ids,
limit=limit,
)
return CalendarEventListResponse(events=[_event_response(event) for event in events]) return CalendarEventListResponse(events=[_event_response(event) for event in events])
@@ -905,15 +961,18 @@ def api_list_events_delta(
session: Session = Depends(get_session), session: Session = Depends(get_session),
): ):
_require_scope(principal, "calendar:event:read") _require_scope(principal, "calendar:event:read")
visible_calendar_ids = _principal_visible_calendar_ids(session, principal)
if since is None: if since is None:
return _full_event_delta_response(session, tenant_id=principal.tenant_id, calendar_id=calendar_id, start_at=start_at, end_at=end_at) return _full_event_delta_response(session, tenant_id=principal.tenant_id, calendar_id=calendar_id, start_at=start_at, end_at=end_at, visible_calendar_ids=visible_calendar_ids)
entries, has_more = _event_delta_entries(session, tenant_id=principal.tenant_id, since=since, limit=limit) entries, has_more = _event_delta_entries(session, tenant_id=principal.tenant_id, since=since, limit=limit)
if entries is None: if entries is None:
return _full_event_delta_response(session, tenant_id=principal.tenant_id, calendar_id=calendar_id, start_at=start_at, end_at=end_at) return _full_event_delta_response(session, tenant_id=principal.tenant_id, calendar_id=calendar_id, start_at=start_at, end_at=end_at, visible_calendar_ids=visible_calendar_ids)
scoped_entries = [ scoped_entries = [
entry entry
for entry in entries for entry in entries
if entry.resource_type == CALENDAR_EVENT_RESOURCE and _event_payload_matches_window(entry, calendar_id=calendar_id, start_at=start_at, end_at=end_at) if entry.resource_type == CALENDAR_EVENT_RESOURCE
and _event_payload_matches_window(entry, calendar_id=calendar_id, start_at=start_at, end_at=end_at)
and _event_entry_matches_visible_calendars(entry, visible_calendar_ids)
] ]
changed_ids = list(dict.fromkeys(entry.resource_id for entry in scoped_entries if entry.operation != "deleted")) changed_ids = list(dict.fromkeys(entry.resource_id for entry in scoped_entries if entry.operation != "deleted"))
visible_events = _visible_events_for_delta( visible_events = _visible_events_for_delta(
@@ -923,6 +982,7 @@ def api_list_events_delta(
calendar_id=calendar_id, calendar_id=calendar_id,
start_at=start_at, start_at=start_at,
end_at=end_at, end_at=end_at,
visible_calendar_ids=visible_calendar_ids,
) )
visible_ids = {event.id for event in visible_events} visible_ids = {event.id for event in visible_events}
deleted = [ deleted = [
@@ -970,7 +1030,10 @@ def api_get_event(
): ):
_require_scope(principal, "calendar:event:read") _require_scope(principal, "calendar:event:read")
try: try:
return _event_response(get_event(session, tenant_id=principal.tenant_id, event_id=event_id)) event = get_event(session, tenant_id=principal.tenant_id, event_id=event_id)
if event.calendar_id not in _principal_visible_calendar_ids(session, principal):
raise CalendarError("Calendar event not found")
return _event_response(event)
except CalendarError as exc: except CalendarError as exc:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)) from exc raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)) from exc
@@ -1154,6 +1217,8 @@ def api_export_ics_event(
_require_scope(principal, "calendar:event:export") _require_scope(principal, "calendar:event:export")
try: try:
event = get_event(session, tenant_id=principal.tenant_id, event_id=event_id) event = get_event(session, tenant_id=principal.tenant_id, event_id=event_id)
if event.calendar_id not in _principal_visible_calendar_ids(session, principal):
raise CalendarError("Calendar event not found")
except CalendarError as exc: except CalendarError as exc:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)) from exc raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)) from exc
ics = event.raw_ics or event_to_ics(event) ics = event.raw_ics or event_to_ics(event)
+22 -2
View File
@@ -3829,15 +3829,25 @@ def list_events(
calendar_id: str | None = None, calendar_id: str | None = None,
start_at: datetime | None = None, start_at: datetime | None = None,
end_at: datetime | None = None, end_at: datetime | None = None,
visible_calendar_ids: Iterable[str] | None = None,
limit: int | None = None,
) -> list[CalendarEvent]: ) -> list[CalendarEvent]:
query = session.query(CalendarEvent).filter(CalendarEvent.tenant_id == tenant_id, CalendarEvent.deleted_at.is_(None)) query = session.query(CalendarEvent).filter(CalendarEvent.tenant_id == tenant_id, CalendarEvent.deleted_at.is_(None))
if visible_calendar_ids is not None:
normalized_calendar_ids = tuple(dict.fromkeys(visible_calendar_ids))
if not normalized_calendar_ids:
return []
query = query.filter(CalendarEvent.calendar_id.in_(normalized_calendar_ids))
if calendar_id: if calendar_id:
query = query.filter(CalendarEvent.calendar_id == calendar_id) query = query.filter(CalendarEvent.calendar_id == calendar_id)
if start_at is not None: if start_at is not None:
query = query.filter(or_(CalendarEvent.end_at.is_(None), CalendarEvent.end_at >= normalize_datetime(start_at))) query = query.filter(or_(CalendarEvent.end_at.is_(None), CalendarEvent.end_at >= normalize_datetime(start_at)))
if end_at is not None: if end_at is not None:
query = query.filter(CalendarEvent.start_at <= normalize_datetime(end_at)) query = query.filter(CalendarEvent.start_at <= normalize_datetime(end_at))
return query.order_by(CalendarEvent.start_at.asc(), CalendarEvent.summary.asc()).all() query = query.order_by(CalendarEvent.start_at.asc(), CalendarEvent.summary.asc())
if limit is not None:
query = query.limit(max(1, limit))
return query.all()
def list_event_occurrences( def list_event_occurrences(
@@ -3847,6 +3857,8 @@ def list_event_occurrences(
start_at: datetime, start_at: datetime,
end_at: datetime, end_at: datetime,
calendar_id: str | None = None, calendar_id: str | None = None,
visible_calendar_ids: Iterable[str] | None = None,
limit: int | None = None,
) -> list[dict[str, Any]]: ) -> list[dict[str, Any]]:
"""Return range-bounded events with recurring series fully reconciled.""" """Return range-bounded events with recurring series fully reconciled."""
@@ -3863,6 +3875,13 @@ def list_event_occurrences(
CalendarEvent.tenant_id == tenant_id, CalendarEvent.tenant_id == tenant_id,
CalendarEvent.deleted_at.is_(None), CalendarEvent.deleted_at.is_(None),
) )
if visible_calendar_ids is not None:
normalized_calendar_ids = tuple(dict.fromkeys(visible_calendar_ids))
if not normalized_calendar_ids:
return []
base_query = base_query.filter(
CalendarEvent.calendar_id.in_(normalized_calendar_ids)
)
if calendar_id: if calendar_id:
base_query = base_query.filter(CalendarEvent.calendar_id == calendar_id) base_query = base_query.filter(CalendarEvent.calendar_id == calendar_id)
@@ -3991,7 +4010,7 @@ def list_event_occurrences(
is_override=is_override, is_override=is_override,
) )
) )
return sorted( sorted_results = sorted(
results, results,
key=lambda item: ( key=lambda item: (
item["start_at"], item["start_at"],
@@ -4000,6 +4019,7 @@ def list_event_occurrences(
item["instance_id"], item["instance_id"],
), ),
) )
return sorted_results[: max(1, limit)] if limit is not None else sorted_results
def event_overlaps_range( def event_overlaps_range(
+76 -4
View File
@@ -1,7 +1,7 @@
from __future__ import annotations from __future__ import annotations
import unittest import unittest
from datetime import datetime, timezone from datetime import datetime, timedelta, timezone
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker
@@ -28,11 +28,29 @@ from govoplan_tenancy.backend.db.models import Tenant
class CalendarSchedulingCapabilityTests(unittest.TestCase): class CalendarSchedulingCapabilityTests(unittest.TestCase):
def test_event_request_validation_is_exposed_as_capability_error(self) -> None: def setUp(self) -> None:
provider = SqlCalendarSchedulingProvider() self.engine = create_engine("sqlite:///:memory:")
create_scope_tables(self.engine)
Base.metadata.create_all(bind=self.engine)
self.Session = sessionmaker(bind=self.engine)
self.session = self.Session()
self.session.add(Tenant(id="tenant-1", slug="tenant-1", name="Tenant"))
self.calendar = create_calendar(
self.session,
tenant_id="tenant-1",
user_id=None,
payload=CalendarCollectionCreateRequest(name="Scheduling"),
)
self.provider = SqlCalendarSchedulingProvider()
def tearDown(self) -> None:
self.session.close()
Base.metadata.drop_all(bind=self.engine)
self.engine.dispose()
def test_event_request_validation_is_exposed_as_capability_error(self) -> None:
with self.assertRaises(CalendarCapabilityError): with self.assertRaises(CalendarCapabilityError):
provider.create_event( self.provider.create_event(
object(), object(),
tenant_id="tenant-1", tenant_id="tenant-1",
user_id="user-1", user_id="user-1",
@@ -42,6 +60,60 @@ class CalendarSchedulingCapabilityTests(unittest.TestCase):
), ),
) )
def test_hold_promotion_and_release_are_idempotent(self) -> None:
start = datetime(2026, 7, 20, 9, tzinfo=timezone.utc)
hold = self.provider.create_event(
self.session,
tenant_id="tenant-1",
user_id="user-1",
request=CalendarEventRequest(
calendar_id=self.calendar.id,
summary="Tentative hold",
status="TENTATIVE",
start_at=start,
end_at=start + timedelta(hours=1),
metadata={"scheduling_request_id": "request-1"},
),
)
promoted = self.provider.promote_event(
self.session,
tenant_id="tenant-1",
user_id="user-1",
event_id=hold.id,
request=CalendarEventRequest(
calendar_id=self.calendar.id,
summary="Confirmed meeting",
status="CONFIRMED",
start_at=start,
end_at=start + timedelta(hours=1),
metadata={"scheduling_request_id": "request-1"},
),
)
released = self.provider.release_event(
self.session,
tenant_id="tenant-1",
user_id="user-1",
event_id=promoted.id,
)
replayed = self.provider.release_event(
self.session,
tenant_id="tenant-1",
user_id="user-1",
event_id=promoted.id,
)
absent = self.provider.release_event(
self.session,
tenant_id="tenant-1",
user_id="user-1",
event_id="missing-event",
)
self.assertEqual(promoted.id, hold.id)
self.assertEqual("CONFIRMED", self.session.get(CalendarEvent, hold.id).status)
self.assertFalse(released.already_released)
self.assertTrue(replayed.already_released)
self.assertEqual("not_found", absent.external_state)
class CalendarExternalProfileCapabilityTests(unittest.TestCase): class CalendarExternalProfileCapabilityTests(unittest.TestCase):
def setUp(self) -> None: def setUp(self) -> None:
+597
View File
@@ -0,0 +1,597 @@
from __future__ import annotations
import unittest
from datetime import datetime, timezone
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from govoplan_access.backend.db.models import Account, Group, User
from govoplan_calendar.backend.db.models import (
CalendarCollection,
CalendarEvent,
CalendarMigrationBatch,
CalendarMigrationResource,
CalendarOutboxOperation,
CalendarSyncCredential,
CalendarSyncSource,
CalendarViewPreference,
)
from govoplan_calendar.backend.dsar_provider import (
CALENDAR_DSAR_CAPABILITY,
CalendarDsarProvider,
)
from govoplan_calendar.backend.manifest import manifest
from govoplan_core.core.change_sequence import ChangeSequenceEntry
from govoplan_core.core.dsar import DsarProvider, DsarSubjectRef
from govoplan_core.db.base import Base
from govoplan_core.privacy.dsar_workflow import (
DataSubjectRequest,
create_data_subject_request,
execute_data_subject_erasure,
plan_data_subject_erasure,
search_data_subject_request,
)
class _Registry:
def __init__(
self,
provider: CalendarDsarProvider,
*,
calendar_active: bool = True,
) -> None:
self.provider = provider
self.calendar_active = calendar_active
def capability_names(self):
return (CALENDAR_DSAR_CAPABILITY,)
def capability_owner(self, name):
self._assert_capability(name)
return "calendar"
def tenant_entitlement_resolver(self):
calendar_active = self.calendar_active
class _Resolver:
@staticmethod
def resolve(session, tenant_id):
del session, tenant_id
return type(
"State",
(),
{"effective_modules": ("calendar",) if calendar_active else ()},
)()
return _Resolver()
def require_tenant_capability(self, name, session, **kwargs):
del session, kwargs
self._assert_capability(name)
return self.provider
def manifests(self):
return (type("Manifest", (), {"id": "calendar"})(),)
@staticmethod
def _assert_capability(name: str) -> None:
if name != CALENDAR_DSAR_CAPABILITY:
raise KeyError(name)
class CalendarDsarProviderTests(unittest.TestCase):
def setUp(self) -> None:
self.engine = create_engine("sqlite:///:memory:", future=True)
Base.metadata.create_all(
bind=self.engine,
tables=[
Account.__table__,
User.__table__,
Group.__table__,
ChangeSequenceEntry.__table__,
DataSubjectRequest.__table__,
CalendarCollection.__table__,
CalendarEvent.__table__,
CalendarViewPreference.__table__,
CalendarSyncSource.__table__,
CalendarSyncCredential.__table__,
CalendarOutboxOperation.__table__,
CalendarMigrationBatch.__table__,
CalendarMigrationResource.__table__,
],
)
self.session = sessionmaker(bind=self.engine, future=True)()
now = datetime.now(timezone.utc)
account = Account(
id="account-1",
email="subject@example.test",
normalized_email="subject@example.test",
display_name="Subject",
)
other_account = Account(
id="account-2",
email="other@example.test",
normalized_email="other@example.test",
display_name="Other",
)
self.user = User(
id="membership-1",
tenant_id="tenant-1",
account_id=account.id,
email="subject@example.test",
display_name="Subject",
)
other_user = User(
id="membership-2",
tenant_id="tenant-1",
account_id=other_account.id,
email="other@example.test",
display_name="Other",
)
self.collection = CalendarCollection(
id="calendar-subject",
tenant_id="tenant-1",
slug="subject-calendar",
name="Subject calendar",
description="Subject-owned calendar",
owner_type="user",
owner_id=self.user.id,
visibility="private",
created_by_user_id=self.user.id,
metadata_={"secret": "collection-secret-do-not-export"},
)
target_collection = CalendarCollection(
id="calendar-target",
tenant_id="tenant-1",
slug="target-calendar",
name="Target calendar",
owner_type="user",
owner_id=self.user.id,
visibility="private",
created_by_user_id=self.user.id,
)
other_collection = CalendarCollection(
id="calendar-other",
tenant_id="tenant-1",
slug="other-calendar",
name="Other calendar",
owner_type="user",
owner_id=other_user.id,
visibility="private",
created_by_user_id=other_user.id,
)
tenant_two_collection = CalendarCollection(
id="calendar-tenant-2",
tenant_id="tenant-2",
slug="tenant-two",
name="Tenant two secret calendar",
owner_type="tenant",
visibility="tenant",
)
self.event = CalendarEvent(
id="event-subject",
tenant_id="tenant-1",
calendar_id=self.collection.id,
uid="subject-event@example.test",
summary="Subject appointment",
description="Information visible to the subject",
location="Town hall",
start_at=now,
end_at=now,
organizer={
"value": "mailto:organizer@example.test",
"params": {"CN": ["Organizer"]},
},
attendees=[
{
"value": "mailto:Subject@Example.Test",
"params": {"CN": ["Subject"], "PARTSTAT": ["ACCEPTED"]},
},
{
"value": "mailto:other@example.test",
"params": {"CN": ["Unrelated Person"]},
},
],
categories=["citizen-service"],
reminders=[{"minutes": 15, "token": "reminder-secret-do-not-export"}],
attachments=[{"href": "/private/attachment-do-not-export"}],
source_kind="caldav",
source_href="/remote/event-do-not-export.ics",
etag="event-etag-do-not-export",
raw_ics="raw-ics-do-not-export",
icalendar={"private": "icalendar-object-do-not-export"},
metadata_={"secret": "event-secret-do-not-export"},
)
unrelated_event = CalendarEvent(
id="event-other",
tenant_id="tenant-1",
calendar_id=self.collection.id,
uid="unrelated@example.test",
summary="Unrelated event do not export",
description="Unrelated event body do not export",
start_at=now,
end_at=now,
organizer={"value": "mailto:other@example.test"},
attendees=[],
)
tenant_two_event = CalendarEvent(
id="event-tenant-2",
tenant_id="tenant-2",
calendar_id=tenant_two_collection.id,
uid="tenant-two@example.test",
summary="Tenant two event do not export",
start_at=now,
end_at=now,
organizer={"value": "mailto:subject@example.test"},
attendees=[],
)
self.source = CalendarSyncSource(
id="source-subject",
tenant_id="tenant-1",
calendar_id=self.collection.id,
source_kind="caldav",
collection_url="https://private.example.test/calendar-do-not-export",
display_name="Subject CalDAV",
auth_type="basic",
username="connector-user-do-not-export",
credential_ref="credential-ref-do-not-export",
sync_token="sync-token-do-not-export",
ctag="ctag-do-not-export",
last_status="failed",
last_error="provider-error-do-not-export",
metadata_={"secret": "source-secret-do-not-export"},
)
target_source = CalendarSyncSource(
id="source-target",
tenant_id="tenant-1",
calendar_id=target_collection.id,
source_kind="caldav",
collection_url="https://private.example.test/target-do-not-export",
display_name="Target CalDAV",
auth_type="none",
)
credential = CalendarSyncCredential(
id="credential-subject",
tenant_id="tenant-1",
credential_kind="basic",
label="Subject credential",
secret_encrypted="ciphertext-do-not-export",
created_by_user_id=self.user.id,
metadata_={"password": "credential-password-do-not-export"},
)
self.preference = CalendarViewPreference(
id="preference-subject",
tenant_id="tenant-1",
user_id=self.user.id,
dim_weekends=True,
workday_start_hour=8,
workday_end_hour=17,
)
operation = CalendarOutboxOperation(
id="operation-subject",
tenant_id="tenant-1",
source_id=self.source.id,
event_id=self.event.id,
operation_kind="put",
resource_href="/private/outbox-href-do-not-export",
payload_ics="outbox-payload-do-not-export",
payload_fingerprint="a" * 64,
expected_etag="expected-etag-do-not-export",
idempotency_key="idempotency-do-not-export",
status="succeeded",
available_at=now,
lease_token="lease-do-not-export",
remote_etag="remote-etag-do-not-export",
last_error="outbox-error-do-not-export",
metadata_={"secret": "outbox-secret-do-not-export"},
)
migration = CalendarMigrationBatch(
id="migration-subject",
tenant_id="tenant-1",
status="active",
phase="copying_destination",
source_calendar_id=self.collection.id,
target_calendar_id=target_collection.id,
source_sync_source_id=self.source.id,
target_sync_source_id=target_source.id,
total_resources=1,
total_events=1,
created_by_user_id=self.user.id,
authorization_evidence={"secret": "authorization-do-not-export"},
last_error="migration-error-do-not-export",
)
migration_resource = CalendarMigrationResource(
id="migration-resource-subject",
tenant_id="tenant-1",
batch_id=migration.id,
source_href="/source/private-do-not-export",
source_expected_etag="source-etag-do-not-export",
destination_href="/destination/private-do-not-export",
event_ids=[self.event.id],
status="copy_pending",
last_error="resource-error-do-not-export",
)
self.session.add_all(
[
account,
other_account,
self.user,
other_user,
self.collection,
target_collection,
other_collection,
tenant_two_collection,
self.event,
unrelated_event,
tenant_two_event,
self.source,
target_source,
credential,
self.preference,
operation,
migration,
migration_resource,
]
)
self.session.commit()
self.provider = CalendarDsarProvider()
self.subject = DsarSubjectRef(
membership_id=self.user.id,
email="subject@example.test",
)
def tearDown(self) -> None:
self.session.close()
self.engine.dispose()
def test_manifest_publishes_protocol_conforming_provider(self) -> None:
provided_names = {item.name for item in manifest.provides_interfaces}
self.assertIn(CALENDAR_DSAR_CAPABILITY, provided_names)
provider = manifest.capability_factories[CALENDAR_DSAR_CAPABILITY](None)
self.assertIsInstance(provider, DsarProvider)
self.assertIn(
"calendar.privacy.data-subject-requests",
{topic.id for topic in manifest.documentation},
)
def test_search_is_tenant_scoped_minimized_and_party_specific(self) -> None:
records = self._records()
resource_types = {record.resource_type for record in records}
self.assertTrue(
{
"calendar_collection",
"calendar_event",
"calendar_view_preference",
"calendar_sync_credential",
"calendar_sync_source",
"calendar_outbox_operation",
"calendar_migration_batch",
"calendar_migration_resource",
}.issubset(resource_types)
)
event = next(
record for record in records if record.resource_type == "calendar_event"
)
self.assertEqual(
"subject@example.test",
event.data["matching_attendees"][0]["email"],
)
self.assertEqual([], event.data["organizer"] or [])
serialized = repr([record.to_dict() for record in records])
for hidden in (
"event-other",
"Unrelated event do not export",
"Unrelated event body do not export",
"other@example.test",
"Unrelated Person",
"event-tenant-2",
"Tenant two event do not export",
"raw-ics-do-not-export",
"icalendar-object-do-not-export",
"/remote/event-do-not-export.ics",
"event-etag-do-not-export",
"/private/attachment-do-not-export",
"collection-secret-do-not-export",
"event-secret-do-not-export",
"reminder-secret-do-not-export",
"calendar-do-not-export",
"connector-user-do-not-export",
"credential-ref-do-not-export",
"sync-token-do-not-export",
"ctag-do-not-export",
"provider-error-do-not-export",
"source-secret-do-not-export",
"ciphertext-do-not-export",
"credential-password-do-not-export",
"outbox-href-do-not-export",
"outbox-payload-do-not-export",
"expected-etag-do-not-export",
"idempotency-do-not-export",
"lease-do-not-export",
"remote-etag-do-not-export",
"outbox-error-do-not-export",
"authorization-do-not-export",
"migration-error-do-not-export",
"/source/private-do-not-export",
"source-etag-do-not-export",
"/destination/private-do-not-export",
"resource-error-do-not-export",
):
self.assertNotIn(hidden, serialized)
def test_conflicting_email_references_fail_closed_for_attendee_data(self) -> None:
records = self.provider.search_subject(
self.session,
tenant_id="tenant-1",
subject=DsarSubjectRef(
email="subject@example.test",
external_references={"calendar.email": "other@example.test"},
),
)
self.assertEqual((), records)
def test_plan_retains_evidence_and_only_executes_preference_deletion(self) -> None:
records = self._records()
actions = self.provider.plan_erasure(
self.session,
tenant_id="tenant-1",
subject=self.subject,
records=records,
)
self.assertTrue({"retain", "manual_review"}.issubset({a.kind for a in actions}))
self.assertTrue(
any(
action.action_id == "calendar:retain:calendar_event:event-subject"
for action in actions
)
)
self.assertEqual(
{"calendar:delete:calendar_view_preference:preference-subject"},
{action.action_id for action in actions if action.executable},
)
def test_execution_is_revalidated_tenant_bound_and_idempotent(self) -> None:
action = self._preference_delete_action()
wrong_tenant = self.provider.execute_erasure(
self.session,
tenant_id="tenant-2",
subject=self.subject,
actions=(action,),
request_id="dsar-wrong-tenant",
)
self.assertEqual("blocked", wrong_tenant[0].status)
first = self.provider.execute_erasure(
self.session,
tenant_id="tenant-1",
subject=self.subject,
actions=(action,),
request_id="dsar-calendar-1",
)
self.assertEqual("executed", first[0].status)
self.assertIsNone(self.session.get(CalendarViewPreference, self.preference.id))
repeated = self.provider.execute_erasure(
self.session,
tenant_id="tenant-1",
subject=self.subject,
actions=(action,),
request_id="dsar-calendar-1",
)
self.assertEqual("unchanged", repeated[0].status)
def test_execution_blocks_when_preference_owner_changed_after_planning(
self,
) -> None:
action = self._preference_delete_action()
self.preference.user_id = "membership-2"
self.session.flush()
result = self.provider.execute_erasure(
self.session,
tenant_id="tenant-1",
subject=self.subject,
actions=(action,),
request_id="dsar-stale",
)
self.assertEqual("blocked", result[0].status)
self.assertIsNotNone(
self.session.get(CalendarViewPreference, self.preference.id)
)
def test_core_workflow_discovers_active_provider_and_skips_it_when_disabled(
self,
) -> None:
request = create_data_subject_request(
self.session,
tenant_id="tenant-1",
reference="DSAR-CALENDAR-1",
request_kind="access_and_erasure",
subject=self.subject,
purpose="Respond to an authorized privacy request.",
legal_basis="Article 15 and 17 GDPR",
due_at=None,
requested_by_account_id="privacy-officer",
)
self.session.commit()
registry = _Registry(self.provider)
search_data_subject_request(
self.session,
registry=registry,
row=request,
expected_revision=1,
)
self.assertEqual("searched", request.status)
self.assertEqual(["calendar"], request.coverage["covered_modules"])
plan_data_subject_erasure(
self.session,
registry=registry,
row=request,
expected_revision=2,
)
executable_ids = [
action["action_id"]
for action in request.erasure_plan["actions"]
if action["executable"]
]
execute_data_subject_erasure(
self.session,
registry=registry,
row=request,
expected_revision=3,
action_ids=executable_ids,
)
self.assertEqual("completed", request.status)
disabled = create_data_subject_request(
self.session,
tenant_id="tenant-1",
reference="DSAR-CALENDAR-DISABLED",
request_kind="access",
subject=self.subject,
purpose="Verify disabled-module coverage.",
legal_basis="Article 15 GDPR",
due_at=None,
requested_by_account_id="privacy-officer",
)
search_data_subject_request(
self.session,
registry=_Registry(self.provider, calendar_active=False),
row=disabled,
expected_revision=1,
)
self.assertEqual(0, disabled.search_result["record_count"])
self.assertEqual(
[CALENDAR_DSAR_CAPABILITY],
disabled.coverage["inactive_provider_capabilities"],
)
def _records(self):
return self.provider.search_subject(
self.session,
tenant_id="tenant-1",
subject=self.subject,
)
def _preference_delete_action(self):
return next(
action
for action in self.provider.plan_erasure(
self.session,
tenant_id="tenant-1",
subject=self.subject,
records=self._records(),
)
if action.resource_type == "calendar_view_preference" and action.executable
)
if __name__ == "__main__":
unittest.main()
+62 -10
View File
@@ -10,6 +10,14 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
class CalendarInterfaceDocumentationContractTests(unittest.TestCase): class CalendarInterfaceDocumentationContractTests(unittest.TestCase):
def test_all_static_topics_have_complete_german_content(self) -> None:
for topic in get_manifest().documentation:
german = (topic.translations or {}).get("de", {})
self.assertEqual({"title", "summary", "body"}, set(german), topic.id)
self.assertTrue(
all(str(value).strip() for value in german.values()), topic.id
)
def test_backend_surfaces_and_hierarchy_remain_declared(self) -> None: def test_backend_surfaces_and_hierarchy_remain_declared(self) -> None:
frontend = get_manifest().frontend frontend = get_manifest().frontend
self.assertIsNotNone(frontend) self.assertIsNotNone(frontend)
@@ -26,17 +34,26 @@ class CalendarInterfaceDocumentationContractTests(unittest.TestCase):
"calendar.outbox", "calendar.outbox",
"calendar.migration", "calendar.migration",
"calendar.settings.preferences", "calendar.settings.preferences",
"calendar.quick_access.agenda",
"calendar.widget.upcoming", "calendar.widget.upcoming",
} }
self.assertEqual(expected, set(surfaces)) self.assertEqual(expected, set(surfaces))
self.assertEqual("calendar.page", surfaces["calendar.page.sidebar"].parent_id) self.assertEqual("calendar.page", surfaces["calendar.page.sidebar"].parent_id)
self.assertEqual("calendar.page.sidebar", surfaces["calendar.page.agenda"].parent_id) self.assertEqual(
"calendar.page.sidebar", surfaces["calendar.page.agenda"].parent_id
)
self.assertEqual("calendar.page", surfaces["calendar.page.workspace"].parent_id) self.assertEqual("calendar.page", surfaces["calendar.page.workspace"].parent_id)
self.assertEqual("calendar.page", surfaces["calendar.event-editor"].parent_id) self.assertEqual("calendar.page", surfaces["calendar.event-editor"].parent_id)
self.assertEqual("calendar.page.sidebar", surfaces["calendar.collection-editor"].parent_id) self.assertEqual(
self.assertEqual("calendar.collection-editor", surfaces["calendar.sync-status"].parent_id) "calendar.page.sidebar", surfaces["calendar.collection-editor"].parent_id
)
self.assertEqual(
"calendar.collection-editor", surfaces["calendar.sync-status"].parent_id
)
self.assertEqual("calendar.sync-status", surfaces["calendar.outbox"].parent_id) self.assertEqual("calendar.sync-status", surfaces["calendar.outbox"].parent_id)
self.assertEqual("calendar.sync-status", surfaces["calendar.migration"].parent_id) self.assertEqual(
"calendar.sync-status", surfaces["calendar.migration"].parent_id
)
def test_help_and_consequence_metadata_remain_published(self) -> None: def test_help_and_consequence_metadata_remain_published(self) -> None:
topics = {topic.id: topic for topic in get_manifest().documentation} topics = {topic.id: topic for topic in get_manifest().documentation}
@@ -53,14 +70,49 @@ class CalendarInterfaceDocumentationContractTests(unittest.TestCase):
self.assertIn("calendar.outbox", recovery.metadata["help_contexts"]) self.assertIn("calendar.outbox", recovery.metadata["help_contexts"])
self.assertIn("reconcile_outbox", recovery.metadata["consequence_classes"]) self.assertIn("reconcile_outbox", recovery.metadata["consequence_classes"])
def test_webui_uses_shared_help_guard_and_confirmation_components(self) -> None: quick_tool = get_manifest().frontend.quick_access_tools[0]
event_dialog = (REPO_ROOT / "webui/src/features/calendar/CalendarEventDialog.tsx").read_text(encoding="utf-8") self.assertEqual(("calendar.event",), quick_tool.returned_reference_kinds)
collection_dialog = (REPO_ROOT / "webui/src/features/calendar/CalendarCollectionDialogs.tsx").read_text(encoding="utf-8") self.assertEqual("calendar.quick_access.agenda", quick_tool.help_context_id)
settings_panel = (REPO_ROOT / "webui/src/features/calendar/CalendarSettingsPanel.tsx").read_text(encoding="utf-8") self.assertEqual("/calendar", quick_tool.full_page_path)
for component in ("ActionBlockerHint", "ConfirmDialog", "DocumentationHelpLink", "useUnsavedDraftGuard"): def test_quick_access_is_bounded_temporal_and_owner_launched(self) -> None:
quick_access = (
REPO_ROOT / "webui/src/features/calendar/CalendarQuickAccess.tsx"
).read_text(encoding="utf-8")
page = (REPO_ROOT / "webui/src/features/calendar/CalendarPage.tsx").read_text(
encoding="utf-8"
)
self.assertIn("const AGENDA_LIMIT = 7", quick_access)
self.assertIn("launchContext.temporalContext", quick_access)
self.assertIn("limit: AGENDA_LIMIT", quick_access)
self.assertIn('kind: "event"', quick_access)
self.assertIn("quickAccessLaunchState(launchContext)", quick_access)
self.assertIn('parameters.get("quickAction") !== "create-event"', page)
def test_webui_uses_shared_help_guard_and_confirmation_components(self) -> None:
event_dialog = (
REPO_ROOT / "webui/src/features/calendar/CalendarEventDialog.tsx"
).read_text(encoding="utf-8")
collection_dialog = (
REPO_ROOT / "webui/src/features/calendar/CalendarCollectionDialogs.tsx"
).read_text(encoding="utf-8")
settings_panel = (
REPO_ROOT / "webui/src/features/calendar/CalendarSettingsPanel.tsx"
).read_text(encoding="utf-8")
for component in (
"ActionBlockerHint",
"ConfirmDialog",
"DocumentationHelpLink",
"useUnsavedDraftGuard",
):
self.assertIn(component, event_dialog) self.assertIn(component, event_dialog)
for component in ("ActionBlockerHint", "DocumentationHelpLink", "useUnsavedDraftGuard"): for component in (
"ActionBlockerHint",
"DocumentationHelpLink",
"useUnsavedDraftGuard",
):
self.assertIn(component, collection_dialog) self.assertIn(component, collection_dialog)
for component in ("DocumentationHelpLink", "useUnsavedDraftGuard"): for component in ("DocumentationHelpLink", "useUnsavedDraftGuard"):
self.assertIn(component, settings_panel) self.assertIn(component, settings_panel)
+88 -1
View File
@@ -5,8 +5,20 @@ from datetime import datetime, timedelta, timezone
from types import SimpleNamespace from types import SimpleNamespace
from unittest.mock import patch from unittest.mock import patch
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from govoplan_access.backend.db.models import Account, User
from govoplan_calendar.backend.db.models import CalendarCollection, CalendarEvent
from govoplan_calendar.backend.schemas import CalendarCollectionDeleteRequest, CalendarEventResponse from govoplan_calendar.backend.schemas import CalendarCollectionDeleteRequest, CalendarEventResponse
from govoplan_calendar.backend.service import calendar_is_visible_to_principal, delete_calendar, event_response from govoplan_calendar.backend.service import (
calendar_is_visible_to_principal,
delete_calendar,
event_response,
list_event_occurrences,
list_events,
)
from govoplan_core.db.base import Base
class FakeSession: class FakeSession:
@@ -108,6 +120,81 @@ class CalendarVisibilityTests(unittest.TestCase):
) )
) )
def test_event_queries_apply_visible_calendar_fence_and_limit(self) -> None:
engine = create_engine("sqlite://")
Base.metadata.create_all(
engine,
tables=(
Account.__table__,
User.__table__,
CalendarCollection.__table__,
CalendarEvent.__table__,
),
)
session = Session(engine)
start = datetime(2026, 8, 19, 9, tzinfo=timezone.utc)
try:
session.add_all(
(
CalendarCollection(
id="visible-calendar",
tenant_id="tenant-1",
slug="visible",
name="Visible",
visibility="tenant",
),
CalendarCollection(
id="private-calendar",
tenant_id="tenant-1",
slug="private",
name="Private",
visibility="private",
owner_type="user",
owner_id="other-user",
),
CalendarEvent(
id="visible-event",
tenant_id="tenant-1",
calendar_id="visible-calendar",
uid="visible@example.test",
summary="Visible event",
start_at=start,
end_at=start + timedelta(hours=1),
),
CalendarEvent(
id="private-event",
tenant_id="tenant-1",
calendar_id="private-calendar",
uid="private@example.test",
summary="Private event",
start_at=start + timedelta(hours=2),
end_at=start + timedelta(hours=3),
),
)
)
session.commit()
events = list_events(
session,
tenant_id="tenant-1",
visible_calendar_ids=("visible-calendar",),
limit=1,
)
occurrences = list_event_occurrences(
session,
tenant_id="tenant-1",
start_at=start - timedelta(hours=1),
end_at=start + timedelta(days=1),
visible_calendar_ids=("visible-calendar",),
limit=1,
)
self.assertEqual(["visible-event"], [event.id for event in events])
self.assertEqual(["visible-event"], [event["id"] for event in occurrences])
finally:
session.close()
engine.dispose()
def test_private_calendar_is_hidden_from_other_readers_but_visible_to_admin(self) -> None: def test_private_calendar_is_hidden_from_other_readers_but_visible_to_admin(self) -> None:
calendar = self.calendar() calendar = self.calendar()
self.assertFalse( self.assertFalse(
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@govoplan/calendar-webui", "name": "@govoplan/calendar-webui",
"version": "0.1.18", "version": "0.1.20",
"private": true, "private": true,
"type": "module", "type": "module",
"main": "src/index.ts", "main": "src/index.ts",
+2 -1
View File
@@ -472,13 +472,14 @@ export function cancelCalendarMigration(
export function listCalendarEvents( export function listCalendarEvents(
settings: ApiSettings, settings: ApiSettings,
params: { calendar_id?: string; start_at?: string; end_at?: string; expand_recurring?: boolean } = {} params: { calendar_id?: string; start_at?: string; end_at?: string; expand_recurring?: boolean; limit?: number } = {}
): Promise<CalendarEventListResponse> { ): Promise<CalendarEventListResponse> {
const search = new URLSearchParams(); const search = new URLSearchParams();
if (params.calendar_id) search.set("calendar_id", params.calendar_id); if (params.calendar_id) search.set("calendar_id", params.calendar_id);
if (params.start_at) search.set("start_at", params.start_at); if (params.start_at) search.set("start_at", params.start_at);
if (params.end_at) search.set("end_at", params.end_at); if (params.end_at) search.set("end_at", params.end_at);
if (params.expand_recurring) search.set("expand_recurring", "true"); if (params.expand_recurring) search.set("expand_recurring", "true");
if (params.limit) search.set("limit", String(params.limit));
const suffix = search.toString() ? `?${search.toString()}` : ""; const suffix = search.toString() ? `?${search.toString()}` : "";
return apiFetch<CalendarEventListResponse>(settings, `/api/v1/calendar/events${suffix}`); return apiFetch<CalendarEventListResponse>(settings, `/api/v1/calendar/events${suffix}`);
} }
@@ -6,7 +6,7 @@ import {
type FormEvent, type FormEvent,
} from "react"; } from "react";
import { ArrowRightLeft, ListChecks, RefreshCw, Trash2 } from "lucide-react"; import { ArrowRightLeft, ListChecks, RefreshCw, Trash2 } from "lucide-react";
import { import { FormGrid, DialogForm,
ActionBlockerHint, ActionBlockerHint,
Button, Button,
ColorPickerField, ColorPickerField,
@@ -352,7 +352,7 @@ export function CalendarCollectionDialog({
<Dialog <Dialog
open open
title={isEdit ? "i18n:govoplan-calendar.edit_calendar.a47a2a7a" : "i18n:govoplan-calendar.add_calendar.8fadb5bc"} title={isEdit ? "i18n:govoplan-calendar.edit_calendar.a47a2a7a" : "i18n:govoplan-calendar.add_calendar.8fadb5bc"}
className="calendar-event-dialog" size="large"
footerClassName="calendar-event-dialog-footer" footerClassName="calendar-event-dialog-footer"
closeDisabled={saving} closeDisabled={saving}
onClose={onCancel} onClose={onCancel}
@@ -372,7 +372,7 @@ export function CalendarCollectionDialog({
</> </>
}> }>
<form id={formId} className="calendar-dialog-form" onSubmit={submit}> <DialogForm id={formId} className="calendar-dialog-form" onSubmit={submit}>
<div className="calendar-dialog-documentation"> <div className="calendar-dialog-documentation">
<DocumentationHelpLink reference={CALENDAR_SOURCE_DOCUMENTATION} /> <DocumentationHelpLink reference={CALENDAR_SOURCE_DOCUMENTATION} />
</div> </div>
@@ -443,7 +443,7 @@ export function CalendarCollectionDialog({
</span> </span>
} }
</div> </div>
<div className="calendar-caldav-setup"> <FormGrid columns={2} gap="small" collapseAt="narrow" className="calendar-caldav-setup">
<label className="calendar-dialog-wide"> <label className="calendar-dialog-wide">
<span>{calendarSourceUrlLabel(sourceMode)}</span> <span>{calendarSourceUrlLabel(sourceMode)}</span>
<input <input
@@ -532,7 +532,7 @@ export function CalendarCollectionDialog({
} }
{effectiveCollectionUrl && <span>{effectiveCollectionUrl}</span>} {effectiveCollectionUrl && <span>{effectiveCollectionUrl}</span>}
</div> </div>
</div> </FormGrid>
{discoveryError && <p className="calendar-form-error">{discoveryError}</p>} {discoveryError && <p className="calendar-form-error">{discoveryError}</p>}
{calendarSourceUsesCalDav(sourceMode) && discoveredCalendars.length > 0 && {calendarSourceUsesCalDav(sourceMode) && discoveredCalendars.length > 0 &&
<label> <label>
@@ -548,13 +548,13 @@ export function CalendarCollectionDialog({
} }
<details className="calendar-advanced-settings"> <details className="calendar-advanced-settings">
<summary>i18n:govoplan-calendar.advanced.4d064726</summary> <summary>i18n:govoplan-calendar.advanced.4d064726</summary>
<div className="calendar-dialog-grid-two"> <FormGrid columns={2} gap="small" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.display_name.c7874aaa</span> <span>i18n:govoplan-calendar.display_name.c7874aaa</span>
<input value={displayName} onChange={(item) => setDisplayName(item.target.value)} maxLength={255} disabled={saving || !canEditMutableSourceSettings} /> <input value={displayName} onChange={(item) => setDisplayName(item.target.value)} maxLength={255} disabled={saving || !canEditMutableSourceSettings} />
</label> </label>
</div> </FormGrid>
<div className="calendar-sync-settings"> <FormGrid columns={2} gap="small" collapseAt="narrow">
<ToggleSwitch label="i18n:govoplan-calendar.automatic_sync.084644b2" checked={syncEnabled} disabled={saving || !canEditMutableSourceSettings} onChange={setSyncEnabled} /> <ToggleSwitch label="i18n:govoplan-calendar.automatic_sync.084644b2" checked={syncEnabled} disabled={saving || !canEditMutableSourceSettings} onChange={setSyncEnabled} />
<label> <label>
<span>i18n:govoplan-calendar.interval.011efcd5</span> <span>i18n:govoplan-calendar.interval.011efcd5</span>
@@ -574,7 +574,7 @@ export function CalendarCollectionDialog({
<option value="overwrite">i18n:govoplan-calendar.overwrite_remote.39625e32</option> <option value="overwrite">i18n:govoplan-calendar.overwrite_remote.39625e32</option>
</select> </select>
</label> </label>
</div> </FormGrid>
</details> </details>
{source && {source &&
<div className="calendar-sync-status-panel"> <div className="calendar-sync-status-panel">
@@ -614,7 +614,7 @@ export function CalendarCollectionDialog({
{needsSourceSecret && <p className="calendar-form-note">i18n:govoplan-calendar.enter_a_password_or_token_for_this_source.74c09a54</p>} {needsSourceSecret && <p className="calendar-form-note">i18n:govoplan-calendar.enter_a_password_or_token_for_this_source.74c09a54</p>}
</section> </section>
} }
</form> </DialogForm>
</Dialog>); </Dialog>);
} }
@@ -4,7 +4,7 @@ import {
type FormEvent, type FormEvent,
} from "react"; } from "react";
import { Trash2 } from "lucide-react"; import { Trash2 } from "lucide-react";
import { import { FormGrid, DialogForm,
ActionBlockerHint, ActionBlockerHint,
Button, Button,
ConfirmDialog, ConfirmDialog,
@@ -281,7 +281,7 @@ export function CalendarEventDialog({
<Dialog <Dialog
open open
title={event ? "i18n:govoplan-calendar.edit_event.a7028454" : "i18n:govoplan-calendar.new_event.2ef3795c"} title={event ? "i18n:govoplan-calendar.edit_event.a7028454" : "i18n:govoplan-calendar.new_event.2ef3795c"}
className="calendar-event-dialog calendar-vevent-dialog" className="calendar-vevent-dialog"
footerClassName="calendar-event-dialog-footer" footerClassName="calendar-event-dialog-footer"
closeDisabled={saving} closeDisabled={saving}
onClose={onCancel} onClose={onCancel}
@@ -301,7 +301,7 @@ export function CalendarEventDialog({
</> </>
}> }>
<form id={formId} className="calendar-dialog-form" onSubmit={submit}> <DialogForm id={formId} className="calendar-dialog-form" onSubmit={submit}>
<div className="calendar-dialog-documentation"> <div className="calendar-dialog-documentation">
<DocumentationHelpLink reference={CALENDAR_DOCUMENTATION} /> <DocumentationHelpLink reference={CALENDAR_DOCUMENTATION} />
</div> </div>
@@ -355,7 +355,7 @@ export function CalendarEventDialog({
<input value={location} onChange={(item) => setLocation(item.target.value)} maxLength={500} disabled={saving || !canWrite} /> <input value={location} onChange={(item) => setLocation(item.target.value)} maxLength={500} disabled={saving || !canWrite} />
</label> </label>
<ToggleSwitch label="i18n:govoplan-calendar.whole_day.951c82d1" checked={allDay} disabled={saving || !canWrite} onChange={handleAllDayChange} /> <ToggleSwitch label="i18n:govoplan-calendar.whole_day.951c82d1" checked={allDay} disabled={saving || !canWrite} onChange={handleAllDayChange} />
<div className="calendar-dialog-date-row"> <FormGrid columns={2} gap="compact" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.start_date.ff99f5b5</span> <span>i18n:govoplan-calendar.start_date.ff99f5b5</span>
<DateField value={startDate} onChange={handleStartDateChange} required disabled={saving || !canWrite} /> <DateField value={startDate} onChange={handleStartDateChange} required disabled={saving || !canWrite} />
@@ -364,9 +364,9 @@ export function CalendarEventDialog({
<span>i18n:govoplan-calendar.start_time.88d8206d</span> <span>i18n:govoplan-calendar.start_time.88d8206d</span>
<TimeField value={startTime} onChange={handleStartTimeChange} disabled={saving || !canWrite || allDay} /> <TimeField value={startTime} onChange={handleStartTimeChange} disabled={saving || !canWrite || allDay} />
</label> </label>
</div> </FormGrid>
{!allDay && {!allDay &&
<div className="calendar-dialog-date-row"> <FormGrid columns={2} gap="compact" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.end_mode.5a06de37</span> <span>i18n:govoplan-calendar.end_mode.5a06de37</span>
<select value={endMode} onChange={(item) => setEndMode(item.target.value as CalendarEventEndMode)} disabled={saving || !canWrite}> <select value={endMode} onChange={(item) => setEndMode(item.target.value as CalendarEventEndMode)} disabled={saving || !canWrite}>
@@ -380,10 +380,10 @@ export function CalendarEventDialog({
<input type="number" min={1} step={60} value={durationSeconds} onChange={(item) => setDurationSeconds(item.target.value)} required disabled={saving || !canWrite} /> <input type="number" min={1} step={60} value={durationSeconds} onChange={(item) => setDurationSeconds(item.target.value)} required disabled={saving || !canWrite} />
</label> </label>
} }
</div> </FormGrid>
} }
{(allDay || endMode === "end") && {(allDay || endMode === "end") &&
<div className="calendar-dialog-date-row"> <FormGrid columns={2} gap="compact" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.end_date.89d10cd6</span> <span>i18n:govoplan-calendar.end_date.89d10cd6</span>
<DateField value={endDate} min={startDate} onChange={setEndDate} required disabled={saving || !canWrite} /> <DateField value={endDate} min={startDate} onChange={setEndDate} required disabled={saving || !canWrite} />
@@ -392,13 +392,13 @@ export function CalendarEventDialog({
<span>i18n:govoplan-calendar.end_time.cd7800da</span> <span>i18n:govoplan-calendar.end_time.cd7800da</span>
<TimeField value={endTime} min={!allDay && startDate === endDate ? startTime : undefined} onChange={setEndTime} disabled={saving || !canWrite || allDay} /> <TimeField value={endTime} min={!allDay && startDate === endDate ? startTime : undefined} onChange={setEndTime} disabled={saving || !canWrite || allDay} />
</label> </label>
</div> </FormGrid>
} }
<details className="calendar-advanced-settings calendar-vevent-details"> <details className="calendar-advanced-settings calendar-vevent-details">
<summary>i18n:govoplan-calendar.vevent.9cf5be75</summary> <summary>i18n:govoplan-calendar.vevent.9cf5be75</summary>
<section className="calendar-vevent-section"> <section className="calendar-vevent-section">
<h3>i18n:govoplan-calendar.identity.7e5a975b</h3> <h3>i18n:govoplan-calendar.identity.7e5a975b</h3>
<div className="calendar-dialog-grid-three"> <FormGrid columns={3} gap="small" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.uid.d946adf5</span> <span>i18n:govoplan-calendar.uid.d946adf5</span>
<input value={uid} onChange={(item) => setUid(item.target.value)} maxLength={255} disabled={saving || !canWrite || Boolean(event)} /> <input value={uid} onChange={(item) => setUid(item.target.value)} maxLength={255} disabled={saving || !canWrite || Boolean(event)} />
@@ -411,11 +411,11 @@ export function CalendarEventDialog({
<span>i18n:govoplan-calendar.sequence.5c8f4e0e</span> <span>i18n:govoplan-calendar.sequence.5c8f4e0e</span>
<input type="number" min={0} step={1} value={sequence} onChange={(item) => setSequence(item.target.value)} disabled={saving || !canWrite} /> <input type="number" min={0} step={1} value={sequence} onChange={(item) => setSequence(item.target.value)} disabled={saving || !canWrite} />
</label> </label>
</div> </FormGrid>
</section> </section>
<section className="calendar-vevent-section"> <section className="calendar-vevent-section">
<h3>i18n:govoplan-calendar.state.a7250206</h3> <h3>i18n:govoplan-calendar.state.a7250206</h3>
<div className="calendar-dialog-grid-three"> <FormGrid columns={3} gap="small" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.status.bae7d5be</span> <span>i18n:govoplan-calendar.status.bae7d5be</span>
<select value={status} onChange={(item) => setStatus(item.target.value)} disabled={saving || !canWrite}> <select value={status} onChange={(item) => setStatus(item.target.value)} disabled={saving || !canWrite}>
@@ -447,11 +447,11 @@ export function CalendarEventDialog({
<span>i18n:govoplan-calendar.categories.6ccb6007</span> <span>i18n:govoplan-calendar.categories.6ccb6007</span>
<input value={categoriesText} onChange={(item) => setCategoriesText(item.target.value)} disabled={saving || !canWrite} /> <input value={categoriesText} onChange={(item) => setCategoriesText(item.target.value)} disabled={saving || !canWrite} />
</label> </label>
</div> </FormGrid>
</section> </section>
<section className="calendar-vevent-section"> <section className="calendar-vevent-section">
<h3>i18n:govoplan-calendar.participants.cd56e083</h3> <h3>i18n:govoplan-calendar.participants.cd56e083</h3>
<div className="calendar-dialog-grid-two"> <FormGrid columns={2} gap="small" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.organizer_json.3add6f9f</span> <span>i18n:govoplan-calendar.organizer_json.3add6f9f</span>
<textarea value={organizerJson} onChange={(item) => setOrganizerJson(item.target.value)} rows={5} disabled={saving || !canWrite} /> <textarea value={organizerJson} onChange={(item) => setOrganizerJson(item.target.value)} rows={5} disabled={saving || !canWrite} />
@@ -460,7 +460,7 @@ export function CalendarEventDialog({
<span>i18n:govoplan-calendar.attendees_json.aeb487bb</span> <span>i18n:govoplan-calendar.attendees_json.aeb487bb</span>
<textarea value={attendeesJson} onChange={(item) => setAttendeesJson(item.target.value)} rows={5} disabled={saving || !canWrite} /> <textarea value={attendeesJson} onChange={(item) => setAttendeesJson(item.target.value)} rows={5} disabled={saving || !canWrite} />
</label> </label>
</div> </FormGrid>
</section> </section>
<section className="calendar-vevent-section"> <section className="calendar-vevent-section">
<h3>i18n:govoplan-calendar.recurrence.f7ad40f5</h3> <h3>i18n:govoplan-calendar.recurrence.f7ad40f5</h3>
@@ -468,7 +468,7 @@ export function CalendarEventDialog({
<span>i18n:govoplan-calendar.rrule.c7b2f8a3</span> <span>i18n:govoplan-calendar.rrule.c7b2f8a3</span>
<input value={rruleText} onChange={(item) => setRruleText(item.target.value)} disabled={saving || !canWrite} /> <input value={rruleText} onChange={(item) => setRruleText(item.target.value)} disabled={saving || !canWrite} />
</label> </label>
<div className="calendar-dialog-grid-two"> <FormGrid columns={2} gap="small" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.rdate_json.5b51fca4</span> <span>i18n:govoplan-calendar.rdate_json.5b51fca4</span>
<textarea value={rdateJson} onChange={(item) => setRdateJson(item.target.value)} rows={5} disabled={saving || !canWrite} /> <textarea value={rdateJson} onChange={(item) => setRdateJson(item.target.value)} rows={5} disabled={saving || !canWrite} />
@@ -477,11 +477,11 @@ export function CalendarEventDialog({
<span>i18n:govoplan-calendar.exdate_json.7d0c538d</span> <span>i18n:govoplan-calendar.exdate_json.7d0c538d</span>
<textarea value={exdateJson} onChange={(item) => setExdateJson(item.target.value)} rows={5} disabled={saving || !canWrite} /> <textarea value={exdateJson} onChange={(item) => setExdateJson(item.target.value)} rows={5} disabled={saving || !canWrite} />
</label> </label>
</div> </FormGrid>
</section> </section>
<section className="calendar-vevent-section"> <section className="calendar-vevent-section">
<h3>i18n:govoplan-calendar.related.917df91e</h3> <h3>i18n:govoplan-calendar.related.917df91e</h3>
<div className="calendar-dialog-grid-three"> <FormGrid columns={3} gap="small" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.reminders_json.ca25e08f</span> <span>i18n:govoplan-calendar.reminders_json.ca25e08f</span>
<textarea value={remindersJson} onChange={(item) => setRemindersJson(item.target.value)} rows={5} disabled={saving || !canWrite} /> <textarea value={remindersJson} onChange={(item) => setRemindersJson(item.target.value)} rows={5} disabled={saving || !canWrite} />
@@ -494,11 +494,11 @@ export function CalendarEventDialog({
<span>i18n:govoplan-calendar.related_to_json.2d4e8f59</span> <span>i18n:govoplan-calendar.related_to_json.2d4e8f59</span>
<textarea value={relatedToJson} onChange={(item) => setRelatedToJson(item.target.value)} rows={5} disabled={saving || !canWrite} /> <textarea value={relatedToJson} onChange={(item) => setRelatedToJson(item.target.value)} rows={5} disabled={saving || !canWrite} />
</label> </label>
</div> </FormGrid>
</section> </section>
<section className="calendar-vevent-section"> <section className="calendar-vevent-section">
<h3>i18n:govoplan-calendar.source.6da13add</h3> <h3>i18n:govoplan-calendar.source.6da13add</h3>
<div className="calendar-dialog-grid-three"> <FormGrid columns={3} gap="small" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.source_kind.7eda9bc4</span> <span>i18n:govoplan-calendar.source_kind.7eda9bc4</span>
<input value={sourceKind} onChange={(item) => setSourceKind(item.target.value)} maxLength={30} disabled={saving || !canWrite} /> <input value={sourceKind} onChange={(item) => setSourceKind(item.target.value)} maxLength={30} disabled={saving || !canWrite} />
@@ -511,11 +511,11 @@ export function CalendarEventDialog({
<span>i18n:govoplan-calendar.etag.11d00f6e</span> <span>i18n:govoplan-calendar.etag.11d00f6e</span>
<input value={etag} onChange={(item) => setEtag(item.target.value)} maxLength={255} disabled={saving || !canWrite} /> <input value={etag} onChange={(item) => setEtag(item.target.value)} maxLength={255} disabled={saving || !canWrite} />
</label> </label>
</div> </FormGrid>
</section> </section>
<section className="calendar-vevent-section"> <section className="calendar-vevent-section">
<h3>i18n:govoplan-calendar.raw.da433cd4</h3> <h3>i18n:govoplan-calendar.raw.da433cd4</h3>
<div className="calendar-dialog-grid-two"> <FormGrid columns={2} gap="small" collapseAt="narrow">
<label> <label>
<span>i18n:govoplan-calendar.icalendar_json.fb6cc33e</span> <span>i18n:govoplan-calendar.icalendar_json.fb6cc33e</span>
<textarea value={icalendarJson} onChange={(item) => setICalendarJson(item.target.value)} rows={8} disabled={saving || !canWrite} /> <textarea value={icalendarJson} onChange={(item) => setICalendarJson(item.target.value)} rows={8} disabled={saving || !canWrite} />
@@ -524,10 +524,10 @@ export function CalendarEventDialog({
<span>i18n:govoplan-calendar.metadata_json.b0e4c283</span> <span>i18n:govoplan-calendar.metadata_json.b0e4c283</span>
<textarea value={metadataJson} onChange={(item) => setMetadataJson(item.target.value)} rows={8} disabled={saving || !canWrite} /> <textarea value={metadataJson} onChange={(item) => setMetadataJson(item.target.value)} rows={8} disabled={saving || !canWrite} />
</label> </label>
</div> </FormGrid>
</section> </section>
</details> </details>
</form> </DialogForm>
</Dialog> </Dialog>
<ConfirmDialog <ConfirmDialog
open={Boolean(event && confirmingDelete)} open={Boolean(event && confirmingDelete)}
@@ -1,6 +1,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { RefreshCw, XCircle } from "lucide-react"; import { RefreshCw, XCircle } from "lucide-react";
import { import {
ActionToolbar,
Button, Button,
Dialog, Dialog,
DismissibleAlert, DismissibleAlert,
@@ -120,13 +121,13 @@ export function CalendarMigrationDialog({
)} )}
{batch && ( {batch && (
<> <>
<div className="calendar-migration-heading"> <ActionToolbar surface="section-header" className="calendar-migration-heading">
<div> <div>
<strong>{phaseLabel(batch.phase)}</strong> <strong>{phaseLabel(batch.phase)}</strong>
<span>Updated {dateTimeLabel(new Date(batch.updated_at))}</span> <span>Updated {dateTimeLabel(new Date(batch.updated_at))}</span>
</div> </div>
<StatusBadge status={batch.status} label={statusLabel(batch.status)} /> <StatusBadge status={batch.status} label={statusLabel(batch.status)} />
</div> </ActionToolbar>
<progress value={progress} max={100} aria-label="Remote move progress" /> <progress value={progress} max={100} aria-label="Remote move progress" />
<dl className="calendar-migration-summary"> <dl className="calendar-migration-summary">
<div><dt>Events</dt><dd>{batch.total_events}</dd></div> <div><dt>Events</dt><dd>{batch.total_events}</dd></div>
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
import { RefreshCw, RotateCcw, ScanSearch, Trash2 } from "lucide-react"; import { RefreshCw, RotateCcw, ScanSearch, Trash2 } from "lucide-react";
import { import { ActionToolbar,
ActionBlockerHint, ActionBlockerHint,
Button, Button,
ConfirmDialog, ConfirmDialog,
@@ -113,7 +113,7 @@ export function CalendarOutboxDialog({
<p className="calendar-outbox-calendar-name">{calendar.name}</p> <p className="calendar-outbox-calendar-name">{calendar.name}</p>
<DocumentationHelpLink reference={CALENDAR_RECOVERY_DOCUMENTATION} /> <DocumentationHelpLink reference={CALENDAR_RECOVERY_DOCUMENTATION} />
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>} {error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
<div className="calendar-outbox-toolbar"> <ActionToolbar justify="between" className="calendar-outbox-toolbar">
<SegmentedControl<OutboxFilter> <SegmentedControl<OutboxFilter>
value={filter} value={filter}
ariaLabel="i18n:govoplan-calendar.outbox_filter.8305af40" ariaLabel="i18n:govoplan-calendar.outbox_filter.8305af40"
@@ -128,7 +128,7 @@ export function CalendarOutboxDialog({
<div><dt>i18n:govoplan-calendar.conflicts_dead.31252c3a</dt><dd>{conflictCount}</dd></div> <div><dt>i18n:govoplan-calendar.conflicts_dead.31252c3a</dt><dd>{conflictCount}</dd></div>
<div><dt>i18n:govoplan-calendar.shown.498e85a1</dt><dd>{visibleOperations.length}</dd></div> <div><dt>i18n:govoplan-calendar.shown.498e85a1</dt><dd>{visibleOperations.length}</dd></div>
</dl> </dl>
</div> </ActionToolbar>
{loading && !operations.length {loading && !operations.length
? <p className="calendar-form-note">i18n:govoplan-calendar.loading_outbound_changes.3fc59656</p> ? <p className="calendar-form-note">i18n:govoplan-calendar.loading_outbound_changes.3fc59656</p>
: visibleOperations.length : visibleOperations.length
+50 -9
View File
@@ -8,7 +8,7 @@ import {
type WheelEvent as ReactWheelEvent } from type WheelEvent as ReactWheelEvent } from
"react"; "react";
import { CalendarDays, ChevronLeft, ChevronRight, Pencil, Plus, RefreshCw } from "lucide-react"; import { CalendarDays, ChevronLeft, ChevronRight, Pencil, Plus, RefreshCw } from "lucide-react";
import { import { ToolbarGroup, ActionToolbar,
AdminIconButton, AdminIconButton,
Button, Button,
DismissibleAlert, DismissibleAlert,
@@ -21,6 +21,7 @@ import {
type ApiSettings, type ApiSettings,
type AuthInfo type AuthInfo
} from "@govoplan/core-webui"; } from "@govoplan/core-webui";
import { useLocation, useNavigate } from "react-router";
import { import {
createCalendar, createCalendar,
createCalendarEvent, createCalendarEvent,
@@ -124,6 +125,8 @@ const modeOptions: {id: CalendarMode;label: string;}[] = [
export default function CalendarPage({ settings, auth }: {settings: ApiSettings;auth: AuthInfo;}) { export default function CalendarPage({ settings, auth }: {settings: ApiSettings;auth: AuthInfo;}) {
const location = useLocation();
const navigate = useNavigate();
const [calendars, setCalendars] = useState<CalendarCollection[]>([]); const [calendars, setCalendars] = useState<CalendarCollection[]>([]);
const [syncSources, setSyncSources] = useState<CalendarSyncSource[]>([]); const [syncSources, setSyncSources] = useState<CalendarSyncSource[]>([]);
const [visibleCalendarIds, setVisibleCalendarIds] = useState<string[]>([]); const [visibleCalendarIds, setVisibleCalendarIds] = useState<string[]>([]);
@@ -185,6 +188,38 @@ export default function CalendarPage({ settings, auth }: {settings: ApiSettings;
void loadCalendars(); void loadCalendars();
}, [settings.apiBaseUrl, settings.apiKey, settings.accessToken]); }, [settings.apiBaseUrl, settings.apiKey, settings.accessToken]);
useEffect(() => {
const parameters = new URLSearchParams(location.search);
const focusParameter = parameters.get("focusDate");
const requestedFocus = validCalendarLaunchDate(focusParameter);
if (requestedFocus) setFocusDate(requestedFocus);
if (parameters.get("quickAction") !== "create-event" || loading) return;
const requestedStart = validCalendarLaunchDate(parameters.get("startAt"));
if (canWrite && calendars.length > 0 && targetCalendarId) {
setFocusDate(requestedStart ?? requestedFocus ?? new Date());
setEventDialog({ kind: "create" });
}
parameters.delete("quickAction");
parameters.delete("startAt");
if (requestedStart) parameters.set("focusDate", requestedStart.toISOString());
const search = parameters.toString();
navigate(
{ pathname: location.pathname, search: search ? `?${search}` : "" },
{ replace: true, state: location.state }
);
}, [
calendars.length,
canWrite,
loading,
location.pathname,
location.search,
location.state,
navigate,
targetCalendarId
]);
useEffect(() => { useEffect(() => {
saveCalendarMode(mode); saveCalendarMode(mode);
}, [mode]); }, [mode]);
@@ -854,8 +889,8 @@ export default function CalendarPage({ settings, auth }: {settings: ApiSettings;
</aside> </aside>
<section className="calendar-main-panel" aria-label="i18n:govoplan-calendar.calendar.adab5090"> <section className="calendar-main-panel" aria-label="i18n:govoplan-calendar.calendar.adab5090">
<div className="calendar-view-toolbar" aria-label="i18n:govoplan-calendar.calendar_controls.974f4fa1"> <ActionToolbar className="calendar-view-toolbar" aria-label="i18n:govoplan-calendar.calendar_controls.974f4fa1">
<div className="calendar-toolbar-left"> <ToolbarGroup grow className="calendar-toolbar-left">
<SegmentedControl <SegmentedControl
className="calendar-mode-switch" className="calendar-mode-switch"
size="equal" size="equal"
@@ -870,9 +905,9 @@ export default function CalendarPage({ settings, auth }: {settings: ApiSettings;
}} }}
options={modeOptions} options={modeOptions}
/> />
</div> </ToolbarGroup>
<div className="calendar-toolbar-center"> <ToolbarGroup align="center" className="calendar-toolbar-center">
<div className="calendar-icon-group" aria-label="i18n:govoplan-calendar.calendar_navigation.7ba43cd2"> <div className="calendar-icon-group" aria-label="i18n:govoplan-calendar.calendar_navigation.7ba43cd2">
<AdminIconButton <AdminIconButton
label="i18n:govoplan-calendar.previous.50f94286" label="i18n:govoplan-calendar.previous.50f94286"
@@ -892,9 +927,9 @@ export default function CalendarPage({ settings, auth }: {settings: ApiSettings;
<strong>{heading}</strong> <strong>{heading}</strong>
</div> </div>
</div> </div>
</div> </ToolbarGroup>
<div className="calendar-toolbar-right"> <ToolbarGroup align="end" className="calendar-toolbar-right">
<DocumentationHelpLink reference={CALENDAR_DOCUMENTATION} /> <DocumentationHelpLink reference={CALENDAR_DOCUMENTATION} />
<AdminIconButton <AdminIconButton
label="i18n:govoplan-calendar.refresh.56e3badc" label="i18n:govoplan-calendar.refresh.56e3badc"
@@ -906,8 +941,8 @@ export default function CalendarPage({ settings, auth }: {settings: ApiSettings;
<Plus size={17} /> i18n:govoplan-calendar.new.6403f2b7 <Plus size={17} /> i18n:govoplan-calendar.new.6403f2b7
</Button> </Button>
} }
</div> </ToolbarGroup>
</div> </ActionToolbar>
<div className={`calendar-view-shell is-${mode}`}> <div className={`calendar-view-shell is-${mode}`}>
{mode === "continuous" ? {mode === "continuous" ?
@@ -1083,6 +1118,12 @@ function calendarRemoteMoveBatchId(calendar: CalendarCollection): string {
return typeof batchId === "string" ? batchId : ""; return typeof batchId === "string" ? batchId : "";
} }
function validCalendarLaunchDate(value: string | null): Date | null {
if (!value) return null;
const parsed = new Date(value);
return Number.isNaN(parsed.getTime()) ? null : parsed;
}
function calendarViewPreferences( function calendarViewPreferences(
response: CalendarViewPreferencesResponse response: CalendarViewPreferencesResponse
): CalendarViewPreferences { ): CalendarViewPreferences {
@@ -0,0 +1,200 @@
import { CalendarDays, ExternalLink, MapPin, Plus } from "lucide-react";
import { useCallback, useEffect, useMemo, useState } from "react";
import { Link } from "react-router";
import {
Button,
DismissibleAlert,
LoadingFrame,
SelectionList,
SelectionListItem,
SelectionListItemContent,
hasScope,
quickAccessLaunchState,
useDashboardWidgetData,
type QuickAccessToolRenderContext
} from "@govoplan/core-webui";
import { listCalendarEvents, type CalendarEvent } from "../../api/calendar";
const AGENDA_DAYS = 21;
const AGENDA_LIMIT = 7;
type Props = Pick<
QuickAccessToolRenderContext,
"settings" | "auth" | "launchContext" | "complete" | "close"
>;
/**
* Calendar-owned, range- and result-bounded agenda. The API applies tenant,
* scope, and collection-visibility checks before any event reaches the rail.
*/
export default function CalendarQuickAccess({
settings,
auth,
launchContext,
complete,
close
}: Props) {
const [selectedKey, setSelectedKey] = useState("");
const rangeStart = useMemo(
() => agendaStart(launchContext.temporalContext),
[
launchContext.temporalContext.validAt,
launchContext.temporalContext.validityMode
]
);
const rangeEnd = useMemo(() => {
const end = new Date(rangeStart);
end.setDate(end.getDate() + AGENDA_DAYS);
return end;
}, [rangeStart]);
const load = useCallback(async () => {
const response = await listCalendarEvents(settings, {
start_at: rangeStart.toISOString(),
end_at: rangeEnd.toISOString(),
expand_recurring: true,
limit: AGENDA_LIMIT
});
return response.events.filter(
(event) => event.status.toUpperCase() !== "CANCELLED"
);
}, [rangeEnd, rangeStart, settings]);
const { data: events, loading, error } = useDashboardWidgetData(load, 0);
const items = events ?? [];
const selected = useMemo(
() => items.find((event) => eventKey(event) === selectedKey) ?? items[0] ?? null,
[items, selectedKey]
);
const canCreate = hasScope(auth, "calendar:event:write");
useEffect(() => {
if (!selectedKey && items[0]) setSelectedKey(eventKey(items[0]));
if (selectedKey && !items.some((event) => eventKey(event) === selectedKey)) {
setSelectedKey(items[0] ? eventKey(items[0]) : "");
}
}, [items, selectedKey]);
function selectForHost(event: CalendarEvent) {
complete({
contractVersion: "1",
outcome: "completed",
action: "selected",
reference: {
ownerModule: "calendar",
kind: "event",
objectId: eventKey(event),
tenantId: event.tenant_id,
label: event.summary,
version: `${event.sequence}:${event.updated_at}`,
path: calendarFocusPath(event.start_at)
}
});
}
return (
<LoadingFrame loading={loading} label="i18n:govoplan-calendar.loading_calendar.7eb8f548">
{error ? (
<DismissibleAlert tone="warning" resetKey={error}>{error}</DismissibleAlert>
) : null}
<p className="calendar-quick-range">
i18n:govoplan-calendar.quick_access_range: {rangeLabel(rangeStart, rangeEnd)}
</p>
{items.length ? (
<SelectionList variant="navigation" label="i18n:govoplan-calendar.agenda.891e9d6d">
{items.map((event) => (
<SelectionListItem
key={eventKey(event)}
selected={selected ? eventKey(event) === eventKey(selected) : false}
onClick={() => setSelectedKey(eventKey(event))}
>
<SelectionListItemContent
leading={<CalendarDays size={16} aria-hidden="true" />}
title={event.summary}
description={eventTimeLabel(event)}
/>
</SelectionListItem>
))}
</SelectionList>
) : !loading && !error ? (
<p className="muted">i18n:govoplan-calendar.no_events.e339ba73</p>
) : null}
{selected ? (
<section className="calendar-quick-detail" aria-label="i18n:govoplan-calendar.quick_access_event_details">
<strong>{selected.summary}</strong>
<span>{eventTimeLabel(selected)}</span>
{selected.location ? (
<span><MapPin size={13} aria-hidden="true" /> {selected.location}</span>
) : null}
{selected.description ? <p>{selected.description}</p> : null}
<div className="button-row compact-actions">
<Button variant="primary" onClick={() => selectForHost(selected)}>
i18n:govoplan-calendar.quick_access_select_event
</Button>
<Link
className="btn btn-secondary"
to={calendarFocusPath(selected.start_at)}
state={quickAccessLaunchState(launchContext)}
onClick={() => selectForHost(selected)}
>
<ExternalLink size={15} aria-hidden="true" />
i18n:govoplan-calendar.quick_access_open_calendar
</Link>
</div>
</section>
) : null}
{canCreate ? (
<div className="dashboard-contribution-footer">
<Link
className="btn btn-secondary"
to={calendarCreatePath(rangeStart)}
state={quickAccessLaunchState(launchContext)}
onClick={close}
>
<Plus size={15} aria-hidden="true" />
i18n:govoplan-calendar.new_event.2ef3795c
</Link>
</div>
) : null}
</LoadingFrame>
);
}
function agendaStart(
context: QuickAccessToolRenderContext["launchContext"]["temporalContext"]
): Date {
if (context.validityMode === "at" && context.validAt) {
const parsed = new Date(context.validAt);
if (!Number.isNaN(parsed.getTime())) return parsed;
}
return new Date();
}
function eventKey(event: CalendarEvent): string {
return event.instance_id || event.id;
}
function calendarFocusPath(startAt: string): string {
return `/calendar?focusDate=${encodeURIComponent(startAt)}`;
}
function calendarCreatePath(startAt: Date): string {
return `/calendar?quickAction=create-event&startAt=${encodeURIComponent(startAt.toISOString())}`;
}
function eventTimeLabel(event: CalendarEvent): string {
const start = new Date(event.start_at);
if (event.all_day) {
return new Intl.DateTimeFormat(undefined, { dateStyle: "medium" }).format(start);
}
return new Intl.DateTimeFormat(undefined, {
dateStyle: "medium",
timeStyle: "short"
}).format(start);
}
function rangeLabel(start: Date, end: Date): string {
const formatter = new Intl.DateTimeFormat(undefined, { dateStyle: "medium" });
return `${formatter.format(start)} ${formatter.format(end)}`;
}
@@ -1,6 +1,6 @@
import { useEffect, useMemo, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { Save } from "lucide-react"; import { Save } from "lucide-react";
import { import { FormGrid, ContentGrid,
Button, Button,
Card, Card,
DismissibleAlert, DismissibleAlert,
@@ -124,12 +124,12 @@ export default function CalendarSettingsPanel({
}); });
return ( return (
<div className="dashboard-grid settings-dashboard-grid calendar-settings-panel"> <ContentGrid columns={2} collapseAt="workspace" className="calendar-settings-panel">
<div className="calendar-settings-documentation"> <div className="calendar-settings-documentation">
<DocumentationHelpLink reference={CALENDAR_DOCUMENTATION} /> <DocumentationHelpLink reference={CALENDAR_DOCUMENTATION} />
</div> </div>
<Card title="Calendar display"> <Card title="Calendar display">
<div className="form-grid"> <FormGrid columns={1} collapseAt="standard" className="">
<ToggleSwitch <ToggleSwitch
label="Dim weekends" label="Dim weekends"
help="Use a quieter background for Saturday and Sunday in week views." help="Use a quieter background for Saturday and Sunday in week views."
@@ -147,7 +147,7 @@ export default function CalendarSettingsPanel({
setDraft((current) => ({ ...current, dim_off_hours })) setDraft((current) => ({ ...current, dim_off_hours }))
} }
/> />
<div className="calendar-dialog-grid-two"> <FormGrid columns={2} gap="small" collapseAt="narrow">
<FormField label="Workday starts"> <FormField label="Workday starts">
<input <input
type="number" type="number"
@@ -178,11 +178,11 @@ export default function CalendarSettingsPanel({
} }
/> />
</FormField> </FormField>
</div> </FormGrid>
</div> </FormGrid>
</Card> </Card>
<Card title="Continuous view"> <Card title="Continuous view">
<div className="form-grid"> <FormGrid columns={1} collapseAt="standard" className="">
<ToggleSwitch <ToggleSwitch
label="Virtualize distant weeks" label="Virtualize distant weeks"
help="Keep the continuous calendar responsive by rendering only nearby weeks." help="Keep the continuous calendar responsive by rendering only nearby weeks."
@@ -240,9 +240,9 @@ export default function CalendarSettingsPanel({
{message} {message}
</DismissibleAlert> </DismissibleAlert>
)} )}
</div> </FormGrid>
</Card> </Card>
</div> </ContentGrid>
); );
} }
+10
View File
@@ -51,6 +51,11 @@ export const generatedTranslations: PlatformTranslations = {
"i18n:govoplan-calendar.calendar_source_type.92cdb42f": "Calendar source type", "i18n:govoplan-calendar.calendar_source_type.92cdb42f": "Calendar source type",
"i18n:govoplan-calendar.calendar_views.9e6b9c2b": "Calendar views", "i18n:govoplan-calendar.calendar_views.9e6b9c2b": "Calendar views",
"i18n:govoplan-calendar.calendar.adab5090": "Calendar", "i18n:govoplan-calendar.calendar.adab5090": "Calendar",
"i18n:govoplan-calendar.quick_access_description": "Upcoming events across visible calendars.",
"i18n:govoplan-calendar.quick_access_range": "Agenda range",
"i18n:govoplan-calendar.quick_access_event_details": "Event details",
"i18n:govoplan-calendar.quick_access_select_event": "Select event",
"i18n:govoplan-calendar.quick_access_open_calendar": "Open in Calendar",
"i18n:govoplan-calendar.calendars_are_unavailable.f074c862": "Calendars are unavailable.", "i18n:govoplan-calendar.calendars_are_unavailable.f074c862": "Calendars are unavailable.",
"i18n:govoplan-calendar.calendars.94445018": "Calendars", "i18n:govoplan-calendar.calendars.94445018": "Calendars",
"i18n:govoplan-calendar.cancel.77dfd213": "Cancel", "i18n:govoplan-calendar.cancel.77dfd213": "Cancel",
@@ -289,6 +294,11 @@ export const generatedTranslations: PlatformTranslations = {
"i18n:govoplan-calendar.calendar_source_type.92cdb42f": "Calendar source type", "i18n:govoplan-calendar.calendar_source_type.92cdb42f": "Calendar source type",
"i18n:govoplan-calendar.calendar_views.9e6b9c2b": "Calendar views", "i18n:govoplan-calendar.calendar_views.9e6b9c2b": "Calendar views",
"i18n:govoplan-calendar.calendar.adab5090": "Kalender", "i18n:govoplan-calendar.calendar.adab5090": "Kalender",
"i18n:govoplan-calendar.quick_access_description": "Anstehende Termine aus den sichtbaren Kalendern.",
"i18n:govoplan-calendar.quick_access_range": "Agendazeitraum",
"i18n:govoplan-calendar.quick_access_event_details": "Termindetails",
"i18n:govoplan-calendar.quick_access_select_event": "Termin auswählen",
"i18n:govoplan-calendar.quick_access_open_calendar": "Im Kalender öffnen",
"i18n:govoplan-calendar.calendars_are_unavailable.f074c862": "Kalender sind nicht verfügbar.", "i18n:govoplan-calendar.calendars_are_unavailable.f074c862": "Kalender sind nicht verfügbar.",
"i18n:govoplan-calendar.calendars.94445018": "Calendars", "i18n:govoplan-calendar.calendars.94445018": "Calendars",
"i18n:govoplan-calendar.cancel.77dfd213": "Abbrechen", "i18n:govoplan-calendar.cancel.77dfd213": "Abbrechen",
+19 -1
View File
@@ -3,12 +3,14 @@ import type {
CalendarPickerUiCapability, CalendarPickerUiCapability,
DashboardWidgetsUiCapability, DashboardWidgetsUiCapability,
PlatformWebModule, PlatformWebModule,
QuickAccessToolsUiCapability,
SettingsSectionsUiCapability SettingsSectionsUiCapability
} from "@govoplan/core-webui"; } from "@govoplan/core-webui";
import "./styles/calendar.css"; import "./styles/calendar.css";
import { generatedTranslations } from "./i18n/generatedTranslations"; import { generatedTranslations } from "./i18n/generatedTranslations";
import CalendarPicker from "./features/calendar/CalendarPicker"; import CalendarPicker from "./features/calendar/CalendarPicker";
import UpcomingEventsWidget from "./features/calendar/UpcomingEventsWidget"; import UpcomingEventsWidget from "./features/calendar/UpcomingEventsWidget";
import CalendarQuickAccess from "./features/calendar/CalendarQuickAccess";
const CalendarPage = lazy(() => import("./features/calendar/CalendarPage")); const CalendarPage = lazy(() => import("./features/calendar/CalendarPage"));
const CalendarSettingsPanel = lazy( const CalendarSettingsPanel = lazy(
@@ -90,6 +92,14 @@ const calendarDashboardWidgets: DashboardWidgetsUiCapability = {
} }
] ]
}; };
const calendarQuickAccessTools: QuickAccessToolsUiCapability = {
tools: [
{
id: "calendar.agenda",
render: (context) => createElement(CalendarQuickAccess, context)
}
]
};
export const calendarModule: PlatformWebModule = { export const calendarModule: PlatformWebModule = {
id: "calendar", id: "calendar",
@@ -122,6 +132,13 @@ export const calendarModule: PlatformWebModule = {
kind: "section", kind: "section",
label: "Calendar preferences", label: "Calendar preferences",
order: 45 order: 45
},
{
id: "calendar.quick_access.agenda",
moduleId: "calendar",
kind: "quick_access",
label: "Calendar Quick Access",
order: 50
} }
], ],
navItems: [{ to: "/calendar", label: "i18n:govoplan-calendar.calendar.adab5090", iconName: "calendar", anyOf: eventRead, order: 55, surfaceId: "calendar.navigation" }], navItems: [{ to: "/calendar", label: "i18n:govoplan-calendar.calendar.adab5090", iconName: "calendar", anyOf: eventRead, order: 55, surfaceId: "calendar.navigation" }],
@@ -130,7 +147,8 @@ export const calendarModule: PlatformWebModule = {
uiCapabilities: { uiCapabilities: {
"calendar.picker": calendarPicker, "calendar.picker": calendarPicker,
"dashboard.widgets": calendarDashboardWidgets, "dashboard.widgets": calendarDashboardWidgets,
"settings.sections": calendarSettingsSections "settings.sections": calendarSettingsSections,
"quickAccess.tools": calendarQuickAccessTools
} }
}; };
+48 -65
View File
@@ -93,7 +93,7 @@
flex: 0 1 520px; flex: 0 1 520px;
grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-columns: repeat(5, minmax(0, 1fr));
width: min(520px, 100%); width: min(520px, 100%);
max-width: 520px; max-width: 560px;
} }
.calendar-mode-switch .segmented-control-option { .calendar-mode-switch .segmented-control-option {
@@ -149,7 +149,7 @@
width: 100%; width: 100%;
min-height: 34px; min-height: 34px;
border: 1px solid transparent; border: 1px solid transparent;
border-radius: 4px; border-radius: var(--radius-sm);
background: transparent; background: transparent;
color: var(--text); color: var(--text);
cursor: pointer; cursor: pointer;
@@ -165,7 +165,7 @@
gap: 4px; gap: 4px;
min-height: 36px; min-height: 36px;
padding: 2px 4px; padding: 2px 4px;
border-radius: 4px; border-radius: var(--radius-sm);
} }
.calendar-list-row:hover, .calendar-list-row:hover,
@@ -187,7 +187,7 @@
align-items: center; align-items: center;
padding: 2px; padding: 2px;
border: 1px solid var(--control-border); border: 1px solid var(--control-border);
border-radius: 999px; border-radius: var(--radius-pill);
background: var(--calendar-switch-bg); background: var(--calendar-switch-bg);
cursor: pointer; cursor: pointer;
transition: background .16s ease, border-color .16s ease; transition: background .16s ease, border-color .16s ease;
@@ -201,7 +201,7 @@
.calendar-visibility-switch span { .calendar-visibility-switch span {
width: 14px; width: 14px;
height: 14px; height: 14px;
border-radius: 50%; border-radius: var(--radius-round);
background: var(--surface); background: var(--surface);
box-shadow: var(--shadow-thumb); box-shadow: var(--shadow-thumb);
transform: translateX(0); transform: translateX(0);
@@ -266,6 +266,33 @@
justify-content: center; justify-content: center;
} }
.calendar-quick-range {
margin: 0 0 10px;
color: var(--muted);
font-size: 12px;
}
.calendar-quick-detail {
display: grid;
gap: 7px;
margin-top: 12px;
border-top: var(--border-line);
padding-top: 12px;
}
.calendar-quick-detail > span,
.calendar-quick-detail > p {
margin: 0;
color: var(--muted);
font-size: 12px;
}
.calendar-quick-detail > span {
display: inline-flex;
align-items: center;
gap: 5px;
}
.calendar-agenda { .calendar-agenda {
flex: 1 1 auto; flex: 1 1 auto;
min-height: 0; min-height: 0;
@@ -495,7 +522,7 @@
padding: 4px 7px; padding: 4px 7px;
border: 1px solid var(--calendar-event-border); border: 1px solid var(--calendar-event-border);
border-left: 4px solid var(--calendar-event-color); border-left: 4px solid var(--calendar-event-color);
border-radius: 4px; border-radius: var(--radius-sm);
background: var(--calendar-event-bg); background: var(--calendar-event-bg);
color: var(--calendar-event-text); color: var(--calendar-event-text);
cursor: pointer; cursor: pointer;
@@ -720,7 +747,7 @@
top: -5px; top: -5px;
width: 8px; width: 8px;
height: 8px; height: 8px;
border-radius: 999px; border-radius: var(--radius-pill);
background: var(--green); background: var(--green);
content: ""; content: "";
} }
@@ -731,7 +758,7 @@
left: 10px; left: 10px;
padding: 2px 6px; padding: 2px 6px;
border: 1px solid var(--calendar-success-border); border: 1px solid var(--calendar-success-border);
border-radius: 4px; border-radius: var(--radius-sm);
background: var(--green); background: var(--green);
color: var(--on-accent); color: var(--on-accent);
font-size: 11px; font-size: 11px;
@@ -744,7 +771,7 @@
position: absolute; position: absolute;
z-index: 1; z-index: 1;
min-width: 0; min-width: 0;
border-radius: 4px; border-radius: var(--radius-sm);
font: inherit; font: inherit;
text-align: left; text-align: left;
} }
@@ -815,7 +842,7 @@
left: 50%; left: 50%;
width: 34px; width: 34px;
height: 2px; height: 2px;
border-radius: 999px; border-radius: var(--radius-pill);
background: var(--calendar-overlay); background: var(--calendar-overlay);
content: ""; content: "";
opacity: 0; opacity: 0;
@@ -850,10 +877,6 @@
font-weight: 800; font-weight: 800;
} }
.calendar-event-dialog {
width: min(680px, 100%);
}
.calendar-vevent-dialog { .calendar-vevent-dialog {
width: min(920px, 100%); width: min(920px, 100%);
} }
@@ -899,13 +922,6 @@
cursor: not-allowed; cursor: not-allowed;
} }
.calendar-dialog-row,
.calendar-dialog-date-row {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.calendar-dialog-name-color-row { .calendar-dialog-name-color-row {
display: grid; display: grid;
grid-template-columns: minmax(0, 1fr) 142px; grid-template-columns: minmax(0, 1fr) 142px;
@@ -926,7 +942,7 @@
gap: 12px; gap: 12px;
padding: 12px; padding: 12px;
border: var(--border-line); border: var(--border-line);
border-radius: 6px; border-radius: var(--radius-compact);
background: var(--panel-soft); background: var(--panel-soft);
} }
@@ -944,19 +960,6 @@
gap: 10px; gap: 10px;
} }
.calendar-dialog-grid-two,
.calendar-dialog-grid-three,
.calendar-caldav-setup,
.calendar-sync-settings {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.calendar-dialog-grid-three {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.calendar-dialog-wide { .calendar-dialog-wide {
grid-column: 1 / -1; grid-column: 1 / -1;
} }
@@ -1048,7 +1051,7 @@
.calendar-sync-status { .calendar-sync-status {
padding: 3px 8px; padding: 3px 8px;
border: var(--border-line-dark); border: var(--border-line-dark);
border-radius: 999px; border-radius: var(--radius-pill);
background: var(--surface); background: var(--surface);
color: var(--muted); color: var(--muted);
font-size: 12px; font-size: 12px;
@@ -1078,7 +1081,7 @@
gap: 10px; gap: 10px;
padding: 10px; padding: 10px;
border: var(--border-line); border: var(--border-line);
border-radius: 6px; border-radius: var(--radius-compact);
background: var(--surface); background: var(--surface);
} }
@@ -1134,13 +1137,6 @@
font-weight: 700; font-weight: 700;
} }
.calendar-outbox-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.calendar-outbox-summary { .calendar-outbox-summary {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -1183,7 +1179,7 @@
gap: 8px; gap: 8px;
padding: 11px 12px; padding: 11px 12px;
border: var(--border-line); border: var(--border-line);
border-radius: 6px; border-radius: var(--radius-compact);
background: var(--surface); background: var(--surface);
} }
@@ -1199,8 +1195,8 @@
display: grid; display: grid;
gap: 10px; gap: 10px;
padding: 12px; padding: 12px;
border-left: 3px solid var(--color-danger, #b42318); border-left: 3px solid var(--danger-border-deep);
background: var(--color-danger-subtle, rgba(180, 35, 24, 0.08)); background: var(--danger-muted-bg);
} }
.calendar-remote-move-confirmation label, .calendar-remote-move-confirmation label,
@@ -1225,13 +1221,6 @@
min-height: 240px; min-height: 240px;
} }
.calendar-migration-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.calendar-migration-heading > div { .calendar-migration-heading > div {
display: grid; display: grid;
gap: 3px; gap: 3px;
@@ -1310,7 +1299,7 @@
.calendar-migration-error { .calendar-migration-error {
margin: 0; margin: 0;
color: var(--color-danger, #b42318); color: var(--danger-border-deep);
} }
.calendar-migration-cancel { .calendar-migration-cancel {
@@ -1324,7 +1313,7 @@
justify-self: start; justify-self: start;
} }
@media (max-width: 700px) { @media (max-width: 760px) {
.calendar-migration-summary { .calendar-migration-summary {
grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-columns: repeat(2, minmax(0, 1fr));
} }
@@ -1388,7 +1377,7 @@
margin: 0; margin: 0;
padding: 9px 10px; padding: 9px 10px;
border: 1px solid var(--calendar-danger-border); border: 1px solid var(--calendar-danger-border);
border-radius: 4px; border-radius: var(--radius-sm);
background: var(--calendar-danger-bg); background: var(--calendar-danger-bg);
color: var(--red); color: var(--red);
font-size: 13px; font-size: 13px;
@@ -1398,7 +1387,7 @@
.calendar-form-note { .calendar-form-note {
margin: 0; margin: 0;
padding: 9px 10px; padding: 9px 10px;
border-radius: 4px; border-radius: var(--radius-sm);
font-size: 13px; font-size: 13px;
} }
@@ -1420,7 +1409,7 @@
margin: 0; margin: 0;
padding: 10px; padding: 10px;
border: var(--border-line); border: var(--border-line);
border-radius: 6px; border-radius: var(--radius-compact);
background: var(--panel-soft); background: var(--panel-soft);
} }
@@ -1521,13 +1510,7 @@
max-width: none; max-width: none;
} }
.calendar-dialog-row,
.calendar-dialog-date-row,
.calendar-dialog-name-color-row, .calendar-dialog-name-color-row,
.calendar-dialog-grid-two,
.calendar-dialog-grid-three,
.calendar-caldav-setup,
.calendar-sync-settings,
.calendar-sync-status-panel dl { .calendar-sync-status-panel dl {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
+1
View File
@@ -36,6 +36,7 @@
"src/features/calendar/CalendarPage.tsx", "src/features/calendar/CalendarPage.tsx",
"src/features/calendar/CalendarSettingsPanel.tsx", "src/features/calendar/CalendarSettingsPanel.tsx",
"src/features/calendar/UpcomingEventsWidget.tsx", "src/features/calendar/UpcomingEventsWidget.tsx",
"src/features/calendar/CalendarQuickAccess.tsx",
"src/features/calendar/CalendarViews.tsx", "src/features/calendar/CalendarViews.tsx",
"src/features/calendar/CalendarCollectionDialogs.tsx", "src/features/calendar/CalendarCollectionDialogs.tsx",
"src/features/calendar/CalendarEventDialog.tsx", "src/features/calendar/CalendarEventDialog.tsx",