Skip to content

Commit

Permalink
Fixing some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcpage committed Aug 17, 2024
1 parent 290a09f commit b082a9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions genweb/data/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
results[field] = value[0].value;
}

return JSON.stringify(results);
return results;
}

function save_form() {
Expand All @@ -316,7 +316,7 @@

request.open("POST", "/api/v1/metadata/" + form_info.id, true);
request.setRequestHeader("Content-Type", "text/json;charset=UTF-8");
request.send(form_info);
request.send(JSON.stringify(form_info));
}

</script>
Expand Down
5 changes: 5 additions & 0 deletions genweb/webapi_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ApiV1:
URL = "/api/v1/"
CALL = regex(rf"^{URL}(people|metadata)(/([^/]+))?$")
SEPARATOR_PATTERN = regex(r"[\s:;,]+")
INT_FIELDS = ["width", "height"]

def __init__(self):
self.settings: Settings = None
Expand Down Expand Up @@ -141,6 +142,10 @@ def handle_post(self, handler: Handler) -> tuple[bytes, str, int]:
if "people" in metadata: # change people from string to list
metadata["people"] = ApiV1.SEPARATOR_PATTERN.split(metadata["people"])

for field in ApiV1.INT_FIELDS:
if field in metadata:
metadata[field] = int(metadata[field])

self.metadata[identifier] = metadata
self.metadata.save()
body = dumps(metadata).encode("utf-8")
Expand Down

0 comments on commit b082a9c

Please sign in to comment.