Closed Raruto closed 1 month ago
Moved here from the g3w-suite-docker repository because I think this can already be accomplished somehow through the built-in features of the Django Framework, for example:
Further information:
Related to: https://github.com/g3w-suite/g3w-admin/pull/787 and https://github.com/g3w-suite/g3w-client/pull/574
Here's an example of how we might start sharing searches across different installations (probably a similar thing can be done to import the default demo project/group and its settings):
python3 g3w-admin/manage.py dumpdata --indent 2 qdjango.widget > /code/g3w-admin/core/fixtures/qdjango_widget.json
[
{
"model": "qdjango.widget",
"pk": 2,
"fields": {
"name": "Type and volume",
"body": "{\"title\":\"Type and volume\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"type\",\"label\":\"Type\",\"blanktext\":\"Lorem ipsum\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"},{\"name\":\"volume\",\"label\":\"Volume greater than\",\"blanktext\":\"\",\"filterop\":\"gt\",\"widgettype\":\"inputbox\",\"input\":{\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"}],\"otherlayers\":[\"work_areas_f0ecbe28_cbd1_4a38_8a57_ab6da91473fe\",\"maintenance_works_f8cbe34a_eebe_4cd1_9c78_5d420ab0af63\"],\"results\":[],\"selectionlayer\":\"buildings_2f43dc1d_6725_42d2_a09b_dd446220104a\",\"selectionzoom\":0,\"dozoomtoextent\":true}",
"datasource": "dbname='/shared-volume/media/project_data/spatialite/building_management_demo.sqlite' table=\"buildings\" (geom)",
"widget_type": "search",
"slug": "foo",
"layers": [
3
]
}
},
{
"model": "qdjango.widget",
"pk": 4,
"fields": {
"name": "Type and Address",
"body": "{\"title\":\"Type and Address\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"type\",\"label\":\"\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"},{\"name\":\"address\",\"label\":\"Address\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"dependance\":\"type\",\"dependance_strict\":true,\"numdigaut\":\"2\"}},\"logicop\":\"and\"}],\"otherlayers\":null,\"results\":[],\"selectionlayer\":\"buildings_2f43dc1d_6725_42d2_a09b_dd446220104a\",\"selectionzoom\":0,\"dozoomtoextent\":true}",
"datasource": "dbname='/shared-volume/media/project_data/spatialite/building_management_demo.sqlite' table=\"buildings\" (geom)",
"widget_type": "search",
"slug": "type-and-address",
"layers": [
3
]
}
},
{
"model": "qdjango.widget",
"pk": 5,
"fields": {
"name": "Subtype",
"body": "{\"title\":\"Subtype\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"subtype\",\"label\":\"Subtype\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"}],\"otherlayers\":null,\"results\":[],\"selectionlayer\":\"buildings_2f43dc1d_6725_42d2_a09b_dd446220104a\",\"selectionzoom\":0,\"dozoomtoextent\":true}",
"datasource": "dbname='/shared-volume/media/project_data/spatialite/building_management_demo.sqlite' table=\"buildings\" (geom)",
"widget_type": "search",
"slug": "subtype",
"layers": [
3
]
}
},
{
"model": "qdjango.widget",
"pk": 6,
"fields": {
"name": "Type and Subtype",
"body": "{\"title\":\"Type and Subtype\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"type\",\"label\":\"Type\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"},{\"name\":\"subtype\",\"label\":\"Subtype\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"dependance\":\"type\",\"dependance_strict\":true,\"numdigaut\":\"2\"}},\"logicop\":\"and\"}],\"otherlayers\":null,\"results\":[],\"selectionlayer\":\"buildings_2f43dc1d_6725_42d2_a09b_dd446220104a\",\"selectionzoom\":0,\"dozoomtoextent\":true}",
"datasource": "dbname='/shared-volume/media/project_data/spatialite/building_management_demo.sqlite' table=\"buildings\" (geom)",
"widget_type": "search",
"slug": "type-and-subtype",
"layers": [
3
]
}
},
{
"model": "qdjango.widget",
"pk": 7,
"fields": {
"name": "Multilayers Search",
"body": "{\"title\":\"Multilayers Search\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"name\",\"label\":\"Name\",\"blanktext\":\"\",\"filterop\":\"LIKE\",\"widgettype\":\"inputbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"}],\"otherlayers\":[\"roads_ea006d6f_bd87_4635_aae0_4e9e7842b3f4\"],\"results\":[],\"selectionlayer\":\"buildings_2f43dc1d_6725_42d2_a09b_dd446220104a\",\"selectionzoom\":0,\"dozoomtoextent\":true}",
"datasource": "dbname='/shared-volume/media/project_data/spatialite/building_management_demo.sqlite' table=\"buildings\" (geom)",
"widget_type": "search",
"slug": "multilayers-search",
"layers": [
3
]
}
},
{
"model": "qdjango.widget",
"pk": 8,
"fields": {
"name": "autocomplete",
"body": "{\"title\":\"autocomplete\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"type\",\"label\":\"\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"autocompletebox\",\"input\":{\"type\":\"textfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"},{\"name\":\"address\",\"label\":\"\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"autocompletebox\",\"input\":{\"type\":\"textfield\",\"options\":{\"dependance\":\"type\",\"dependance_strict\":false,\"numdigaut\":\"2\"}},\"logicop\":\"and\"},{\"name\":\"zone\",\"label\":\"\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"autocompletebox\",\"input\":{\"type\":\"textfield\",\"options\":{\"dependance\":\"address\",\"dependance_strict\":false,\"numdigaut\":\"1\"}},\"logicop\":\"and\"}],\"otherlayers\":null,\"results\":[],\"selectionlayer\":\"buildings_2f43dc1d_6725_42d2_a09b_dd446220104a\",\"selectionzoom\":0,\"dozoomtoextent\":true}",
"datasource": "dbname='/shared-volume/media/project_data/spatialite/building_management_demo.sqlite' table=\"buildings\" (geom)",
"widget_type": "search",
"slug": "autocomplete",
"layers": [
3
]
}
},
{
"model": "qdjango.widget",
"pk": 9,
"fields": {
"name": "Buildings for roads",
"body": "{\"title\":\"Buildings for roads\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"address\",\"label\":\"Address\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"}],\"otherlayers\":null,\"results\":[],\"selectionlayer\":\"buildings_2f43dc1d_6725_42d2_a09b_dd446220104a\",\"selectionzoom\":0,\"dozoomtoextent\":true}",
"datasource": "dbname='/shared-volume/media/project_data/spatialite/building_management_demo.sqlite' table=\"buildings\" (geom)",
"widget_type": "search",
"slug": "buildings-for-roads",
"layers": [
3
]
}
},
{
"model": "qdjango.widget",
"pk": 10,
"fields": {
"name": "Date",
"body": "{\"title\":\"Date\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"date_barriers\",\"label\":\"Date\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"datetimebox\",\"input\":{\"type\":\"datetimefield\",\"options\":{\"numdigaut\":\"2\",\"format\":{\"date\":false,\"time\":false,\"fieldformat\":\"yyyy-MM-dd\",\"displayformat\":\"yyyy/MM/dd\",\"default\":null}}},\"logicop\":\"and\"}],\"otherlayers\":null,\"results\":[],\"selectionlayer\":\"buildings_2f43dc1d_6725_42d2_a09b_dd446220104a\",\"selectionzoom\":0,\"dozoomtoextent\":true}",
"datasource": "dbname='/shared-volume/media/project_data/spatialite/building_management_demo.sqlite' table=\"buildings\" (geom)",
"widget_type": "search",
"slug": "date",
"layers": [
3
]
}
},
{
"model": "qdjango.widget",
"pk": 11,
"fields": {
"name": "Type and year",
"body": "{\"title\":\"Type and year\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"type\",\"label\":\"Type\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"},{\"name\":\"year\",\"label\":\"Year\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"options\":{\"dependance\":\"type\",\"dependance_strict\":false,\"numdigaut\":\"2\"}},\"logicop\":\"and\"}],\"otherlayers\":null,\"results\":[],\"selectionlayer\":\"buildings_2f43dc1d_6725_42d2_a09b_dd446220104a\",\"selectionzoom\":0,\"dozoomtoextent\":true}",
"datasource": "dbname='/shared-volume/media/project_data/spatialite/building_management_demo.sqlite' table=\"buildings\" (geom)",
"widget_type": "search",
"slug": "type-and-year",
"layers": [
3
]
}
},
{
"model": "qdjango.widget",
"pk": 12,
"fields": {
"name": "Search on 1:N relations data",
"body": "{\"title\":\"Search on 1:N relations data\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"maintenance\",\"label\":\"Maintenance\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"},{\"name\":\"responsible\",\"label\":\"Responsible\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"textfield\",\"options\":{\"dependance\":\"maintenance\",\"dependance_strict\":true,\"numdigaut\":\"2\"}},\"logicop\":\"and\"}],\"otherlayers\":null,\"results\":[],\"selectionlayer\":\"maintenance_works_f8cbe34a_eebe_4cd1_9c78_5d420ab0af63\",\"selectionzoom\":0,\"dozoomtoextent\":true,\"relations\":\"maintenanc_id_building_buildings__fid\"}",
"datasource": "dbname='/shared-volume/media/project_data/spatialite/building_management_demo.sqlite' table=\"maintenance_works\"",
"widget_type": "search",
"slug": "search-on-1n-relations-data",
"layers": [
5
]
}
},
{
"model": "qdjango.widget",
"pk": 13,
"fields": {
"name": "Relazione valore su figli",
"body": "{\"title\":\"Relazione valore su figli\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"value\",\"label\":\"\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"numberfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"}],\"otherlayers\":null,\"results\":[],\"selectionlayer\":\"figlio_relazione_1f9c5b74_83aa_4fa6_bdc3_ac870a41e3c5\",\"selectionzoom\":0,\"dozoomtoextent\":true,\"relations\":\"\"}",
"datasource": "/shared-volume/media/project_data/editing-multi-fields/editing-multi-fields.gpkg|layername=figlio_relazione",
"widget_type": "search",
"slug": "relazione-valore-su-figli",
"layers": [
50
]
}
},
{
"model": "qdjango.widget",
"pk": 14,
"fields": {
"name": "Relazione valore su padre",
"body": "{\"title\":\"Relazione valore su padre\",\"query\":\"simpleWmsSearch\",\"usewmsrequest\":true,\"fields\":[{\"name\":\"value\",\"label\":\"\",\"blanktext\":\"\",\"filterop\":\"eq\",\"widgettype\":\"selectbox\",\"input\":{\"type\":\"numberfield\",\"options\":{\"numdigaut\":\"2\"}},\"logicop\":\"and\"}],\"otherlayers\":null,\"results\":[],\"selectionlayer\":\"figlio_relazione_1f9c5b74_83aa_4fa6_bdc3_ac870a41e3c5\",\"selectionzoom\":0,\"dozoomtoextent\":true,\"relations\":\"figlio_rel_id_padre_padre_rela_id\"}",
"datasource": "/shared-volume/media/project_data/editing-multi-fields/editing-multi-fields.gpkg|layername=figlio_relazione",
"widget_type": "search",
"slug": "relazione-valore-su-padre",
"layers": [
50
]
}
}
]
For more info: https://stackoverflow.com/a/49941917
At the moment the documentation on how to create a new project is excessively verbose about it (I don't think there is even a precise section that explains how to do it). At least for the demo project, to make it easier for new developers, it would be useful to have some sort of automated system to import and create everything needed.
Related to: https://github.com/g3w-suite/g3w-client/issues/183