mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-28 23:04:34 +08:00
Merge pull request #8536 from Ultimaker/CURA-7717_Add_Essentials_subscription_information_in_slice_data
CURA-7717: Add subscription information in slice data
This commit is contained in:
commit
3c7422f172
@ -1,11 +1,11 @@
|
||||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from datetime import datetime
|
||||
import json
|
||||
import random
|
||||
from hashlib import sha512
|
||||
from base64 import b64encode
|
||||
from typing import Optional
|
||||
from typing import Optional, Any, Dict, Tuple
|
||||
|
||||
import requests
|
||||
|
||||
@ -16,6 +16,7 @@ from cura.OAuth2.Models import AuthenticationResponse, UserProfile, OAuth2Settin
|
||||
catalog = i18nCatalog("cura")
|
||||
TOKEN_TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S"
|
||||
|
||||
|
||||
class AuthorizationHelpers:
|
||||
"""Class containing several helpers to deal with the authorization flow."""
|
||||
|
||||
@ -121,10 +122,13 @@ class AuthorizationHelpers:
|
||||
if not user_data or not isinstance(user_data, dict):
|
||||
Logger.log("w", "Could not parse user data from token: %s", user_data)
|
||||
return None
|
||||
|
||||
return UserProfile(
|
||||
user_id = user_data["user_id"],
|
||||
username = user_data["username"],
|
||||
profile_image_url = user_data.get("profile_image_url", "")
|
||||
profile_image_url = user_data.get("profile_image_url", ""),
|
||||
organization_id = user_data.get("organization", {}).get("organization_id", ""),
|
||||
subscriptions = user_data.get("subscriptions", [])
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from typing import Optional, Dict, Any
|
||||
from typing import Optional, Dict, Any, List
|
||||
|
||||
|
||||
class BaseModel:
|
||||
@ -27,6 +27,8 @@ class UserProfile(BaseModel):
|
||||
user_id = None # type: Optional[str]
|
||||
username = None # type: Optional[str]
|
||||
profile_image_url = None # type: Optional[str]
|
||||
organization_id = None # type: Optional[str]
|
||||
subscriptions = None # type: Optional[List[Dict[str, Any]]]
|
||||
|
||||
|
||||
class AuthenticationResponse(BaseModel):
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import json
|
||||
@ -116,6 +116,7 @@ class SliceInfo(QObject, Extension):
|
||||
|
||||
machine_manager = self._application.getMachineManager()
|
||||
print_information = self._application.getPrintInformation()
|
||||
user_profile = self._application.getCuraAPI().account.userProfile
|
||||
|
||||
global_stack = machine_manager.activeMachine
|
||||
|
||||
@ -124,6 +125,8 @@ class SliceInfo(QObject, Extension):
|
||||
data["schema_version"] = 0
|
||||
data["cura_version"] = self._application.getVersion()
|
||||
data["cura_build_type"] = ApplicationMetadata.CuraBuildType
|
||||
data["organization_id"] = user_profile.get("organization_id", None) if user_profile else None
|
||||
data["subscriptions"] = user_profile.get("subscriptions", []) if user_profile else []
|
||||
|
||||
active_mode = self._application.getPreferences().getValue("cura/active_mode")
|
||||
if active_mode == 0:
|
||||
|
@ -1,12 +1,17 @@
|
||||
<html>
|
||||
<body>
|
||||
<b>Cura Version:</b> 4.0<br/>
|
||||
<b>Cura Version:</b> 4.8<br/>
|
||||
<b>Operating System:</b> Windows 10<br/>
|
||||
<b>Language:</b> en_US<br/>
|
||||
<b>Machine Type:</b> Ultimaker S5<br/>
|
||||
<b>Intent Profile:</b> Default<br/>
|
||||
<b>Quality Profile:</b> Fast<br/>
|
||||
<b>Using Custom Settings:</b> No
|
||||
<b>Using Custom Settings:</b> No<br/>
|
||||
<b>Organization ID (if any):</b> ABCDefGHIjKlMNOpQrSTUvYxWZ0-1234567890abcDE=<br/>
|
||||
<b>Subscriptions (if any):</b>
|
||||
<ul>
|
||||
<li><b>Level:</b> 10, <b>Type:</b> Enterprise, <b>Plan:</b> Basic</li>
|
||||
</ul>
|
||||
|
||||
<h3>Extruder 1:</h3>
|
||||
<ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user