File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 3
3
from django .contrib .auth .models import Group
4
4
from django .contrib .gis .geos import GEOSGeometry
5
5
from geostore .models import Layer , LayerGroup
6
+ from terra_geocrud .models import CrudView , CrudViewProperty
7
+ from terra_geocrud .properties .schema import sync_layer_schema
6
8
from rest_framework .exceptions import MethodNotAllowed
7
9
8
10
from custom .receivers import * # noqa
@@ -22,6 +24,27 @@ def layer_callback(geosource):
22
24
23
25
layer_groups = Group .objects .filter (pk__in = geosource .settings .get ('groups' , []))
24
26
27
+ crud_view = CrudView .objects .get_or_create (layer = layer ,
28
+ defaults = {"name" : layer .name , "order" : 0 })[0 ]
29
+
30
+ fields = geosource .fields .all ()
31
+ for field in fields :
32
+ data_type = field .data_type
33
+ name = field .name
34
+ label = field .label
35
+ if data_type == 1 :
36
+ final_type = "string"
37
+ elif data_type == 2 :
38
+ final_type = "string"
39
+ elif data_type == 3 :
40
+ final_type = "float"
41
+ elif data_type == 4 :
42
+ final_type = "boolean"
43
+ property , created = CrudViewProperty .objects .get_or_create (view = crud_view , key = name )
44
+ property .json_schema = {"title" : label , "type" : final_type }
45
+ property .save ()
46
+
47
+ sync_layer_schema (crud_view )
25
48
if set (layer .authorized_groups .all ()) != set (layer_groups ):
26
49
layer .authorized_groups .set (layer_groups )
27
50
Original file line number Diff line number Diff line change 28
28
'django.contrib.sessions' ,
29
29
'django.contrib.staticfiles' ,
30
30
'django.contrib.gis' ,
31
+ 'django_object_actions' ,
31
32
'rest_framework' ,
32
33
'rest_framework_gis' ,
33
34
'corsheaders' ,
Original file line number Diff line number Diff line change 14
14
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15
15
"""
16
16
from django .conf import settings
17
+ from django .contrib import admin
17
18
from django .conf .urls .static import static
18
19
from django .urls import include , path
19
20
20
21
from custom .receivers import * # noqa
21
22
22
23
urlpatterns = [
24
+ path ('' , admin .site .urls ),
23
25
path ('api/' , include ('terra_layer.urls' )),
24
26
path ('api/mapbox_baselayer/' , include ('mapbox_baselayer.urls' )),
25
27
path ('api/crud/' , include ('terra_geocrud.urls' )),
You can’t perform that action at this time.
0 commit comments