Skip to content

Allow students to view the preview projects - #974

Open
DNR500 wants to merge 2 commits into
mainfrom
allow-students-to-view-preview-projects
Open

Allow students to view the preview projects#974
DNR500 wants to merge 2 commits into
mainfrom
allow-students-to-view-preview-projects

Conversation

@DNR500

@DNR500 DNR500 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Needs to allow student view checks on issue: 1659

Comes out of this work on editor-standalone - https://github.com/RaspberryPiFoundation/editor-standalone/pull/1064

Summary

Updated editor-api CanCan permissions so that school students can :show the Experience CS preview starter project used by the classroom preview route.

With this changes students are now allowed to view unowned (user_id: nil, school_id: nil) Scratch template projects.

This prevents the preview route in editor-standalone from failing project loading (which previously triggered a redirect to /${locale}/error).

@cla-bot cla-bot Bot added the cla-signed label Aug 19, 2026
@DNR500
DNR500 requested a lite review from Copilot August 19, 2026 15:38
@DNR500 DNR500 self-assigned this Aug 19, 2026
@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

Test coverage

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

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

Updates CanCanCan authorization in the Rails monolith to allow school students to access the unowned Experience CS preview starter project (and related data) so the editor-standalone classroom preview route can load the project successfully.

Changes:

  • Adds a student-specific :show permission for unowned Projects of type Project::Types::CODE_EDITOR_SCRATCH.
  • Adds a corresponding student-specific :show permission for Components belonging to those unowned scratch projects.

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

Comment thread app/models/ability.rb
Comment on lines +26 to +30
if user&.student?
# Allow students to view the Experience CS preview starter template.
can :show, Project, user_id: nil, school_id: nil, project_type: Project::Types::CODE_EDITOR_SCRATCH
can :show, Component, project: { user_id: nil, school_id: nil, project_type: Project::Types::CODE_EDITOR_SCRATCH }
return

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed

@DNR500
DNR500 marked this pull request as ready for review August 19, 2026 16:33
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.

3 participants