Exemplo n.º 1
0
    def folderitem(self, obj, item, index):
        """Applies new properties to item (StorageContainer) that is currently
        being rendered as a row in the list
        """
        item = super(ContainersView, self).folderitem(obj, item, index)

        # Get the object (the passed-in "obj" is a brain)
        obj = api.get_object(obj)

        # Containers/Positions usage
        # Samples containers cannot have containers inside!
        if not IStorageSamplesContainer.providedBy(obj):
            capacity = obj.get_capacity()
            taken = len(obj.get_non_available_positions())
            percentage = capacity and taken*100/capacity or 0
            item["replace"]["ContainersUsage"] = get_progress_bar_html(percentage)
            item["replace"]["Containers"] = "{:01d} / {:01d} ({:01d}%)"\
                .format(taken, capacity, percentage)

        # append the UID of the primary AR as parent
        parent = api.get_uid(api.get_parent(obj))
        item["parent"] = parent != api.get_uid(self.context) and parent or ""
        # append partition UIDs of this AR as children
        containers = obj.get_layout_containers()
        item["children"] = map(lambda cont: api.get_uid(cont), containers)
        return item
Exemplo n.º 2
0
    def __init__(self, context, request):
        super(ContainersView, self).__init__(context, request)
        self.title = context.Title()
        self.form_id = "list_storage_containers"
        self.show_select_column = True
        self.contentFilter = {
            "sort_on": "sortable_title",
            "sort_order": "ascending",
            "path": {
                "query": "/".join(context.getPhysicalPath()),
                "depth": 1,
            }
        }

        self.columns = collections.OrderedDict((
            ("Title", {
                "title": _("Name"),
                "index": "sortable_index"}),
            ("Id", {
                "title": _("ID")}),
            ("Temperature", {
                "title": _("Temperature"),}),
            ("SamplesUsage", {
                "title": _("Samples"),}),
            ("Samples", {
                "title": _("Samples usage"),}),
            ("ContainersUsage", {
                "title": _("Containers"),}),
            ("Containers", {
                "title": _("Containers usage"),}),
        ))

        self.review_states = [{
                "id": "default",
                "contentFilter": {"review_state": "active"},
                "title": _("Active"),
                "transitions": [],
                "confirm_transitions": ["recover_samples"],
                "columns": self.columns.keys(),
            },]

        imgs_path = "++resource++senaite.storage.static/img"
        icon_name = "container_big.png"
        if IStorageFacility.providedBy(self.context):
            icon_name = "facility_big.png"
        self.icon = "{}/{}/{}".format(self.portal_url, imgs_path, icon_name)

        self.context_actions = collections.OrderedDict()
        if not IStorageSamplesContainer.providedBy(self.context):
            self.context_actions[_("Add container")] = {
                "url": "createObject?type_name=StorageContainer",
                "icon": "{}/{}".format(imgs_path, "container.png")
            }
        if IStorageContainer.providedBy(self.context):
            self.context_actions[_("Add samples container")] = {
                "url": "createObject?type_name=StorageSamplesContainer",
                "icon": "{}/{}".format(imgs_path, "box.png")
            }
Exemplo n.º 3
0
 def get_next_container(self):
     """Returns the next container from the list of uids from the request
     that have not been yet processed or None
     """
     next_uids = self.get_next_uids()
     if next_uids:
         container = api.get_object_by_uid(next_uids[0])
         if IStorageSamplesContainer.providedBy(container):
             return container
     return None
Exemplo n.º 4
0
 def get_container(self):
     """Returns the current samples container based on the uids passed in the
     request
     """
     if self.container:
         return self.container
     request_uids = self.get_uids_from_request()
     if not request_uids:
         if IStorageSamplesContainer.providedBy(self.context):
             self.container = self.context
     else:
         self.container = api.get_object_by_uid(request_uids[0])
     return self.container
Exemplo n.º 5
0
def guard_add_samples(samples_container):
    """Guard for adding samples to this container
    """
    if not IStorageSamplesContainer.providedBy(samples_container):
        return False
    return not samples_container.is_full()
Exemplo n.º 6
0
def guard_recover_samples(samples_container):
    """ Guard for recover all samples from this container
    """
    if not IStorageSamplesContainer.providedBy(samples_container):
        return False
    return samples_container.has_samples()