Skip to content

Commit

Permalink
Fix flak8 errors and figure deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Rdornier committed Oct 3, 2024
1 parent 4f003fa commit 126a5cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions omero_figure/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,12 @@ def save_web_figure(request, conn=None, **kwargs):
return HttpResponse(str(file_id))


def delete_figure_kvp(conn, ns, figure_name, file_id):
def delete_figure_kvp(conn, ns, file_id):
# get kvp
ann = get_figure_kvp(conn, ns, figure_name, file_id)
ann = get_figure_kvp(conn, ns, file_id)
if ann is not None and len(ann) > 0:
map_id = ann[0]
map_ann = ann[0]
map_id = map_ann[0]
update = conn.getUpdateService()

# get the links between the key-value and the linked images
Expand Down Expand Up @@ -543,7 +544,7 @@ def link_figure_kvp_to_images(conn, update, ns, image_ids, map_id):
def create_or_get_figure_kvp(conn, ns, figure_name, file_id, figure_url):
# retrieve the key-value corresponding to the current figure
try:
ann = get_figure_kvp(conn, ns, figure_name, file_id)
ann = get_figure_kvp(conn, ns, file_id)

if ann is not None and len(ann) > 0:
map_att = ann[0]
Expand All @@ -557,15 +558,15 @@ def create_or_get_figure_kvp(conn, ns, figure_name, file_id, figure_url):
map_ann.setNs(wrap(ns))

map_ann.setValue([["Figure_%s_%s" % (file_id, figure_name),
figure_url]])
figure_url]])
map_ann.save()

return map_ann.getId()
except Exception:
return -1


def get_figure_kvp(conn, ns, figure_name, file_id):
def get_figure_kvp(conn, ns, file_id):
params = omero.sys.ParametersI()
where_clause = []
where_clause.append(f"mv.name like 'Figure_{file_id}%'")
Expand Down Expand Up @@ -730,8 +731,7 @@ def delete_web_figure(request, conn=None, **kwargs):
return HttpResponse("Need to POST 'fileId' to delete")

file_id = request.POST.get('fileId')
figure_name = request.POST.get('figName')
delete_figure_kvp(conn, LINK_FIGURE_NS, figure_name, file_id)
delete_figure_kvp(conn, LINK_FIGURE_NS, file_id)
conn.deleteObjects("Annotation", [file_id])
return HttpResponse("Deleted OK")

Expand Down
2 changes: 1 addition & 1 deletion src/js/views/figure_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@
var msg = "Delete '" + figName + "'?";
var self = this;
if (confirm(msg)) {
$.post( BASE_WEBFIGURE_URL + "delete_web_figure/", { fileId: fileId, figName: figName })
$.post( BASE_WEBFIGURE_URL + "delete_web_figure/", { fileId: fileId})
.done(function(){
self.figureFiles.removeFile(fileId);
self.app.navigate("", {trigger: true});
Expand Down

0 comments on commit 126a5cc

Please sign in to comment.