Skip to content

Commit

Permalink
Add default COG layer
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jul 10, 2024
1 parent 224c566 commit a6ac763
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion admin/c2cgeoportal_admin/views/layers_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ def schema(self) -> GeoFormSchemaNode:

@view_config(route_name="c2cgeoform_item", request_method="GET", renderer="../templates/edit.jinja2") # type: ignore[misc]
def view(self) -> ObjectResponse:
return super().edit(self.schema())
if self._is_new():
dbsession = self._request.dbsession
default_cog = LayerCOG.get_default(dbsession)
if default_cog:
return self.copy(default_cog, excludes=["name", "layer"])
return super().edit()

@view_config(route_name="c2cgeoform_item", request_method="POST", renderer="../templates/edit.jinja2") # type: ignore[misc]
def save(self) -> SaveResponse:
Expand Down
2 changes: 2 additions & 0 deletions commons/c2cgeoportal_commons/models/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,8 @@ class LayerCOG(Layer):
"""
<div class="help-block">
<p>Definition of a <code>COG Layer</code>.</p>
<p>Note: The layers named <code>cog-defaults</code> contains the values
used when we create a new <code>COG layer</code>.</p>
</div>
"""
)
Expand Down

0 comments on commit a6ac763

Please sign in to comment.