示例#1
0
 def view(self):
     if self._is_new():
         dbsession = self._request.dbsession
         default_wmts = LayerWMTS.get_default(dbsession)
         if default_wmts:
             return self.copy(default_wmts, excludes=["name", "layer"])
     return super().edit()
示例#2
0
 def test_convert_without_wmts_defaults(self, test_app, layer_wms_test_data,
                                        dbsession):
     from c2cgeoportal_commons.models.main import LayerWMTS
     dbsession.delete(LayerWMTS.get_default(dbsession))
     layer = layer_wms_test_data['layers'][3]
     test_app.post("/layers_wms/{}/convert_to_wmts".format(layer.id),
                   status=200)
示例#3
0
 def view(self) -> Dict[str, Any]:
     if self._is_new():
         dbsession = self._request.dbsession
         default_wmts = LayerWMTS.get_default(dbsession)
         if default_wmts:
             return self.copy(default_wmts,
                              excludes=["name", "layer"])  # type: ignore
     return super().edit()  # type: ignore
示例#4
0
    def convert_to_wmts(self) -> Dict[str, Any]:
        src = self._get_object()
        dbsession = self._request.dbsession
        default_wmts = LayerWMTS.get_default(dbsession)
        values = ({
            "url": default_wmts.url,
            "matrix_set": default_wmts.matrix_set
        } if default_wmts else {
            "url": "",
            "matrix_set": ""
        })
        with dbsession.no_autoflush:
            d = delete(LayerWMS.__table__)
            d = d.where(LayerWMS.__table__.c.id == src.id)
            i = insert(LayerWMTS.__table__)
            values.update({
                "id": src.id,
                "layer": src.layer,
                "image_type": src.ogc_server.image_type,
                "style": src.style,
            })
            i = i.values(values)
            u = update(TreeItem.__table__)
            u = u.where(TreeItem.__table__.c.id == src.id)
            u = u.values({"type": "l_wmts"})
            dbsession.execute(d)
            dbsession.execute(i)
            dbsession.execute(u)
            dbsession.expunge(src)

        dbsession.flush()
        mark_changed(dbsession)

        return {
            "success":
            True,
            "redirect":
            self._request.route_url(
                "c2cgeoform_item",
                table="layers_wmts",
                id=self._request.matchdict["id"],
                _query=[("msg_col", "submit_ok")],
            ),
        }
示例#5
0
    def convert_to_wmts(self):
        src = self._get_object()
        dbsession = self._request.dbsession
        default_wmts = LayerWMTS.get_default(dbsession)
        values = {
            'url': default_wmts.url,
            'matrix_set': default_wmts.matrix_set
        } if default_wmts else {
            'url': '',
            'matrix_set': ''
        }
        with dbsession.no_autoflush:
            d = delete(LayerWMS.__table__)
            d = d.where(LayerWMS.__table__.c.id == src.id)
            i = insert(LayerWMTS.__table__)
            values.update({
                'id': src.id,
                'layer': src.layer,
                'image_type': src.ogc_server.image_type,
                'style': src.style
            })
            i = i.values(values)
            u = update(TreeItem.__table__)
            u = u.where(TreeItem.__table__.c.id == src.id)
            u = u.values({'type': 'l_wmts'})
            dbsession.execute(d)
            dbsession.execute(i)
            dbsession.execute(u)
            dbsession.expunge(src)

        dbsession.flush()
        mark_changed(dbsession)

        return {
            'success':
            True,
            'redirect':
            self._request.route_url('c2cgeoform_item',
                                    table='layers_wmts',
                                    id=self._request.matchdict['id'],
                                    _query=[('msg_col', 'submit_ok')])
        }
示例#6
0
    def test_convert_without_wmts_defaults(self, test_app, layer_wms_test_data, dbsession):
        from c2cgeoportal_commons.models.main import LayerWMTS

        dbsession.delete(LayerWMTS.get_default(dbsession))
        layer = layer_wms_test_data["layers"][3]
        test_app.post(f"/admin/layers_wms/{layer.id}/convert_to_wmts", status=200)