-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from UoA-eResearch/IDS-952-decide-and-implement…
…-persistence IDS-952 Handle and store archiving request
- Loading branch information
Showing
10 changed files
with
600 additions
and
14 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,116 @@ GET {{server_url}}/api/v1/resdriveinfo | |
x-api-key: {{api_key}} | ||
|
||
### | ||
|
||
POST http://localhost:8000/api/v1/resdriveinfo | ||
?drive_id={{drive_id}} | ||
x-api-key: {{api_key}} | ||
|
||
{ | ||
"id": 383, | ||
"title": "Monteith Research Art Archive", | ||
"description": "<span>The works often explore the political dimensions of culture engaged in turmoil over land ownership, history and occupation. Her work traverses political movements, contemporary sports, culture and social activities. Alex\u2019s projects often take place in large-scale or extreme geographies. Her surfing-related projects connect museum spaces directly to local geography through participatory performance projects.<br><br></span>An archive of UofA funded visual art video, performance and photo work I have produced since in appointment in 2008. Bring together 2008 to 2014 archive already held on tape backup at UofA, with current research projects, to make the older work accessible to me for re-publishing, and to back-up currently exposed research created from 2014 to 2018.", | ||
"division": "CAI", | ||
"codes": [ | ||
{ | ||
"code": "cer00383", | ||
"href": "/project/383/code/766", | ||
"id": 766 | ||
}, | ||
{ | ||
"code": "rescai201800001", | ||
"href": "/project/383/code/767", | ||
"id": 767 | ||
} | ||
], | ||
"status": { | ||
"href": "/projectstatus/1", | ||
"id": 1, | ||
"name": "Open" | ||
}, | ||
"start_date": "2018-04-09", | ||
"end_date": "2023-04-09", | ||
"next_review_date": "2023-04-09", | ||
"last_modified": "2022-11-16T00:18:14Z", | ||
"requirements": "", | ||
"services": { | ||
"dropbox": [], | ||
"href": "/project/383/service", | ||
"mytardis": [], | ||
"nectar": [], | ||
"research_drive": [ | ||
{ | ||
"allocated_gb": 25600.0, | ||
"archived": 0, | ||
"date": "2024-10-13", | ||
"deleted": 0, | ||
"first_day": "2018-04-09", | ||
"free_gb": 24894.5, | ||
"id": 138, | ||
"last_day": null, | ||
"name": "rescai201800001-MonteithResearchArt", | ||
"num_files": 50102, | ||
"percentage_used": 2.75578, | ||
"project_code": "rescai201800001", | ||
"used_gb": 705.479 | ||
} | ||
], | ||
"uoaivm": [], | ||
"vis": [], | ||
"vm": [] | ||
}, | ||
"members": [ | ||
{ | ||
"id": 1421, | ||
"person.email": "[email protected]", | ||
"person.full_name": "Alex Monteith", | ||
"person.identities": { | ||
"href": "/person/120/identity", | ||
"items": [ | ||
{ | ||
"href": "/person/120/identity/235", | ||
"id": 235, | ||
"username": "amon011" | ||
} | ||
] | ||
}, | ||
"person.status": { | ||
"href": "/personstatus/1", | ||
"id": 1, | ||
"name": "Active" | ||
}, | ||
"role": { | ||
"href": "/personrole/1", | ||
"id": 1, | ||
"name": "Project Owner" | ||
}, | ||
"notes": "" | ||
}, | ||
{ | ||
"id": 1420, | ||
"person.email": "[email protected]", | ||
"person.full_name": "Yvette Wharton", | ||
"person.identities": { | ||
"href": "/person/12/identity", | ||
"items": [ | ||
{ | ||
"href": "/person/12/identity/20", | ||
"id": 20, | ||
"username": "ywha001" | ||
} | ||
] | ||
}, | ||
"person.status": { | ||
"href": "/personstatus/1", | ||
"id": 1, | ||
"name": "Active" | ||
}, | ||
"role": { | ||
"href": "/personrole/7", | ||
"id": 7, | ||
"name": "Primary Adviser" | ||
}, | ||
"notes": "" | ||
} | ||
] | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Data models representing project members - person in a project and their role.""" | ||
|
||
from sqlmodel import Field, Relationship, SQLModel | ||
|
||
from models.person import Person | ||
from models.project import Project | ||
from models.role import Role | ||
|
||
|
||
class Member(SQLModel, table=True): | ||
"""Linking table between projects, people and their roles.""" | ||
|
||
project_id: int | None = Field( | ||
default=None, foreign_key="project.id", primary_key=True | ||
) | ||
person_id: int | None = Field( | ||
default=None, foreign_key="person.id", primary_key=True | ||
) | ||
role_id: int | None = Field(default=None, foreign_key="role.id", primary_key=True) | ||
|
||
role: "Role" = Relationship() | ||
project: "Project" = Relationship(back_populates="members") | ||
person: "Person" = Relationship() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Data models representing people and their identities.""" | ||
|
||
from typing import Optional | ||
|
||
from sqlmodel import Field, SQLModel | ||
|
||
from models.role import Role | ||
|
||
|
||
class InputIdentity(SQLModel): | ||
"""Data class for the identity list in POST request.""" | ||
|
||
username: str | ||
|
||
|
||
class InputIdentityResultItems(SQLModel): | ||
"""The set of result items from Project DB API.""" | ||
|
||
href: str | ||
items: list[InputIdentity] | ||
|
||
|
||
class InputPerson(SQLModel): | ||
"Data class for a Person model in POST request." | ||
id: Optional[int] = Field(default=None, primary_key=True) | ||
email: Optional[str] = Field(schema_extra={"validation_alias": "person.email"}) | ||
full_name: str = Field(schema_extra={"validation_alias": "person.full_name"}) | ||
identities: InputIdentityResultItems = Field( | ||
schema_extra={"validation_alias": "person.identities"} | ||
) | ||
role: Role | ||
|
||
|
||
class Person(SQLModel, table=True): | ||
"Data class for a Person model in database." | ||
id: Optional[int] = Field(default=None, primary_key=True) | ||
email: Optional[str] | ||
full_name: str | ||
username: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"""Data models representing projects.""" | ||
|
||
from datetime import datetime | ||
from typing import TYPE_CHECKING, Optional | ||
|
||
from sqlmodel import Field, Relationship, SQLModel | ||
|
||
from models.person import InputPerson | ||
from models.services import InputServices, Services | ||
|
||
# Only import Member during typechecking to prevent circular dependency error. | ||
if TYPE_CHECKING: | ||
from models.member import Member | ||
|
||
|
||
class Code(SQLModel, table=True): | ||
"""Model for project codes.""" | ||
|
||
id: Optional[int] = Field(primary_key=True) | ||
code: str | ||
|
||
|
||
class BaseProject(SQLModel): | ||
"""Base model for describing a project.""" | ||
|
||
title: str | ||
description: str | ||
division: str | ||
start_date: datetime | ||
end_date: datetime | ||
|
||
|
||
class InputProject(BaseProject): | ||
"""Input project model for data received from POST""" | ||
|
||
id: Optional[int] = Field(default=None, primary_key=True) | ||
members: list[InputPerson] | ||
codes: list[Code] | ||
services: InputServices | ||
|
||
|
||
class ProjectCodeLink(SQLModel, table=True): | ||
"""Linking table between project and codes""" | ||
|
||
code_id: int | None = Field(default=None, foreign_key="code.id", primary_key=True) | ||
project_id: int | None = Field( | ||
default=None, foreign_key="project.id", primary_key=True | ||
) | ||
|
||
|
||
class Project(BaseProject, table=True): | ||
"""Project model for data stored in database""" | ||
|
||
id: Optional[int] = Field(default=None, primary_key=True) | ||
services_id: int | None = Field(default=None, foreign_key="services.id") | ||
codes: list[Code] = Relationship(link_model=ProjectCodeLink) | ||
services: Services = Relationship() | ||
members: list["Member"] = Relationship( | ||
# cascade_delete enabled so session.merge() works for project save. | ||
back_populates="project", | ||
cascade_delete=True, | ||
) |
Oops, something went wrong.