-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make changes to collections to support publicly listed collections (#…
…2164) Fixes #2158 - Adds `Organization.listPublicCollections` field and API endpoint to update it - Replaces `Collection.isPublic` boolean with `Collection.access` (values: `private`, `unlisted`, `public`) and add database migration - Update frontend to use `Collection.access` instead of `isPublic`, otherwise not changing current behavior --------- Co-authored-by: sua yoo <[email protected]>
- Loading branch information
Showing
11 changed files
with
224 additions
and
28 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
backend/btrixcloud/migrations/migration_0036_coll_visibility.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,49 @@ | ||
""" | ||
Migration 0036 -- collection access | ||
""" | ||
|
||
from btrixcloud.migrations import BaseMigration | ||
|
||
|
||
MIGRATION_VERSION = "0036" | ||
|
||
|
||
class Migration(BaseMigration): | ||
"""Migration class.""" | ||
|
||
# pylint: disable=unused-argument | ||
def __init__(self, mdb, **kwargs): | ||
super().__init__(mdb, migration_version=MIGRATION_VERSION) | ||
|
||
async def migrate_up(self): | ||
"""Perform migration up. | ||
Move from Collection.isPublic cool to Collection.access enum | ||
""" | ||
colls_mdb = self.mdb["collections"] | ||
|
||
# Set non-public collections to private | ||
try: | ||
await colls_mdb.update_many( | ||
{"isPublic": False}, | ||
{"$set": {"access": "private"}, "$unset": {"isPublic": 1}}, | ||
) | ||
# pylint: disable=broad-exception-caught | ||
except Exception as err: | ||
print( | ||
f"Error migrating private collections: {err}", | ||
flush=True, | ||
) | ||
|
||
# Set public collections to unlisted | ||
try: | ||
await colls_mdb.update_many( | ||
{"isPublic": True}, | ||
{"$set": {"access": "unlisted"}, "$unset": {"isPublic": 1}}, | ||
) | ||
# pylint: disable=broad-exception-caught | ||
except Exception as err: | ||
print( | ||
f"Error migrating public unlisted collections: {err}", | ||
flush=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
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.