Code cosmetic
This commit is contained in:
parent
3971b7f2e7
commit
709f4367ea
1 changed files with 18 additions and 21 deletions
|
@ -11,41 +11,38 @@ from gisaf.models.store import Store
|
||||||
|
|
||||||
class BaseStyle(Model, table=True):
|
class BaseStyle(Model, table=True):
|
||||||
__table_args__ = gisaf_map.table_args
|
__table_args__ = gisaf_map.table_args
|
||||||
__tablename__: str = 'map_base_style' # type: ignore
|
__tablename__: str = "map_base_style" # type: ignore
|
||||||
|
|
||||||
class Admin:
|
class Admin:
|
||||||
menu = 'Other'
|
menu = "Other"
|
||||||
flask_admin_model_view = 'MapBaseStyleModelView'
|
flask_admin_model_view = "MapBaseStyleModelView"
|
||||||
|
|
||||||
id: int | None = Field(primary_key=True, default=None)
|
id: int | None = Field(primary_key=True, default=None)
|
||||||
name: str
|
name: str
|
||||||
style: dict[str, Any] | None = Field(sa_type=JSON(none_as_null=True)) # type: ignore
|
style: dict[str, Any] | None = Field(sa_type=JSON(none_as_null=True)) # type: ignore
|
||||||
mbtiles: str = Field(sa_type=String(50)) # type: ignore
|
mbtiles: str = Field(sa_type=String(50)) # type: ignore
|
||||||
static_tiles_url: str
|
static_tiles_url: str
|
||||||
enabled: bool = True
|
enabled: bool = True
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'<models.BaseStyle {self.name:s}>'
|
return f"<models.BaseStyle {self.name:s}>"
|
||||||
|
|
||||||
|
|
||||||
class BaseMapLayer(Model, table=True):
|
class BaseMapLayer(Model, table=True):
|
||||||
__table_args__ = gisaf_map.table_args
|
__table_args__ = gisaf_map.table_args
|
||||||
__tablename__: str = 'base_map_layer' # type: ignore
|
__tablename__: str = "base_map_layer" # type: ignore
|
||||||
|
|
||||||
class Admin:
|
class Admin:
|
||||||
menu = 'Other'
|
menu = "Other"
|
||||||
|
|
||||||
id: int | None = Field(primary_key=True, default=None)
|
id: int | None = Field(primary_key=True, default=None)
|
||||||
base_map_id: int = Field(foreign_key=gisaf_map.table('base_map.id'),
|
base_map_id: int = Field(foreign_key=gisaf_map.table("base_map.id"), index=True)
|
||||||
index=True)
|
base_map: "BaseMap" = Relationship() # back_populates='layers')
|
||||||
base_map: 'BaseMap' = Relationship() #back_populates='layers')
|
store: str = Field(sa_type=String(100)) # type: ignore
|
||||||
store: str = Field(sa_type=String(100)) # type: ignore
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def selectinload(cls):
|
def selectinload(cls):
|
||||||
return [
|
return [cls.base_map]
|
||||||
cls.base_map
|
|
||||||
]
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<models.BaseMapLayer {self.store or '':s}>"
|
return f"<models.BaseMapLayer {self.store or '':s}>"
|
||||||
|
@ -56,10 +53,10 @@ class BaseMapLayer(Model, table=True):
|
||||||
|
|
||||||
class BaseMap(Model, table=True):
|
class BaseMap(Model, table=True):
|
||||||
__table_args__ = gisaf_map.table_args
|
__table_args__ = gisaf_map.table_args
|
||||||
__tablename__: str = 'base_map' # type: ignore
|
__tablename__: str = "base_map" # type: ignore
|
||||||
|
|
||||||
class Admin:
|
class Admin:
|
||||||
menu = 'Other'
|
menu = "Other"
|
||||||
|
|
||||||
id: int | None = Field(primary_key=True, default=None)
|
id: int | None = Field(primary_key=True, default=None)
|
||||||
name: str
|
name: str
|
||||||
|
@ -69,7 +66,7 @@ class BaseMap(Model, table=True):
|
||||||
# )
|
# )
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f'<models.BaseMap {self.name:s}>'
|
return f"<models.BaseMap {self.name:s}>"
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -94,6 +91,6 @@ class MapInitData(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
class MaplibreStyle(BaseModel):
|
class MaplibreStyle(BaseModel):
|
||||||
paint: dict[str, dict | list | float | int | str] | None = None
|
paint: dict[str, dict | list | bool | float | int | str] | None = None
|
||||||
layout: dict[str, dict | list | float | int | str] | None = None
|
layout: dict[str, dict | list | bool | float | int | str] | None = None
|
||||||
attribution: str | None = None
|
attribution: str | None = None
|
Loading…
Add table
Add a link
Reference in a new issue