Skip to content

Commit

Permalink
Merge branch 'fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
haikoschol committed Mar 1, 2025
2 parents 77e08cf + a8c4057 commit fc96ee0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions photos/static/photos/components/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,12 @@ class CoaUploader extends HTMLElement {
this.metadata.city = this.city.value
this.metadata.country = this.country.value

await this.addPhoto(this.metadata)
Toast(`Uploaded file ${this.metadata.filename} successfully`)
const uploadRes = await this.addPhoto(this.metadata)
if (uploadRes.success) {
Toast(`Uploaded file ${this.metadata.filename} successfully`)
} else {
ErrorToast(`Uploading file ${this.metadata.filename} failed`)
}
}

populateForm() {
Expand Down
12 changes: 9 additions & 3 deletions photos/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,17 @@ def add_photo(request, metadata: dict[str, object]):
coords = Coordinates.objects.filter(point=p).first()

if not coords:
loc, _ = Location.objects.get_or_create(
loc = Location.objects.filter(
city=pm.city,
country=pm.country,
tzoffset=pm.tzoffset,
)
).first()

if not loc:
loc = Location.objects.create(
city=pm.city,
country=pm.country,
tzoffset=pm.tzoffset, # this is probably wrong
)

coords = Coordinates.objects.create(
point=p,
Expand Down

0 comments on commit fc96ee0

Please sign in to comment.