Skip to content

Commit

Permalink
Rename "data layers" to "resources"
Browse files Browse the repository at this point in the history
Closes #92
  • Loading branch information
bkis committed Dec 14, 2023
1 parent d22e485 commit b1d56ac
Show file tree
Hide file tree
Showing 96 changed files with 3,223 additions and 3,111 deletions.
1,856 changes: 928 additions & 928 deletions Tekst-API/openapi.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Tekst-API/tekst/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from tekst.config import TekstConfig, get_config
from tekst.db import init_odm
from tekst.dependencies import get_db, get_db_client
from tekst.layer_types import init_layer_types_mgr
from tekst.logging import log, setup_logging
from tekst.openapi import customize_openapi
from tekst.resource_types import init_resource_types_mgr
from tekst.routers import setup_routes
from tekst.settings import get_settings

Expand All @@ -27,7 +27,7 @@ async def startup_routine(app: FastAPI) -> None:
# blank line for visual separation of app runs in dev mode
print(file=sys.stderr)

init_layer_types_mgr()
init_resource_types_mgr()
setup_routes(app)

# this is ugly, but unfortunately we don't have access to FastAPI's
Expand Down
34 changes: 17 additions & 17 deletions Tekst-API/tekst/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from tekst.config import TekstConfig, get_config
from tekst.email import TemplateIdentifier, send_email
from tekst.logging import log
from tekst.models.layer import LayerBaseDocument
from tekst.models.resource import ResourceBaseDocument
from tekst.models.unit import UnitBaseDocument
from tekst.models.user import UserCreate, UserDocument, UserRead, UserUpdate

Expand Down Expand Up @@ -227,33 +227,33 @@ async def on_after_reset_password(
async def on_before_delete(
self, user: UserDocument, request: Request | None = None
):
# find owned data layers
layers_docs = await LayerBaseDocument.find(
LayerBaseDocument.owner_id == user.id, with_children=True
# find owned resources
resources_docs = await ResourceBaseDocument.find(
ResourceBaseDocument.owner_id == user.id, with_children=True
).to_list()
owned_layers_ids = [layer.id for layer in layers_docs]
# delete units of owned data layers
owned_resources_ids = [resource.id for resource in resources_docs]
# delete units of owned resources
await UnitBaseDocument.find(
In(UnitBaseDocument.layer_id, owned_layers_ids),
In(UnitBaseDocument.resource_id, owned_resources_ids),
with_children=True,
).delete()
# delete owned data layers
await LayerBaseDocument.find_one(
In(LayerBaseDocument.id, owned_layers_ids),
# delete owned resources
await ResourceBaseDocument.find_one(
In(ResourceBaseDocument.id, owned_resources_ids),
with_children=True,
).delete()
# remove user ID from layer shares
await LayerBaseDocument.find(
LayerBaseDocument.shared_read == str(user.id),
# remove user ID from resource shares
await ResourceBaseDocument.find(
ResourceBaseDocument.shared_read == str(user.id),
with_children=True,
).update(
Pull(LayerBaseDocument.shared_read == str(user.id)),
Pull(ResourceBaseDocument.shared_read == str(user.id)),
)
await LayerBaseDocument.find(
LayerBaseDocument.shared_write == str(user.id),
await ResourceBaseDocument.find(
ResourceBaseDocument.shared_write == str(user.id),
with_children=True,
).update(
Pull(LayerBaseDocument.shared_write == str(user.id)),
Pull(ResourceBaseDocument.shared_write == str(user.id)),
)

async def on_after_delete(self, user: UserDocument, request: Request | None = None):
Expand Down
12 changes: 6 additions & 6 deletions Tekst-API/tekst/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

from tekst.auth import AccessToken
from tekst.config import TekstConfig, get_config
from tekst.layer_types import layer_types_mgr
from tekst.logging import log
from tekst.models.layer import LayerBaseDocument
from tekst.models.node import NodeDocument
from tekst.models.resource import ResourceBaseDocument
from tekst.models.segment import ClientSegmentDocument
from tekst.models.settings import PlatformSettingsDocument
from tekst.models.text import TextDocument
from tekst.models.unit import UnitBaseDocument
from tekst.models.user import UserDocument
from tekst.resource_types import resource_types_mgr


_cfg: TekstConfig = get_config()
Expand Down Expand Up @@ -44,16 +44,16 @@ async def init_odm(db: Database) -> None:
models = [
TextDocument,
NodeDocument,
LayerBaseDocument,
ResourceBaseDocument,
UnitBaseDocument,
PlatformSettingsDocument,
ClientSegmentDocument,
UserDocument,
AccessToken,
]
# add layer type models
for lt_class in layer_types_mgr.get_all().values():
models.append(lt_class.layer_model().document_model())
# add resource type models
for lt_class in resource_types_mgr.get_all().values():
models.append(lt_class.resource_model().document_model())
models.append(lt_class.unit_model().document_model())
# init beanie ODM
await init_beanie(database=db, allow_index_dropping=True, document_models=models)
207 changes: 0 additions & 207 deletions Tekst-API/tekst/layer_types/__init__.py

This file was deleted.

45 changes: 0 additions & 45 deletions Tekst-API/tekst/layer_types/debug.py

This file was deleted.

Loading

0 comments on commit b1d56ac

Please sign in to comment.