Fix crash if a Digital Library project is made by deleted user

If the user that created a project has been deleted, the response from the API doesn't include a username. This crashes Cura because it had no default for the username.
The organization_shared field was also optional.

Done as a small fry to fix a bug found by a colleague.
This commit is contained in:
Ghostkeeper 2022-07-07 15:04:15 +02:00
parent 4d98ba3540
commit 15c1b96d7b
No known key found for this signature in database
GPG key ID: 68F39EA88EEED5FF

View file

@ -1,11 +1,14 @@
# Copyright (c) 2021 Ultimaker B.V. # Copyright (c) 2022 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from datetime import datetime from datetime import datetime
from typing import Optional, List, Dict, Any from typing import Optional, List, Dict, Any
from .BaseModel import BaseModel from .BaseModel import BaseModel
from .DigitalFactoryFileResponse import DIGITAL_FACTORY_RESPONSE_DATETIME_FORMAT from .DigitalFactoryFileResponse import DIGITAL_FACTORY_RESPONSE_DATETIME_FORMAT
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
class DigitalFactoryProjectResponse(BaseModel): class DigitalFactoryProjectResponse(BaseModel):
"""Class representing a cloud project.""" """Class representing a cloud project."""
@ -13,8 +16,8 @@ class DigitalFactoryProjectResponse(BaseModel):
def __init__(self, def __init__(self,
library_project_id: str, library_project_id: str,
display_name: str, display_name: str,
username: str, username: str = catalog.i18nc("@text Placeholder for the username if it has been deleted", "deleted user"),
organization_shared: bool, organization_shared: bool = False,
last_updated: Optional[str] = None, last_updated: Optional[str] = None,
created_at: Optional[str] = None, created_at: Optional[str] = None,
thumbnail_url: Optional[str] = None, thumbnail_url: Optional[str] = None,