diff --git a/omeroweb/webclient/controller/container.py b/omeroweb/webclient/controller/container.py index 16165b8e28..4ff9332858 100644 --- a/omeroweb/webclient/controller/container.py +++ b/omeroweb/webclient/controller/container.py @@ -82,73 +82,67 @@ def __init__( **kw, ): BaseController.__init__(self, conn) + if project is not None: self.obj_type = "project" - self.project = self.conn.getObject("Project", project) - self.assertNotNone(self.project, project, "Project") - self.assertNotNone(self.project._obj, project, "Project") + self.project = self._getObject("Project", project) if dataset is not None: self.obj_type = "dataset" - self.dataset = self.conn.getObject("Dataset", dataset) - self.assertNotNone(self.dataset, dataset, "Dataset") - self.assertNotNone(self.dataset._obj, dataset, "Dataset") + self.dataset = self._getObject("Dataset", dataset) if screen is not None: self.obj_type = "screen" - self.screen = self.conn.getObject("Screen", screen) - self.assertNotNone(self.screen, screen, "Screen") - self.assertNotNone(self.screen._obj, screen, "Screen") + self.screen = self._getObject("Screen", screen) if plate is not None: self.obj_type = "plate" - self.plate = self.conn.getObject("Plate", plate) - self.assertNotNone(self.plate, plate, "Plate") - self.assertNotNone(self.plate._obj, plate, "Plate") + self.plate = self._getObject("Plate", plate) if acquisition is not None: self.obj_type = "acquisition" - self.acquisition = self.conn.getObject("PlateAcquisition", acquisition) - self.assertNotNone(self.acquisition, acquisition, "Plate Acquisition") - self.assertNotNone(self.acquisition._obj, acquisition, "Plate Acquisition") + self.acquisition = self._getObject("PlateAcquisition", acquisition) if image is not None: self.obj_type = "image" - self.image = self.conn.getObject("Image", image) - self.assertNotNone(self.image, image, "Image") - self.assertNotNone(self.image._obj, image, "Image") + self.image = self._getObject("Image", image) if well is not None: self.obj_type = "well" - self.well = self.conn.getObject("Well", well) - self.assertNotNone(self.well, well, "Well") - self.assertNotNone(self.well._obj, well, "Well") + self.well = self._getObject("Well", well) if tag is not None: self.obj_type = "tag" - self.tag = self.conn.getObject("Annotation", tag) - self.assertNotNone(self.tag, tag, "Tag") - self.assertNotNone(self.tag._obj, tag, "Tag") + self.tag = self._getObject("Annotation", tag) if tagset is not None: self.obj_type = "tagset" - self.tag = self.conn.getObject("Annotation", tagset) + self.tag = self._getObject("Annotation", tagset) # We need to check if tagset via hasattr(manager, o_type) self.tagset = self.tag - self.assertNotNone(self.tag, tagset, "Tag") - self.assertNotNone(self.tag._obj, tagset, "Tag") if comment is not None: self.obj_type = "comment" - self.comment = self.conn.getObject("Annotation", comment) - self.assertNotNone(self.comment, comment, "Comment") - self.assertNotNone(self.comment._obj, comment, "Comment") + self.comment = self._getObject("Annotation", comment) if file is not None: self.obj_type = "file" - self.file = self.conn.getObject("Annotation", file) - self.assertNotNone(self.file, file, "File") - self.assertNotNone(self.file._obj, file, "File") + self.file = self._getObject("Annotation", file) if annotation is not None: self.obj_type = "annotation" - self.annotation = self.conn.getObject("Annotation", annotation) - self.assertNotNone(self.annotation, annotation, "Annotation") - self.assertNotNone(self.annotation._obj, annotation, "Annotation") + self.annotation = self._getObject("Annotation", annotation) if orphaned: self.orphaned = True if index is not None: self.index = index + def _getObject(self, obj_type, obj_id): + # we wrap conn.getObject() to FIRST set the group context + # since conn.getObject() with group: -1 is slow if user's default group is big + rsp_obj = None + try: + if self.conn.SERVICE_OPTS.getOmeroGroup() == -1: + obj = self.conn.getQueryService().get( + obj_type, int(obj_id), {"group": "-1"} + ) + group_id = obj.getDetails().group.id.val + self.conn.SERVICE_OPTS.setOmeroGroup(group_id) + rsp_obj = self.conn.getObject(obj_type, obj_id) + except omero.ValidationException: + pass + self.assertNotNone(rsp_obj, obj_id, obj_type) + return rsp_obj + def assertNotNone(self, obj, obj_id, obj_name): if obj is None: raise AttributeError( diff --git a/omeroweb/webclient/templates/webclient/annotations/annotations_share.html b/omeroweb/webclient/templates/webclient/annotations/annotations_share.html index 1ebd260e3b..e2d36cc8c8 100644 --- a/omeroweb/webclient/templates/webclient/annotations/annotations_share.html +++ b/omeroweb/webclient/templates/webclient/annotations/annotations_share.html @@ -242,17 +242,7 @@

