示例#1
0
    def titleStr(self, record):
        """Put the score and the level in the title."""

        score = G(record, N.score)
        if score is None:
            return Qq
        score = H.he(score)
        level = H.he(G(record, N.level)) or Qq
        return f"""{score} - {level}"""
    def bodyCompact(self, **kwargs):
        critId = self.critId
        critRecord = self.critRecord
        perm = self.perm

        critData = critRecord.record
        actual = G(critData, N.actual, default=False)
        msg = E if actual else G(MESSAGES, N.legacyCriterion)

        critKey = f"""{N.criteria}/{critId}/help"""
        (infoShow, infoHide, infoBody) = H.detailx(
            (N.info, N.dismiss),
            critRecord.wrapHelp(),
            critKey,
            openAtts=dict(cls="button small",
                          title="Explanation and scoring guide"),
            closeAtts=dict(cls="button small",
                           title="Hide criteria explanation"),
        )

        score = H.div(self.field(N.score).wrap(asEdit=G(perm, N.isEdit)))
        evidence = H.div(self.field(N.evidence).wrap(asEdit=G(perm, N.isEdit)))
        entry = H.div([
            H.div(H.he(msg), cls="heavy") if msg else E,
            infoShow,
            infoHide,
            infoBody,
            score,
            evidence,
        ], )

        return entry
示例#3
0
    def titleStr(self, record):
        """The title is a sequence number plus the short criterion text."""

        context = self.context
        types = context.types

        seq = H.he(G(record, N.seq)) or Qn
        eid = G(record, N.criteria)
        title = Qq if eid is None else types.criteria.title(eid=eid)
        return f"""{seq}. {title}"""
示例#4
0
    def titleStr(self, record):
        """Put the main type and the sub type in the title."""

        if not record:
            return Qq

        mainType = G(record, N.mainType) or E
        subType = G(record, N.subType) or E
        sep = WHYPHEN if mainType and subType else E
        return H.he(f"""{mainType}{sep}{subType}""")
示例#5
0
    def toDisplay(self, val, markup=True):
        """Turns a real value into a HTML code for readonly display.

        Parameters
        ----------
        val: mixed
            A value of this type.

        Returns
        -------
        string(html)
            Possibly with nice formatting depending on the nature of the value.
        """

        if val is None:
            return QQ if markup else Qq
        valBare = H.he(self.normalize(str(val)))
        return H.span(valBare) if markup else valBare
示例#6
0
    def titleStr(self, record):
        context = self.context
        auth = context.auth

        return H.he(auth.identity(record))
示例#7
0
    def titleStr(self, record):
        """The title is the short criterion text."""

        return H.he(G(record, N.criterion)) or Qq
示例#8
0
 def titleStr(self, record):
     return H.he(G(record, N.title)) or H.he(G(record, N.rep)) or Qq
示例#9
0
    def titleStr(self, record):
        """Puts the 2-letter iso code plus the flag characters in the title."""

        iso = H.he(G(record, N.iso))
        return iso + shiftRegional(iso) if iso else Qc