|
10 | 10 | import strawberry_django |
11 | 11 | from django.db import models |
12 | 12 | from strawberry import auto |
| 13 | +from strawberry.file_uploads import Upload |
13 | 14 | from strawberry.types import Info |
14 | 15 | from strawberry_django.mutations import mutations |
15 | 16 | from strawberry_django.pagination import OffsetPaginationInput |
@@ -59,13 +60,16 @@ class UpdateUseCaseMetadataInput: |
59 | 60 | sectors: List[uuid.UUID] |
60 | 61 |
|
61 | 62 |
|
| 63 | +use_case_running_status = strawberry.enum(UseCaseStatus) # type: ignore |
| 64 | + |
| 65 | + |
62 | 66 | @strawberry_django.partial(UseCase, fields="__all__", exclude=["datasets"]) |
63 | 67 | class UseCaseInputPartial: |
64 | 68 | """Input type for use case updates.""" |
65 | 69 |
|
66 | 70 | id: str |
67 | | - logo: auto |
68 | | - running_status: auto |
| 71 | + logo: Optional[Upload] = strawberry.field(default=None) |
| 72 | + running_status: Optional[use_case_running_status] = UseCaseStatus.DRAFT |
69 | 73 | title: Optional[str] = None |
70 | 74 | summary: Optional[str] = None |
71 | 75 | platform_url: Optional[str] = None |
@@ -367,11 +371,14 @@ def update_use_case(self, info: Info, data: UseCaseInputPartial) -> TypeUseCase: |
367 | 371 | usecase.platform_url = data.platform_url.strip() |
368 | 372 | if data.started_on is not None: |
369 | 373 | usecase.started_on = data.started_on |
370 | | - if data.completed_on is not None: |
| 374 | + if data.completed_on is not None and data.completed_on is not strawberry.UNSET: |
371 | 375 | usecase.completed_on = data.completed_on |
372 | | - if data.running_status is not None: |
373 | | - usecase.running_status = data.running_status.value |
374 | | - if data.logo is not None: |
| 376 | + if ( |
| 377 | + data.running_status is not None |
| 378 | + and data.running_status is not strawberry.UNSET |
| 379 | + ): |
| 380 | + usecase.running_status = data.running_status |
| 381 | + if data.logo is not None and data.logo is not strawberry.UNSET: |
375 | 382 | usecase.logo = data.logo |
376 | 383 | usecase.save() |
377 | 384 | return TypeUseCase.from_django(usecase) |
|
0 commit comments