forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨add preference to allow data collections form services (ITISFoundati…
…on#5112) Co-authored-by: Andrei Neagu <[email protected]>
- Loading branch information
Showing
14 changed files
with
150 additions
and
28 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
packages/models-library/src/models_library/shared_user_preferences.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from .user_preferences import FrontendUserPreference | ||
|
||
|
||
class AllowMetricsCollectionFrontendUserPreference(FrontendUserPreference): | ||
preference_identifier: str = "allowMetricsCollection" | ||
value: bool = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...r-v2/src/simcore_service_director_v2/modules/db/repositories/user_preferences_frontend.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from models_library.products import ProductName | ||
from models_library.user_preferences import FrontendUserPreference, PreferenceName | ||
from models_library.users import UserID | ||
from simcore_postgres_database.utils_user_preferences import FrontendUserPreferencesRepo | ||
|
||
from ._base import BaseRepository | ||
|
||
|
||
def _get_user_preference_name(user_id: UserID, preference_name: PreferenceName) -> str: | ||
return f"{user_id}/{preference_name}" | ||
|
||
|
||
class UserPreferencesFrontendRepository(BaseRepository): | ||
async def get_user_preference( | ||
self, | ||
*, | ||
user_id: UserID, | ||
product_name: ProductName, | ||
preference_class: type[FrontendUserPreference], | ||
) -> FrontendUserPreference | None: | ||
async with self.db_engine.acquire() as conn: | ||
preference_payload: dict | None = await FrontendUserPreferencesRepo.load( | ||
conn, | ||
user_id=user_id, | ||
preference_name=_get_user_preference_name( | ||
user_id, preference_class.get_preference_name() | ||
), | ||
product_name=product_name, | ||
) | ||
|
||
return ( | ||
None | ||
if preference_payload is None | ||
else preference_class.parse_obj(preference_payload) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.