Skip to content

Commit ef61264

Browse files
committed
Rename resource DB field original_id to patch_for
Fixes #1682
1 parent cb38ee8 commit ef61264

38 files changed

+337
-205
lines changed

Tekst-API/demo/resources.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"text_id": { "$oid": "654ba1f3ec7833e469dde765" },
8484
"level": 0,
8585
"resource_type": "plainText",
86-
"original_id": null,
86+
"patch_for": null,
8787
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
8888
"shared_read": [],
8989
"shared_write": [],
@@ -121,7 +121,7 @@
121121
"text_id": { "$oid": "654ba1f3ec7833e469dde765" },
122122
"level": 0,
123123
"resource_type": "plainText",
124-
"original_id": null,
124+
"patch_for": null,
125125
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
126126
"shared_read": [],
127127
"shared_write": [],
@@ -163,7 +163,7 @@
163163
"text_id": { "$oid": "654ba1f3ec7833e469dde765" },
164164
"level": 0,
165165
"resource_type": "plainText",
166-
"original_id": null,
166+
"patch_for": null,
167167
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
168168
"shared_read": [],
169169
"shared_write": [],
@@ -206,7 +206,7 @@
206206
"text_id": { "$oid": "654b825533ee5737b297f8e3" },
207207
"level": 0,
208208
"resource_type": "images",
209-
"original_id": null,
209+
"patch_for": null,
210210
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
211211
"shared_read": [],
212212
"shared_write": [],
@@ -246,7 +246,7 @@
246246
"text_id": { "$oid": "654b825533ee5737b297f8e3" },
247247
"level": 0,
248248
"resource_type": "externalReferences",
249-
"original_id": null,
249+
"patch_for": null,
250250
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
251251
"shared_read": [],
252252
"shared_write": [],
@@ -285,7 +285,7 @@
285285
"text_id": { "$oid": "654b825533ee5737b297f8e3" },
286286
"level": 0,
287287
"resource_type": "audio",
288-
"original_id": null,
288+
"patch_for": null,
289289
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
290290
"shared_read": [],
291291
"shared_write": [],
@@ -324,7 +324,7 @@
324324
"text_id": { "$oid": "654b825533ee5737b297f8e3" },
325325
"level": 2,
326326
"resource_type": "plainText",
327-
"original_id": null,
327+
"patch_for": null,
328328
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
329329
"shared_read": [],
330330
"shared_write": [],
@@ -387,7 +387,7 @@
387387
"text_id": { "$oid": "654b825533ee5737b297f8e3" },
388388
"level": 2,
389389
"resource_type": "plainText",
390-
"original_id": null,
390+
"patch_for": null,
391391
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
392392
"shared_read": [],
393393
"shared_write": [],
@@ -439,7 +439,7 @@
439439
"text_id": { "$oid": "654b825533ee5737b297f8e3" },
440440
"level": 0,
441441
"resource_type": "externalReferences",
442-
"original_id": null,
442+
"patch_for": null,
443443
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
444444
"shared_read": [],
445445
"shared_write": [],
@@ -607,7 +607,7 @@
607607
"text_id": { "$oid": "654b825533ee5737b297f8e3" },
608608
"level": 0,
609609
"resource_type": "richText",
610-
"original_id": null,
610+
"patch_for": null,
611611
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
612612
"shared_read": [],
613613
"shared_write": [],
@@ -684,7 +684,7 @@
684684
"text_id": { "$oid": "654b825533ee5737b297f8e3" },
685685
"level": 1,
686686
"resource_type": "locationMetadata",
687-
"original_id": null,
687+
"patch_for": null,
688688
"owner_ids": [{ "$oid": "65c5fe0c691066aabd498239" }],
689689
"shared_read": [],
690690
"shared_write": [],

Tekst-API/openapi.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"title": "Tekst-Dev",
55
"summary": "An online text research platform",
66
"contact": {},
7-
"version": "0.50.2b0"
7+
"version": "0.51.0b0"
88
},
99
"servers": [
1010
{
@@ -8189,7 +8189,7 @@
81898189
"const": "apiCall",
81908190
"title": "Resourcetype"
81918191
},
8192-
"originalId": {
8192+
"patchFor": {
81938193
"anyOf": [
81948194
{
81958195
"$ref": "#/components/schemas/PydanticObjectId"
@@ -8388,7 +8388,7 @@
83888388
"const": "apiCall",
83898389
"title": "Resourcetype"
83908390
},
8391-
"originalId": {
8391+
"patchFor": {
83928392
"anyOf": [
83938393
{
83948394
"$ref": "#/components/schemas/PydanticObjectId"
@@ -8600,7 +8600,7 @@
86008600
"const": "apiCall",
86018601
"title": "Resourcetype"
86028602
},
8603-
"originalId": {
8603+
"patchFor": {
86048604
"anyOf": [
86058605
{
86068606
"$ref": "#/components/schemas/PydanticObjectId"
@@ -9027,7 +9027,7 @@
90279027
"const": "audio",
90289028
"title": "Resourcetype"
90299029
},
9030-
"originalId": {
9030+
"patchFor": {
90319031
"anyOf": [
90329032
{
90339033
"$ref": "#/components/schemas/PydanticObjectId"
@@ -9221,7 +9221,7 @@
92219221
"const": "audio",
92229222
"title": "Resourcetype"
92239223
},
9224-
"originalId": {
9224+
"patchFor": {
92259225
"anyOf": [
92269226
{
92279227
"$ref": "#/components/schemas/PydanticObjectId"
@@ -9428,7 +9428,7 @@
94289428
"const": "audio",
94299429
"title": "Resourcetype"
94309430
},
9431-
"originalId": {
9431+
"patchFor": {
94329432
"anyOf": [
94339433
{
94349434
"$ref": "#/components/schemas/PydanticObjectId"
@@ -10793,7 +10793,7 @@
1079310793
"const": "externalReferences",
1079410794
"title": "Resourcetype"
1079510795
},
10796-
"originalId": {
10796+
"patchFor": {
1079710797
"anyOf": [
1079810798
{
1079910799
"$ref": "#/components/schemas/PydanticObjectId"
@@ -10987,7 +10987,7 @@
1098710987
"const": "externalReferences",
1098810988
"title": "Resourcetype"
1098910989
},
10990-
"originalId": {
10990+
"patchFor": {
1099110991
"anyOf": [
1099210992
{
1099310993
"$ref": "#/components/schemas/PydanticObjectId"
@@ -11194,7 +11194,7 @@
1119411194
"const": "externalReferences",
1119511195
"title": "Resourcetype"
1119611196
},
11197-
"originalId": {
11197+
"patchFor": {
1119811198
"anyOf": [
1119911199
{
1120011200
"$ref": "#/components/schemas/PydanticObjectId"
@@ -11825,7 +11825,7 @@
1182511825
"const": "images",
1182611826
"title": "Resourcetype"
1182711827
},
11828-
"originalId": {
11828+
"patchFor": {
1182911829
"anyOf": [
1183011830
{
1183111831
"$ref": "#/components/schemas/PydanticObjectId"
@@ -12019,7 +12019,7 @@
1201912019
"const": "images",
1202012020
"title": "Resourcetype"
1202112021
},
12022-
"originalId": {
12022+
"patchFor": {
1202312023
"anyOf": [
1202412024
{
1202512025
"$ref": "#/components/schemas/PydanticObjectId"
@@ -12226,7 +12226,7 @@
1222612226
"const": "images",
1222712227
"title": "Resourcetype"
1222812228
},
12229-
"originalId": {
12229+
"patchFor": {
1223012230
"anyOf": [
1223112231
{
1223212232
"$ref": "#/components/schemas/PydanticObjectId"
@@ -13189,7 +13189,7 @@
1318913189
"const": "locationMetadata",
1319013190
"title": "Resourcetype"
1319113191
},
13192-
"originalId": {
13192+
"patchFor": {
1319313193
"anyOf": [
1319413194
{
1319513195
"$ref": "#/components/schemas/PydanticObjectId"
@@ -13390,7 +13390,7 @@
1339013390
"const": "locationMetadata",
1339113391
"title": "Resourcetype"
1339213392
},
13393-
"originalId": {
13393+
"patchFor": {
1339413394
"anyOf": [
1339513395
{
1339613396
"$ref": "#/components/schemas/PydanticObjectId"
@@ -13604,7 +13604,7 @@
1360413604
"const": "locationMetadata",
1360513605
"title": "Resourcetype"
1360613606
},
13607-
"originalId": {
13607+
"patchFor": {
1360813608
"anyOf": [
1360913609
{
1361013610
"$ref": "#/components/schemas/PydanticObjectId"
@@ -14425,7 +14425,7 @@
1442514425
"const": "plainText",
1442614426
"title": "Resourcetype"
1442714427
},
14428-
"originalId": {
14428+
"patchFor": {
1442914429
"anyOf": [
1443014430
{
1443114431
"$ref": "#/components/schemas/PydanticObjectId"
@@ -14634,7 +14634,7 @@
1463414634
"const": "plainText",
1463514635
"title": "Resourcetype"
1463614636
},
14637-
"originalId": {
14637+
"patchFor": {
1463814638
"anyOf": [
1463914639
{
1464014640
"$ref": "#/components/schemas/PydanticObjectId"
@@ -14856,7 +14856,7 @@
1485614856
"const": "plainText",
1485714857
"title": "Resourcetype"
1485814858
},
14859-
"originalId": {
14859+
"patchFor": {
1486014860
"anyOf": [
1486114861
{
1486214862
"$ref": "#/components/schemas/PydanticObjectId"
@@ -16478,7 +16478,7 @@
1647816478
"const": "richText",
1647916479
"title": "Resourcetype"
1648016480
},
16481-
"originalId": {
16481+
"patchFor": {
1648216482
"anyOf": [
1648316483
{
1648416484
"$ref": "#/components/schemas/PydanticObjectId"
@@ -16677,7 +16677,7 @@
1667716677
"const": "richText",
1667816678
"title": "Resourcetype"
1667916679
},
16680-
"originalId": {
16680+
"patchFor": {
1668116681
"anyOf": [
1668216682
{
1668316683
"$ref": "#/components/schemas/PydanticObjectId"
@@ -16889,7 +16889,7 @@
1688916889
"const": "richText",
1689016890
"title": "Resourcetype"
1689116891
},
16892-
"originalId": {
16892+
"patchFor": {
1689316893
"anyOf": [
1689416894
{
1689516895
"$ref": "#/components/schemas/PydanticObjectId"
@@ -17830,7 +17830,7 @@
1783017830
"const": "textAnnotation",
1783117831
"title": "Resourcetype"
1783217832
},
17833-
"originalId": {
17833+
"patchFor": {
1783417834
"anyOf": [
1783517835
{
1783617836
"$ref": "#/components/schemas/PydanticObjectId"
@@ -18033,7 +18033,7 @@
1803318033
"const": "textAnnotation",
1803418034
"title": "Resourcetype"
1803518035
},
18036-
"originalId": {
18036+
"patchFor": {
1803718037
"anyOf": [
1803818038
{
1803918039
"$ref": "#/components/schemas/PydanticObjectId"
@@ -18249,7 +18249,7 @@
1824918249
"const": "textAnnotation",
1825018250
"title": "Resourcetype"
1825118251
},
18252-
"originalId": {
18252+
"patchFor": {
1825318253
"anyOf": [
1825418254
{
1825518255
"$ref": "#/components/schemas/PydanticObjectId"

Tekst-API/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "tekst"
3-
version = "0.50.2b0"
3+
version = "0.51.0b0"
44
description = "An online text research platform"
55
readme = "README.md"
66
authors = [

Tekst-API/tekst/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ async def on_before_delete(
257257
):
258258
# turn patches of this resource into original resources
259259
await ResourceBaseDocument.find(
260-
ResourceBaseDocument.original_id == res.id,
260+
ResourceBaseDocument.patch_for == res.id,
261261
with_children=True,
262-
).set({ResourceBaseDocument.original_id: None})
262+
).set({ResourceBaseDocument.patch_for: None})
263263

264264
# delete contents belonging to the resource
265265
await ContentBaseDocument.find(
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from tekst.db import Database
2+
3+
4+
async def migration(db: Database) -> None:
5+
await db.resources.update_many(
6+
{},
7+
{"$rename": {"original_id": "patch_for"}},
8+
)

Tekst-API/tekst/models/resource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class ResourceBase(ModelBase, ModelFactoryMixin):
133133
),
134134
]
135135

136-
original_id: Annotated[
136+
patch_for: Annotated[
137137
PydanticObjectId | None,
138138
Field(
139139
description=(
@@ -277,10 +277,10 @@ def model_postprocess(self: "ResourceBase"):
277277
# resource patches are not searchable
278278
if self.config and self.config.general:
279279
self.config.general.searchable_quick = (
280-
self.config.general.searchable_quick and not self.original_id
280+
self.config.general.searchable_quick and not self.patch_for
281281
)
282282
self.config.general.searchable_adv = (
283-
self.config.general.searchable_adv and not self.original_id
283+
self.config.general.searchable_adv and not self.patch_for
284284
)
285285
return self
286286

Tekst-API/tekst/models/text.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
from beanie import PydanticObjectId
66
from beanie.operators import Eq
7-
from pydantic import (
8-
ConfigDict,
9-
Field,
10-
field_validator,
11-
)
7+
from pydantic import Field, field_validator
128
from pydantic_extra_types.color import Color
139
from typing_extensions import TypedDict
1410

@@ -320,5 +316,4 @@ class LocationDefinition(ModelBase):
320316

321317

322318
class TextStructureImportData(ModelBase):
323-
model_config = ConfigDict(extra="allow")
324319
locations: list[LocationDefinition] = []

0 commit comments

Comments
 (0)