Example #1
0
    def __init__(self, context, request):
        super(AnalysisSpecificationView, self).__init__(context, request)

        self.catalog = "bika_setup_catalog"
        self.contentFilter = {
            "portal_type": "AnalysisService",
            "is_active": True,
            "sort_on": "sortable_title",
            "sort_order": "ascending",
        }
        self.context_actions = {}

        self.show_column_toggles = False
        self.show_select_column = True
        self.show_select_all_checkbox = False
        self.pagesize = 999999
        self.allow_edit = True
        self.show_search = True
        self.omit_form = True
        self.fetch_transitions_on_select = False

        # Categories
        if self.show_categories_enabled():
            self.categories = []
            self.show_categories = True
            self.expand_all_categories = False

        # Operator Choices
        self.min_operator_choices = to_choices(MIN_OPERATORS)
        self.max_operator_choices = to_choices(MAX_OPERATORS)

        self.columns = collections.OrderedDict((
            ("Title", {
                "title": _("Service"),
                "index": "sortable_title",
                "sortable": False
            }),
            ("Keyword", {
                "title": _("Keyword"),
                "sortable": False
            }),
            ("Methods", {
                "title": _("Methods"),
                "sortable": False
            }),
            ("Unit", {
                "title": _("Unit"),
                "sortable": False
            }),
            ("warn_min", {
                "title": _("Min warn"),
                "sortable": False
            }),
            ("min_operator", {
                "title": _("Min operator"),
                "type": "choices",
                "sortable": False
            }),
            ("min", {
                "title": _("Min"),
                "sortable": False
            }),
            ("max_operator", {
                "title": _("Max operator"),
                "type": "choices",
                "sortable": False
            }),
            ("max", {
                "title": _("Max"),
                "sortable": False
            }),
            ("warn_max", {
                "title": _("Max warn"),
                "sortable": False
            }),
            ("hidemin", {
                "title": _("< Min"),
                "sortable": False
            }),
            ("hidemax", {
                "title": _("> Max"),
                "sortable": False
            }),
            ("rangecomment", {
                "title": _("Range comment"),
                "sortable": False,
                "type": "remarks",
                "toggle": False
            }),
        ))

        self.review_states = [
            {
                "id": "default",
                "title": _("All"),
                "contentFilter": {},
                "transitions": [{
                    "id": "disallow-all-possible-transitions"
                }],
                "columns": self.columns.keys(),
            },
        ]
Example #2
0
    def folderitem(self, obj, item, index):
        """Service triggered each time an item is iterated in folderitems.

        The use of this service prevents the extra-loops in child objects.

        :obj: the instance of the class to be foldered
        :item: dict containing the properties of the object to be used by
            the template
        :index: current index of the item
        """
        service = api.get_object(obj)

        if service.getKeyword() in self.specsresults:
            specresults = self.specsresults[service.getKeyword()]
        else:
            specresults = {
                "keyword": service.getKeyword(),
                "min_operator": "",
                "min": "",
                "max_operator": "",
                "max": "",
                "warn_min": "",
                "warn_max": "",
                "hidemin": "",
                "hidemax": "",
                "rangecomment": "",
            }

        # Icons
        after_icons = ""
        if service.getAccredited():
            after_icons += get_image("accredited.png", title=_("Accredited"))
        if service.getAttachmentOption() == "r":
            after_icons += get_image("attach_reqd.png",
                                     title=_("Attachment required"))
        if service.getAttachmentOption() == "n":
            after_icons += get_image("attach_no.png",
                                     title=_("Attachment not permitted"))

        state = api.get_workflow_status_of(service, state_var="inactive_state")
        unit = service.getUnit()

        item = {
            "obj":
            service,
            "id":
            service.getId(),
            "uid":
            service.UID(),
            "keyword":
            service.getKeyword(),
            "title":
            service.Title(),
            "unit":
            unit,
            "category":
            service.getCategoryTitle(),
            "selected":
            service.getKeyword() in self.specsresults.keys(),
            "type_class":
            "contenttype-ReferenceResult",
            "url":
            service.absolute_url(),
            "relative_url":
            service.absolute_url(),
            "view_url":
            service.absolute_url(),
            "service":
            service.Title(),
            "min_operator":
            specresults.get("min_operator", "geq"),
            "min":
            specresults.get("min", ""),
            "max_operator":
            specresults.get("max_operator", "leq"),
            "max":
            specresults.get("max", ""),
            "warn_min":
            specresults.get("warn_min", ""),
            "warn_max":
            specresults.get("warn_max", ""),
            "hidemin":
            specresults.get("hidemin", ""),
            "hidemax":
            specresults.get("hidemax", ""),
            "rangecomment":
            specresults.get("rangecomment", ""),
            "replace": {},
            "before": {},
            "after": {
                "service": after_icons,
            },
            "choices": {
                "min_operator": to_choices(MIN_OPERATORS),
                "max_operator": to_choices(MAX_OPERATORS),
            },
            "class":
            "state-%s" % (state),
            "state_class":
            "state-%s" % (state),
            "allow_edit": [
                "min", "max", "warn_min", "warn_max", "hidemin", "hidemax",
                "rangecomment", "min_operator", "max_operator"
            ],
            "table_row_class":
            "even",
            "required": ["min_operator", "max_operator"]
        }

        # Add methods
        methods = service.getMethods()
        if methods:
            links = map(
                lambda m: get_link(
                    m.absolute_url(), value=m.Title(), css_class="link"),
                methods)
            item["replace"]["methods"] = ", ".join(links)
        else:
            item["methods"] = ""

        return item