{% trans "Annotations" %}

{% if manager.share.isExpired %} This {{ manager.share.getShareType|lower }} has expired and you no longer can make any comments. {% else %} -
{% csrf_token %} - - - - - - - - -
{{ form_comment.share }}
{{ form_comment.comment }}
-
+ Commenting is no-longer supported. {% endif %} diff --git a/omeroweb/webclient/views.py b/omeroweb/webclient/views.py index 504ce999d3..1550b94876 100755 --- a/omeroweb/webclient/views.py +++ b/omeroweb/webclient/views.py @@ -1717,61 +1717,12 @@ def load_metadata_details(request, c_type, c_id, conn=None, share_id=None, **kwa context = dict() - # we only expect a single object, but forms can take multiple objects - images = c_type == "image" and list(conn.getObjects("Image", [c_id])) or list() - datasets = ( - c_type == "dataset" and list(conn.getObjects("Dataset", [c_id])) or list() - ) - projects = ( - c_type == "project" and list(conn.getObjects("Project", [c_id])) or list() - ) - screens = c_type == "screen" and list(conn.getObjects("Screen", [c_id])) or list() - plates = c_type == "plate" and list(conn.getObjects("Plate", [c_id])) or list() - acquisitions = ( - c_type == "acquisition" - and list(conn.getObjects("PlateAcquisition", [c_id])) - or list() - ) - shares = ( - (c_type == "share" or c_type == "discussion") - and [conn.getShare(c_id)] - or list() - ) - wells = c_type == "well" and list(conn.getObjects("Well", [c_id])) or list() - - # we simply set up the annotation form, passing the objects to be - # annotated. - selected = { - "images": c_type == "image" and [c_id] or [], - "datasets": c_type == "dataset" and [c_id] or [], - "projects": c_type == "project" and [c_id] or [], - "screens": c_type == "screen" and [c_id] or [], - "plates": c_type == "plate" and [c_id] or [], - "acquisitions": c_type == "acquisition" and [c_id] or [], - "wells": c_type == "well" and [c_id] or [], - "shares": ((c_type == "share" or c_type == "discussion") and [c_id] or []), - } - - initial = { - "selected": selected, - "images": images, - "datasets": datasets, - "projects": projects, - "screens": screens, - "plates": plates, - "acquisitions": acquisitions, - "wells": wells, - "shares": shares, - } - - form_comment = None figScripts = None if c_type in ("share", "discussion"): template = "webclient/annotations/annotations_share.html" manager = BaseShare(conn, c_id) manager.getAllUsers(c_id) manager.getComments(c_id) - form_comment = CommentAnnotationForm(initial=initial) else: try: manager = BaseContainer(conn, **{str(c_type): int(c_id), "index": index}) @@ -1792,8 +1743,6 @@ def load_metadata_details(request, c_type, c_id, conn=None, share_id=None, **kwa context["insight_ns"] = omero.rtypes.rstring( omero.constants.metadata.NSINSIGHTTAGSET ).val - if form_comment is not None: - context["form_comment"] = form_comment context["figScripts"] = figScripts context["template"] = template