Coverage for control/cust/review_record.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from config import Config as C, Names as N
2from control.record import Record
3from control.html import HtmlElements as H
4from control.utils import pick as G, E
7CW = C.web
9ORPHAN = H.icon(CW.unknown[N.reviewKind])
12class ReviewR(Record):
13 """Logic for review records.
15 Review records have a customised title,
16 showing when the ereview was made and by whom.
18 There is also a `compact` method to present these records,
19 just the title, remarks and decision.
21 !!! hint
22 If the `reviewEntry` record is not part of the workflow, the behaviour
23 of this class falls back to the base class `control.record.Record`.
24 """
26 def __init__(self, *args, **kwargs):
27 super().__init__(*args, **kwargs)
29 def title(self, *args, **kwargs):
30 kind = self.kind
31 uid = self.uid
32 record = self.record
34 creatorId = G(record, N.creator)
35 markup = kwargs.get("markup", True)
36 datetime = self.field(N.dateCreated).wrapBare(markup=markup)
37 date = datetime.split(maxsplit=1)[0]
38 creator = self.field(N.creator).wrapBare(markup=markup)
39 youRep = f""" ({N.you})""" if creatorId == uid else E
40 kindRep = kind or ORPHAN
42 return (
43 H.span(f"""{kindRep} on {date} by {creator}{youRep}""", cls="small")
44 if markup
45 else f"""{kindRep} on {date} by {creator}"""
46 )
48 def bodyCompact(self, myMasters=None, hideMasters=False):
49 perm = self.perm
51 theTitle = self.title()
53 remarks = H.div(
54 self.field(N.remarks).wrap(withLabel=False, asEdit=G(perm, N.isEdit)),
55 )
56 decisionPart = H.div(
57 self.field(N.decision).wrap(withLabel=False, asEdit=G(perm, N.isEdit))
58 )
60 return H.div([decisionPart, theTitle, remarks], cls="review")