Skip to content

feat(GAT-1111): add ProjectGrant create endpoint#1695

Open
cocoon02 wants to merge 3 commits into
HDRUK:devfrom
cocoon02:feat/cruk-dummy-data-seeding
Open

feat(GAT-1111): add ProjectGrant create endpoint#1695
cocoon02 wants to merge 3 commits into
HDRUK:devfrom
cocoon02:feat/cruk-dummy-data-seeding

Conversation

@cocoon02

@cocoon02 cocoon02 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds POST /api/v1/project_grants to create a ProjectGrant plus initial version.
Adds request validation via CreateProjectGrant.
Adds feature coverage for creating a grant (incl. version + dataset link).

Test plan
php artisan test --filter ProjectGrantTest

cocoon02 added 2 commits July 7, 2026 10:09
Keep DatasetSeeder and DatasetVersionSeeder unchanged for default HDRUK seeding; add CRUKDatasetSeeder and CRUKDatasetVersionSeeder for optional CRUK fixture data.
Adds POST /api/v1/project_grants with request validation and a feature test.
@cocoon02
cocoon02 requested review from calmacx and spco July 7, 2026 09:20
@cocoon02
cocoon02 requested review from a team as code owners July 7, 2026 09:20
@gh-actions-pipelines-app

Copy link
Copy Markdown

🚨 Invalid PR title format!

Your PR title must follow one of these formats:

  • feat(GAT-1234): Your title
  • fix!(GAT-5678): Breaking change
  • RELEASE: vX.Y.Z

Please update your PR title accordingly. 😊

$input = $request->validated();

$grant = ProjectGrant::create([
'pid' => $input['pid'],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If these are meant to be unique, might it be worth checking?

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.

I too question this. For object creation I'd imagine that this would be generated in real-time via UUID or something similar, but this appears to come from the client, is that correct? Does the client create unique pids?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Looking at the dataset metadata structure (e.g. dataset_00.json), a project grant is supplied as an object where pid is the grant ID:

"projectGrants": [
{
"pid": "ORT105",
"projectGrantName": "Pancreatic Cancer Radiomics Integration",
"leadResearcher": "Dr. Miller",
...
}
]
So pid (e.g. "ORT105") is the grant identifier and is part of the project grant object the client supplies on create — not something we generate separately. Sarah supplied something like CRCXX-XXXXXXXXX.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread config/routes.php Outdated
'path' => '/project_grants',
'methodController' => 'ProjectGrantController@store',
'namespaceController' => 'App\Http\Controllers\Api\V1',
'middleware' => [],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Must add the correct middleware. At least 'jwt.verify' but we probably also want to add in specific permissions for projectgrant.create etc into the permissions model. That is likely a bigger piece of work though,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

{
try {
$input = $request->validated();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please ensure you use the getAccessorUserAndTeam trait to standardise and validate the input payload, and then use checkAccess to control access.

TBH we need to agree the ownership model for ProjectGrants - are they owned by Teams, by Users, or by either? See also later comment about permissions model needing to be extended in light of that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. They are owned by the Teams .

@cocoon02 cocoon02 changed the title feat(GAT-0000)t: add ProjectGrant create endpoint feat(GAT-1111): add ProjectGrant create endpoint Jul 7, 2026
@gh-actions-pipelines-app

Copy link
Copy Markdown

🎉 Great job! Your PR title follows the correct format. 🚀

]);
}

public function test_store_creates_project_grant_with_version_and_dataset_links(): void

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.

Once the middleware for jwt.verify has been included above, per Sam's comment, this test will fail and will need addressing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

- Require jwt.verify and check.access:permissions,project_grants.create on POST /project_grants
- Add project_grants.* permissions to seeders and a migration for existing databases
- Resolve acting user/team via getAccessorUserAndTeam and enforce team access with checkAccess
- Validate pid uniqueness on create; extend feature tests for auth and permission paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants