Skip to content

Add attachments to events and exams#2138

Open
nilsreichardt wants to merge 1 commit intomainfrom
codex/add-file-upload-for-events-and-exams
Open

Add attachments to events and exams#2138
nilsreichardt wants to merge 1 commit intomainfrom
codex/add-file-upload-for-events-and-exams

Conversation

@nilsreichardt
Copy link
Member

Motivation

  • Enable attaching files to calendrical events/exams so users can upload information sheets or exam summaries like they already can for homework and blackboard items.
  • Reuse the existing filesharing flows to store attachments and keep reference tracking in Firestore so files are associated with the created/edited event.

Description

  • Add attachments: List<String> to CalendricalEvent and include it in serialization/deserialization and copyWith so events can store attachment IDs.
  • Extend the filesharing reference types with a new ReferenceType.event so files can be referenced by events.
  • On event creation upload local files via FileSharingGateway.uploadAttachments, persist returned file IDs on the event, and add reference data to each file; TimetableGateway.createEvent now returns the created eventID needed for reference tracking.
  • On event edit support adding new local files (upload + add reference data) and removing existing cloud files (remove reference data); the edit flow builds the final attachments list and saves it.
  • Add UI components to the event add dialog and the event edit page using the shared AttachFile/AttachFileBase widgets so users can add/remove attachments when creating or editing events.
  • Show attachments on the event details page using AttachmentStreamList, and remove file references when an event is deleted.
  • Update mocks and tests to account for new return types and the new attachments field.

Testing

  • Ran fvm flutter test app/test/timetable/timetable_dialog_test.dart and the test suite passed.
  • Ran fvm flutter test app/test/timetable/timetable_bloc_test.dart and the test suite passed.

Codex Task

@nilsreichardt nilsreichardt added the codex Used for PRs that are generated by Codex. label Feb 3, 2026 — with ChatGPT Codex Connector
@github-actions github-actions bot added feature: file-sharing Files can be shared inside Sharezone e.g. by uploading them in a file-sharing folder of a course. feature: timetable / calendar Includes anything regarding lessons (timetable) and events (calendar). feature: universal file features File features (downloading, preview, etc.) that are used by multiple Sharezone features. testing labels Feb 3, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully adds the functionality to attach files to calendrical events and exams. The changes are well-integrated, reusing existing filesharing flows and updating models, UI components, and gateways accordingly. The logic for creating, editing, and deleting events now correctly handles attachment references. I've found one area for improvement in TimetableEditEventBloc to make the code more concise and idiomatic, which I've detailed in a specific comment.

Comment on lines +94 to +111
Function(List<LocalFile>) get addLocalFiles => (localFiles) {
final list = <LocalFile>[];
list.addAll(_localFilesSubject.value);
list.addAll(localFiles);
_localFilesSubject.sink.add(list);
};
Function(LocalFile) get removeLocalFile => (localFile) {
final list = <LocalFile>[];
list.addAll(_localFilesSubject.value);
list.remove(localFile);
_localFilesSubject.sink.add(list);
};
Function(CloudFile) get removeCloudFile => (cloudFile) {
final list = <CloudFile>[];
list.addAll(_cloudFilesSubject.value);
list.remove(cloudFile);
_cloudFilesSubject.sink.add(list);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These methods for updating file lists can be made more concise and idiomatic by using modern Dart collection features like the spread operator to create new lists. This improves readability and aligns with the style guide's recommendation to use collection literals where possible.

  Function(List<LocalFile>) get addLocalFiles => (localFiles) {
    _localFilesSubject.sink.add([..._localFilesSubject.value, ...localFiles]);
  };
  Function(LocalFile) get removeLocalFile => (localFile) {
    final newList = [..._localFilesSubject.value]..remove(localFile);
    _localFilesSubject.sink.add(newList);
  };
  Function(CloudFile) get removeCloudFile => (cloudFile) {
    final newList = [..._cloudFilesSubject.value]..remove(cloudFile);
    _cloudFilesSubject.sink.add(newList);
  };
References
  1. The style guide recommends using collection literals when possible (line 86). The suggested change uses list literals with the spread operator for a more concise implementation. (link)

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Visit the preview URL for this PR (updated for commit 5635241):

https://sharezone-website-dev--pr2138-codex-add-file-uploa-xivetof7.web.app

(expires Fri, 06 Feb 2026 21:34:21 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 372b0431a96247f908d9a97d5d865de1c8b3b04e

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Visit the preview URL for this PR (updated for commit 5635241):

https://sharezone-test--pr2138-codex-add-file-uploa-5tug6tay.web.app

(expires Fri, 06 Feb 2026 21:38:19 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 4cb3ae61e1e018abfd9841fd3239f5b49ccc034b

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Visit the preview URL for this PR (updated for commit 5635241):

https://sharezone-console-dev--pr2138-codex-add-file-uploa-tab59jbx.web.app

(expires Fri, 06 Feb 2026 21:38:52 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 471536afe3f6ec4895d9ea75513730b515d17eb6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex Used for PRs that are generated by Codex. feature: file-sharing Files can be shared inside Sharezone e.g. by uploading them in a file-sharing folder of a course. feature: timetable / calendar Includes anything regarding lessons (timetable) and events (calendar). feature: universal file features File features (downloading, preview, etc.) that are used by multiple Sharezone features. testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant