From 15c1b96d7be21a301d1dc7a6b08221946a277429 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 7 Jul 2022 15:04:15 +0200 Subject: [PATCH] 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. --- .../DigitalLibrary/src/DigitalFactoryProjectResponse.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/DigitalLibrary/src/DigitalFactoryProjectResponse.py b/plugins/DigitalLibrary/src/DigitalFactoryProjectResponse.py index a511a11bd5..bef90e5125 100644 --- a/plugins/DigitalLibrary/src/DigitalFactoryProjectResponse.py +++ b/plugins/DigitalLibrary/src/DigitalFactoryProjectResponse.py @@ -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. + from datetime import datetime from typing import Optional, List, Dict, Any from .BaseModel import BaseModel from .DigitalFactoryFileResponse import DIGITAL_FACTORY_RESPONSE_DATETIME_FORMAT +from UM.i18n import i18nCatalog +catalog = i18nCatalog("cura") class DigitalFactoryProjectResponse(BaseModel): """Class representing a cloud project.""" @@ -13,8 +16,8 @@ class DigitalFactoryProjectResponse(BaseModel): def __init__(self, library_project_id: str, display_name: str, - username: str, - organization_shared: bool, + username: str = catalog.i18nc("@text Placeholder for the username if it has been deleted", "deleted user"), + organization_shared: bool = False, last_updated: Optional[str] = None, created_at: Optional[str] = None, thumbnail_url: Optional[str] = None,