11import typing
22
33from django .db import models
4+ from pydantic import BaseModel
45from pyfirebase_mapswipe import models as firebase_models
56
67from apps .project .models import Project , ProjectTypeEnum
78from project_types .tile_map_service .base import project as tile_map_service_project
9+ from utils .custom_options .models import CustomOption
810
911
1012class SubGridSizeEnum (models .TextChoices ):
@@ -22,8 +24,21 @@ def to_firebase(self) -> firebase_models.FBEnumSubGridSize:
2224 return firebase_models .FBEnumSubGridSize .SIZE_8X8
2325
2426
27+ class ExportMeta (BaseModel ):
28+ key : str
29+ value : str
30+
31+ def to_firebase (self ) -> firebase_models .FbObjExportMeta :
32+ return firebase_models .FbObjExportMeta (
33+ key = self .key ,
34+ value = self .value ,
35+ )
36+
37+
2538class LocateProjectProperty (tile_map_service_project .TileMapServiceProjectProperty ):
2639 sub_grid_size : SubGridSizeEnum
40+ custom_options : list [CustomOption ] | None = None
41+ export_meta : ExportMeta
2742
2843
2944class LocateProjectTaskGroupProperty (tile_map_service_project .TileMapServiceProjectTaskGroupProperty ): ...
@@ -69,14 +84,37 @@ def get_task_specifics_for_db(self, tile_x: int, tile_y: int) -> LocateProjectTa
6984 @typing .override
7085 def get_project_specifics_for_firebase (self ):
7186 tsp = self .project_type_specifics .tile_server_property
87+ custom_opts = self .project_type_specifics .custom_options
7288 return firebase_models .FbProjectLocateCreateOnlyInput (
7389 zoomLevel = self .project_type_specifics .zoom_level ,
7490 subGridSize = self .project_type_specifics .sub_grid_size .to_firebase (),
91+ exportMeta = self .project_type_specifics .export_meta .to_firebase (),
7592 tileServer = firebase_models .FbObjRasterTileServer (
7693 name = tsp .name .to_firebase (),
7794 credits = tsp .get_config ()["credits" ],
7895 url = tsp .get_config ()["raw_url" ],
7996 apiKey = tsp .get_config ()["api_key" ],
8097 wmtsLayerName = None ,
8198 ),
99+ customOptions = [
100+ firebase_models .FbObjCustomOption (
101+ title = opt .title ,
102+ description = opt .description ,
103+ value = opt .value ,
104+ icon = str (opt .icon .label ),
105+ iconColor = opt .icon_color ,
106+ subOptions = [
107+ firebase_models .FbBaseObjCustomSubOption (
108+ value = sub_opt .value ,
109+ description = sub_opt .description ,
110+ )
111+ for sub_opt in opt .sub_options
112+ ]
113+ if opt .sub_options is not None
114+ else None ,
115+ )
116+ for opt in custom_opts
117+ ]
118+ if custom_opts is not None
119+ else None ,
82120 )
0 commit comments