Skip to content

Commit

Permalink
Merge pull request #12 from pblottiere/fix_projects_cache
Browse files Browse the repository at this point in the history
Fix projects in cache in qsa-plugin
  • Loading branch information
pblottiere authored Apr 11, 2024
2 parents 2b8ce9f + f6efd03 commit 95b0d20
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/src/qsa-api/endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ empty.
| GET | `/api/projects/{project}/layers/{layer}/map` | WMS `GetMap` result with default parameters |
| GET | `/api/projects/{project}/layers/{layer}/map/url` | WMS `GetMap` URL with default parameters |
| POST | `/api/projects/{project}/layers` | Add layer to project with `type` (`vector` or `raster`), `name`, `datasource` and `crs` |
| POST | `/api/projects/{project}/layers/{layer}/style` | Add/Update layer's style with `name` (style name) and `current` (`True` or `False`) |
| POST | `/api/projects/{project}/layers/{layer}/style` | Add/Update layer's style with `name` (style name) and `current` (`true` or `false`) |
| DELETE | `/api/projects/{project}/layers/{layer}` | Remove layer from project |

Examples:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/sandbox/styles.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ $ curl "http://localhost:5000/api/projects/my_project/layers/polygons/style" \
-H 'Content-Type: application/json' \
-d '{
"name":"my_fill_style",
"current":"True"
"current":true
}'
true
````
Expand Down
9 changes: 1 addition & 8 deletions qsa-api/qsa_api/api/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
projects = Blueprint("projects", __name__)


def str_to_bool(s: str) -> bool:
if s in ["True", "TRUE", "true", 1]:
return True
return False


@projects.get("/")
def projects_list():
p = []
Expand Down Expand Up @@ -125,8 +119,7 @@ def project_layer_update_style(name, layer_name):
except ValidationError as e:
return {"error": e.message}, 415

current = str_to_bool(data["current"])

current = data["current"]
style_name = data["name"]
rc, msg = project.layer_update_style(layer_name, style_name, current)
if not rc:
Expand Down
5 changes: 4 additions & 1 deletion qsa-plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pickle
import socket
from osgeo import gdal
from pathlib import Path
from threading import Thread
from datetime import datetime

Expand Down Expand Up @@ -38,7 +39,9 @@ def metadata(iface) -> dict:
m["providers"] = QgsProviderRegistry.instance().pluginList().split("\n")

m["cache"] = {}
m["cache"]["projects"] = QgsConfigCache.instance().projects()
m["cache"]["projects"] = []
for project in QgsConfigCache.instance().projects():
m["cache"]["projects"].append(Path(project.fileName()).name)

return m

Expand Down
8 changes: 0 additions & 8 deletions qsa-plugin/metadata.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# This file contains metadata for your plugin. Since
# version 2.0 of QGIS this is the proper way to supply
# information about a plugin. The old method of
# embedding metadata in __init__.py will
# is no longer supported since version 2.0.

# This file should be included when you package your plugin.# Mandatory items:

[general]
name=qsa
qgisMinimumVersion=3.30
Expand Down

0 comments on commit 95b0d20

Please sign in to comment.