Skip to content

Add patch endpoint for file role edition #530

Description

@solenuk

As a developer I want to add a PATCH endpoint to update a file's role so that a user can correct a wrongly assigned role on a file without deleting and re-uploading it.

Assumptions & Constraints

  • Role can only be changed to one of the existing FileRole values, GENERIC, PROBLEM, REFERENCE, or SOLUTION.
  • Only the user who uploaded the file, or an ADMIN, can change its role.
  • The role can be changed only for ATTACHED files.
  • Changing a file's role doesn't touch its storage, filename, or any other metadata.

Preconditions

  1. FileAsset, FileRole, FileService and FileController already exist.

Business rules

  1. A file's role can be set to GENERIC, PROBLEM, REFERENCE, or SOLUTION.
  2. Only the file's uploader or an ADMIN can change its role.
  3. Changing the role doesn't affect the file's status or any other field.
  4. A request for a file id that doesn't exist results in a 404.

Acceptance Criteria

  • A PATCH endpoint accepts a file id and a new role, and updates it.
  • A request from the file's uploader succeeds.
  • A request from an ADMIN who didn't upload the file succeeds.
  • A request from anyone else is rejected with a 403.
  • A request for a file id that doesn't exist returns a 404.

Out of scope

  • Validating a role change against any requirements set on a related tour or task assignment.
  • Any change to file upload, attach, detach, or delete.
  • Bulk role updates across multiple files at once.

Epic link
Epic #115 - EPIC: File Management

Tasks

    • Add the request DTO for the new role.
    • Add the PATCH endpoint, restricted to the uploader or ADMIN.
    • Implement the service method that updates the role.
    • Confirm the 403 and 404 responses behave as expected.

Activity

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

Metadata

Metadata

Assignees

Type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions