Skip to content

Commit

Permalink
Dev layer categories (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkis authored Dec 7, 2023
2 parents 4ef8828 + 35a15e0 commit 930ca36
Show file tree
Hide file tree
Showing 16 changed files with 588 additions and 44 deletions.
175 changes: 175 additions & 0 deletions Tekst-API/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4101,6 +4101,19 @@
"title": "Ownerid",
"description": "User owning this layer"
},
"category": {
"anyOf": [
{
"type": "string",
"maxLength": 16
},
{
"type": "null"
}
],
"title": "Category",
"description": "Data layer category key"
},
"sharedRead": {
"items": {
"type": "string",
Expand Down Expand Up @@ -4285,6 +4298,19 @@
"title": "Ownerid",
"description": "User owning this layer"
},
"category": {
"anyOf": [
{
"type": "string",
"maxLength": 16
},
{
"type": "null"
}
],
"title": "Category",
"description": "Data layer category key"
},
"sharedRead": {
"items": {
"type": "string",
Expand Down Expand Up @@ -4429,6 +4455,19 @@
"title": "Ownerid",
"description": "User owning this layer"
},
"category": {
"anyOf": [
{
"type": "string",
"maxLength": 16
},
{
"type": "null"
}
],
"title": "Category",
"description": "Data layer category key"
},
"sharedRead": {
"items": {
"type": "string",
Expand Down Expand Up @@ -4827,6 +4866,73 @@
"type": "object",
"title": "HTTPValidationError"
},
"LayerCategory-Input": {
"properties": {
"key": {
"type": "string",
"maxLength": 16,
"minLength": 1,
"title": "Key"
},
"translations": {
"items": {
"$ref": "#/components/schemas/LayerCategoryTranslation"
},
"type": "array",
"maxItems": 3,
"title": "Translations"
}
},
"type": "object",
"required": [
"key",
"translations"
],
"title": "LayerCategory"
},
"LayerCategory-Output": {
"properties": {
"key": {
"type": "string",
"maxLength": 16,
"minLength": 1,
"title": "Key"
},
"translations": {
"items": {
"$ref": "#/components/schemas/LayerCategoryTranslation"
},
"type": "array",
"maxItems": 3,
"title": "Translations"
}
},
"type": "object",
"required": [
"key",
"translations"
],
"title": "LayerCategory"
},
"LayerCategoryTranslation": {
"properties": {
"locale": {
"$ref": "#/components/schemas/Locale"
},
"translation": {
"type": "string",
"maxLength": 32,
"minLength": 1,
"title": "Translation"
}
},
"type": "object",
"required": [
"locale",
"translation"
],
"title": "LayerCategoryTranslation"
},
"LayerCommentTranslation": {
"properties": {
"locale": {
Expand Down Expand Up @@ -5178,6 +5284,19 @@
"title": "Ownerid",
"description": "User owning this layer"
},
"category": {
"anyOf": [
{
"type": "string",
"maxLength": 16
},
{
"type": "null"
}
],
"title": "Category",
"description": "Data layer category key"
},
"sharedRead": {
"items": {
"type": "string",
Expand Down Expand Up @@ -5362,6 +5481,19 @@
"title": "Ownerid",
"description": "User owning this layer"
},
"category": {
"anyOf": [
{
"type": "string",
"maxLength": 16
},
{
"type": "null"
}
],
"title": "Category",
"description": "Data layer category key"
},
"sharedRead": {
"items": {
"type": "string",
Expand Down Expand Up @@ -5506,6 +5638,19 @@
"title": "Ownerid",
"description": "User owning this layer"
},
"category": {
"anyOf": [
{
"type": "string",
"maxLength": 16
},
{
"type": "null"
}
],
"title": "Category",
"description": "Data layer category key"
},
"sharedRead": {
"items": {
"type": "string",
Expand Down Expand Up @@ -5993,6 +6138,21 @@
"description": "Custom label for main navigation info entry",
"default": []
},
"layerCategories": {
"items": {
"$ref": "#/components/schemas/LayerCategory-Output"
},
"type": "array",
"title": "Layercategories",
"description": "Layer categories to categorize layers in",
"default": []
},
"showLayerCategoryHeadings": {
"type": "boolean",
"title": "Showlayercategoryheadings",
"description": "Show layer category headings in browse view",
"default": true
},
"alwaysShowTextInfo": {
"type": "boolean",
"title": "Alwaysshowtextinfo",
Expand Down Expand Up @@ -6126,6 +6286,21 @@
"description": "Custom label for main navigation info entry",
"default": []
},
"layerCategories": {
"items": {
"$ref": "#/components/schemas/LayerCategory-Input"
},
"type": "array",
"title": "Layercategories",
"description": "Layer categories to categorize layers in",
"default": []
},
"showLayerCategoryHeadings": {
"type": "boolean",
"title": "Showlayercategoryheadings",
"description": "Show layer category headings in browse view",
"default": true
},
"alwaysShowTextInfo": {
"type": "boolean",
"title": "Alwaysshowtextinfo",
Expand Down
4 changes: 4 additions & 0 deletions Tekst-API/tekst/models/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class LayerBase(ModelBase, ModelFactoryMixin):
owner_id: Annotated[
PydanticObjectId | None, Field(description="User owning this layer")
] = None
category: Annotated[
str | None,
Field(description="Data layer category key", max_length=16),
] = None
shared_read: Annotated[
list[PydanticObjectId],
Field(description="Users with shared read access to this layer"),
Expand Down
24 changes: 24 additions & 0 deletions Tekst-API/tekst/models/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from beanie import PydanticObjectId
from pydantic import EmailStr, Field, StringConstraints
from typing_extensions import TypedDict

from tekst.config import TekstConfig, get_config
from tekst.models.common import (
Expand Down Expand Up @@ -29,9 +30,24 @@ class PlatformNavInfoEntryTranslation(TranslationBase):
]


class LayerCategoryTranslation(TranslationBase):
translation: Annotated[
str, StringConstraints(strip_whitespace=True, min_length=1, max_length=32)
]


class LayerCategory(TypedDict):
key: Annotated[
str, StringConstraints(strip_whitespace=True, min_length=1, max_length=16)
]
translations: Translations[LayerCategoryTranslation]


class PlatformSettings(ModelBase, ModelFactoryMixin):
"""Settings defining platform behavior configured by admins"""

# INFO

info_platform_name: Annotated[
str,
StringConstraints(min_length=1, max_length=32),
Expand Down Expand Up @@ -62,13 +78,21 @@ class PlatformSettings(ModelBase, ModelFactoryMixin):
Field(description="URL to page with contact info"),
] = None

# OPTIONS
default_text_id: Annotated[
PydanticObjectId | None, Field(description="Default text to load in UI")
] = None
nav_info_entry: Annotated[
Translations[PlatformNavInfoEntryTranslation],
Field(description="Custom label for main navigation info entry"),
] = []
layer_categories: Annotated[
list[LayerCategory],
Field(description="Layer categories to categorize layers in"),
] = []
show_layer_category_headings: Annotated[
bool, Field(description="Show layer category headings in browse view")
] = True
always_show_text_info: Annotated[
bool,
Field(
Expand Down
Loading

0 comments on commit 930ca36

Please sign in to comment.