|
22 | 22 | ProjectNotTrashedError, |
23 | 23 | ProjectRunningConflictError, |
24 | 24 | ) |
25 | | -from .models import ProjectPatchInternalExtended |
| 25 | +from .models import ProjectDict, ProjectPatchInternalExtended |
26 | 26 |
|
27 | 27 | _logger = logging.getLogger(__name__) |
28 | 28 |
|
@@ -128,6 +128,13 @@ async def untrash_project( |
128 | 128 | ) |
129 | 129 |
|
130 | 130 |
|
| 131 | +def _get_trashed_fields(project: ProjectDict): |
| 132 | + trashed_at = project.get("trashed") |
| 133 | + trashed_by = project.get("trashedBy") |
| 134 | + trashed_explicitly = project.get("trashedExplicitly") |
| 135 | + return trashed_at, trashed_by, trashed_explicitly |
| 136 | + |
| 137 | + |
131 | 138 | async def list_trashed_projects( |
132 | 139 | app: web.Application, |
133 | 140 | *, |
@@ -155,9 +162,7 @@ async def list_trashed_projects( |
155 | 162 | # by defining a custom trash_filter that permits some flexibility in the filtering options |
156 | 163 | trashed_projects = [] |
157 | 164 | for project in projects: |
158 | | - trashed_at = project.get("trashed_at") |
159 | | - trashed_by = project.get("trashed_by") |
160 | | - trashed_explicitly = project.get("trashed_explicitly") |
| 165 | + trashed_at, trashed_by, trashed_explicitly = _get_trashed_fields(project) |
161 | 166 |
|
162 | 167 | if ( |
163 | 168 | trashed_at |
@@ -191,9 +196,7 @@ async def delete_trashed_project( |
191 | 196 | if not project: |
192 | 197 | raise ProjectNotFoundError(project_uuid=project_id, user_id=user_id) |
193 | 198 |
|
194 | | - trashed_at = project.get("trashed_at") |
195 | | - trashed_by = project.get("trashed_by") |
196 | | - trashed_explicitly = project.get("trashed_explicitly") |
| 199 | + trashed_at, trashed_by, trashed_explicitly = _get_trashed_fields(project) |
197 | 200 |
|
198 | 201 | if ( |
199 | 202 | not trashed_at |
|
0 commit comments