Coverage for control/cust/criteriaentry_details.py : 89%

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 Names as N
2from control.details import Details
3from control.html import HtmlElements as H
4from control.utils import pick as G, cap1, E
7class CriteriaEntryD(Details):
8 """Logic for detail records of criteria entries.
10 The main point of departure from the standard behaviour is that
11 we sort and present the `reviewEntry` detail records into two columns:
12 those of the `expert` reviewer and those of the `final` reviewer.
14 !!! hint
15 If the `criteriaEntry` record is not part of the workflow, the behaviour
16 of this class falls back to the base class `control.details.Details`.
17 """
19 def __init__(self, recordObj):
20 super().__init__(recordObj)
22 def wrap(self, *args, **kwargs):
23 wfitem = self.wfitem
24 if not wfitem: 24 ↛ 25line 24 didn't jump to line 25, because the condition on line 24 was never true
25 return super().wrap(*args, **kwargs)
27 details = self.details
29 (reviewer,) = wfitem.info(N.assessment, N.reviewer)
31 self.fetchDetails(
32 N.reviewEntry, sortKey=lambda r: G(r, N.dateCreated, default=0),
33 )
34 (tableObj, records) = G(details, N.reviewEntry, default=(None, []))
35 if not tableObj: 35 ↛ 36line 35 didn't jump to line 36, because the condition on line 35 was never true
36 return E
38 byReviewer = {N.expert: E, N.final: E}
40 for dest in (N.expert, N.final):
41 byReviewer[dest] = self.wrapDetail(
42 N.reviewEntry,
43 filterFunc=lambda r: G(r, N.creator) == G(reviewer, dest),
44 bodyMethod=N.compact,
45 expanded=True,
46 withProv=False,
47 withN=False,
48 inner=False,
49 )
51 if not byReviewer[dest]:
52 byReviewer[dest] = H.span("""No review comment yet""", cls="info small")
54 return H.div(
55 [
56 f"""<!-- begin reviewer {dest} -->"""
57 + H.div(
58 [H.div(cap1(dest), cls="head"), G(byReviewer, dest)],
59 cls=f"reviewentries {dest}",
60 )
61 + f"""<!-- end reviewer {dest} -->"""
62 for dest in reviewer
63 ],
64 cls="reviewers",
65 )