Skip to content

Allow Experience CS to sync public Scratch projects - #959

Merged
abcampo-iry merged 2 commits into
mainfrom
issues/1657
Aug 11, 2026
Merged

Allow Experience CS to sync public Scratch projects#959
abcampo-iry merged 2 commits into
mainfrom
issues/1657

Conversation

@abcampo-iry

@abcampo-iry abcampo-iry commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Status

What's changed?

  • Allow public, localized code_editor_scratch projects to contain instructions. This is a narrow exception to Restrict instructions to school projects (#479) for public Experience CS templates. This may be worth discussing.
  • Allow Experience CS admins to change a public project to code_editor_scratch.
  • Allow Experience CS admins to create or update Scratch data through the project update endpoint.

Some concerns of mine were to understand the cases:

  • Existing ExCS stub with no ScratchComponent -> Create ScratchComponent -> Store the ExCS code -> Change type from scratch to code_editor_scratch

  • Existing ExCS project with a ScratchComponent -> Replace its content with the latest ExCS code -> This is intentional because ExCS is the source of truth

  • User-owned project -> Cannot be updated by an experience-cs-admin -> Authorization prevents the overwrite

  • Unrelated public project with the same identifier -> Could currently be overwritten -> This is the known provenance/origin risk mentioned in the ticket

@cla-bot cla-bot Bot added the cla-signed label Aug 11, 2026
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

Test coverage

92.2% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/31479108559

@abcampo-iry
abcampo-iry force-pushed the issues/1657 branch 3 times, most recently from 65bcf27 to 4c9fec0 Compare August 11, 2026 09:13
@raspberrypiherokubot
raspberrypiherokubot temporarily deployed to editor-api-p-issues-165-tnrv7l August 11, 2026 09:19 Inactive
@abcampo-iry
abcampo-iry marked this pull request as ready for review August 11, 2026 09:33
Copilot AI lite review requested due to automatic review settings August 11, 2026 09:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Enables Experience CS administrators to synchronize public, localized Scratch-based templates by allowing updates to project type and Scratch SB3 payloads, and by widening the “instructions” validation exception for public code_editor_scratch projects.

Changes:

  • Allow public, localized code_editor_scratch projects to store instructions (model validation change + specs).
  • Permit Experience CS admins to update project_type and create/update a project’s ScratchComponent via the projects update endpoint.
  • Extend request/feature specs to cover Experience CS admin create/update flows and non-admin restrictions.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
spec/requests/projects/update_spec.rb Adds coverage for blocking non-admin type/Scratch updates and allowing Experience CS admin updates.
spec/models/project_spec.rb Verifies validation exception for instructions on public localized code_editor_scratch projects only.
spec/features/project/creating_a_project_spec.rb Updates Experience CS admin create flow to include instructions + Scratch SB3 payload.
lib/concepts/project/operations/update.rb Adds support for updating project_type and persisting a ScratchComponent during project update.
app/models/project.rb Relaxes instructions validation for public localized code_editor_scratch projects.
app/controllers/api/projects_controller.rb Makes project_type/scratch_component params conditional (create or Experience CS admin).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/controllers/api/projects_controller.rb
Comment thread lib/concepts/project/operations/update.rb

@zetter-rpf zetter-rpf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice one

@abcampo-iry
abcampo-iry merged commit fcd7f9f into main Aug 11, 2026
6 checks passed
@abcampo-iry
abcampo-iry deleted the issues/1657 branch August 11, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants