Add plugin management (WIP)

Refactoring some models, prevent circular deps
This commit is contained in:
phil 2024-03-07 12:13:47 +05:30
parent f1534dfed7
commit 360a7a70f3
11 changed files with 308 additions and 160 deletions

View file

@ -40,7 +40,7 @@ from gisaf.models.models_base import Model
from gisaf.models.metadata import gisaf_survey, gisaf_admin, survey, raw_survey
from gisaf.models.misc import Qml
from gisaf.models.category import Category
from gisaf.models.to_migrate import InfoItem
from gisaf.models.info_item import InfoItem
# from gisaf.models.survey import Equipment, Surveyor, Accuracy
# from gisaf.models.project import Project

161
src/gisaf/models/info.py Normal file
View file

@ -0,0 +1,161 @@
from typing import Any
from pydantic import BaseModel
from gisaf.models.info_item import InfoItem
class ActionResult(BaseModel):
message: str
class ActionResults(BaseModel):
name: str
message: str
actionResults: list[ActionResult]
class DataProvider(BaseModel):
name: str
values: list[str]
class InfoCategory(BaseModel):
name: str
infoItems: list[InfoItem]
class PlotBgShape(BaseModel):
name: str
valueTop: float
valueBottom: float
color: str
class PlotBaseLine(BaseModel):
name: str
value: float
color: str
class PlotParams(BaseModel):
baseLines: list[PlotBaseLine]
bgShape: list[PlotBgShape]
barBase: float
class Attachment(BaseModel):
name: str
path: str
class FeatureInfo(BaseModel):
id: str
itemName: str
geoInfoItems: list[InfoItem] = []
surveyInfoItems: list[InfoItem] = []
infoItems: list[InfoItem] = []
categorizedInfoItems: list[InfoCategory] = []
tags: list[InfoItem] = []
graph: str | None = None
plotParams: PlotParams | None = None
files: list[Attachment] = []
images: list[Attachment] = []
externalRecordUrl: str | None = None
class ModelValue(BaseModel):
name: str
title: str
unit: str
chartType: str = 'line'
chartColor: str = 'blue'
class FormField(BaseModel):
name: str
type: str
dflt: str | None = None
value: str | None = None
class ModelAction(BaseModel):
name: str
icon: str
formFields: list[FormField]
class TagAction(BaseModel):
name: str
_plugin: Any
action: str
roles: list[str] | None = None
link: str | None = None
save: bool = False
class TagActions(BaseModel):
domain: str
key: str
actions: list[TagAction]
class ActionAction(BaseModel):
roles: list[str]
# plugin: Any
name: str
params: Any
icon: str
formFields: list[FormField]
class Downloader(BaseModel):
# plugin: str
# downloader: str
roles: list[str] = []
name: str
icon: str | None = None
class LegendItem(BaseModel):
key: str
value: str
class ModelInfo(BaseModel):
store: str
modelName: str
symbol: str | None = None
values: list[ModelValue] = []
actions: list[ModelAction] = []
formName: str | None = None
formFields: list[FormField] = []
tagPlugins: list[str] = []
tagActions: list[TagActions] = []
downloaders: list[Downloader] = []
legend: list[LegendItem] = []
class TagsStore(BaseModel):
store: str
tagActions: list[TagActions]
class TagsStores(BaseModel):
stores: list[TagsStore]
class ActionParam(BaseModel):
name: str
type: str
dflt: str
class Action(BaseModel):
name: str
roles: list[str]
params: list[ActionParam]
class ActionsStore(BaseModel):
store: str
actions: list[Action]

View file

@ -0,0 +1,6 @@
from pydantic import BaseModel
class InfoItem(BaseModel):
key: str
value: str | float | int

View file

@ -3,7 +3,7 @@ from sqlalchemy import BigInteger
from sqlalchemy.ext.mutable import MutableDict
from sqlalchemy.dialects.postgresql import HSTORE
from sqlmodel import Field, SQLModel, MetaData, JSON, TEXT, Relationship, Column
from pydantic import computed_field
from pydantic import BaseModel, computed_field
from gisaf.models.metadata import gisaf
from gisaf.models.geo_models_base import GeoPointModel
@ -42,4 +42,5 @@ class TagKey(SQLModel, table=True):
return self.key
def __repr__(self):
return '<models.TagKey {self.key}>'.format(self=self)
return '<models.TagKey {self.key}>'.format(self=self)

View file

@ -1,75 +0,0 @@
from pydantic import BaseModel
class ActionResult(BaseModel):
message: str
class ActionResults(BaseModel):
name: str
message: str
actionResults: list[ActionResult]
class FormField(BaseModel):
name: str
type: str
class ModelAction(BaseModel):
name: str
icon: str
formFields: list[FormField]
class DataProvider(BaseModel):
name: str
values: list[str]
class InfoItem(BaseModel):
key: str
value: str | float | int
class InfoCategory(BaseModel):
name: str
infoItems: list[InfoItem]
class PlotBgShape(BaseModel):
name: str
valueTop: float
valueBottom: float
color: str
class PlotBaseLine(BaseModel):
name: str
value: float
color: str
class PlotParams(BaseModel):
baseLines: list[PlotBaseLine]
bgShape: list[PlotBgShape]
barBase: float
class Attachment(BaseModel):
name: str
path: str
class FeatureInfo(BaseModel):
id: str
itemName: str
geoInfoItems: list[InfoItem] = []
surveyInfoItems: list[InfoItem] = []
infoItems: list[InfoItem] = []
categorizedInfoItems: list[InfoCategory] = []
tags: list[InfoItem] = []
graph: str | None = None
plotParams: PlotParams | None = None
files: list[Attachment] = []
images: list[Attachment] = []
externalRecordUrl: str | None = None