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.details import Details
3from control.html import HtmlElements as H
4from control.utils import pick as G, cap1, E
7CT = C.tables
8CW = C.web
10REVIEW_DECISION = CW.messages[N.reviewDecision]
13class AssessmentD(Details):
14 """Logic for detail records of assessments.
16 An assessment is filled out by entering data in a fixed set of `criteriaEntry` records.
17 Each `criteriaEntry` corresponds to a specific `criteria` record.
18 The type of the assessment determines wich set of `criteria` is linked to it.
20 !!! hint
21 If the `assessment` record is not part of the workflow, the behaviour
22 of this class falls back to the base class `control.details.Details`.
23 """
25 def __init__(self, recordObj):
26 super().__init__(recordObj)
28 def wrap(self, *args, **kwargs):
29 wfitem = self.wfitem
30 if not wfitem:
31 return super().wrap(*args, **kwargs)
33 (reviewer, reviewers) = wfitem.info(N.assessment, N.reviewer, N.reviewers)
35 self.fetchDetails(N.criteriaEntry, sortKey=self.cEntrySort)
37 criteriaPart = self.wrapDetail(N.criteriaEntry, bodyMethod=N.compact)
39 self.fetchDetails(
40 N.review, sortKey=lambda r: G(r, N.dateCreated, default=0),
41 )
43 byReviewer = {N.expert: E, N.final: E}
45 for dest in (N.expert, N.final):
46 byReviewer[dest] = self.wrapDetail(
47 N.review,
48 filterFunc=lambda r: G(r, N.creator) == G(reviewer, dest),
49 bodyMethod=N.compact,
50 withDetails=True,
51 expanded=True,
52 withProv=True,
53 withN=False,
54 inner=False,
55 )
57 if not byReviewer[dest]:
58 byReviewer[dest] = H.span(
59 """No review decision yet""", cls="info small"
60 )
62 showEid = self.mustShow(N.review, kwargs)
64 orphanedReviews = self.wrapDetail(
65 N.review,
66 filterFunc=lambda r: G(r, N.creator) not in reviewers,
67 withProv=True,
68 showEid=showEid,
69 )
71 reviewPart = H.div(
72 [
73 H.div(
74 [H.div(cap1(dest), cls="head"), G(byReviewer, dest)],
75 cls=f"reviews {dest}",
76 )
77 for dest in reviewer
78 ],
79 cls="reviewers",
80 ) + (
81 H.div(
82 [
83 H.div(cap1(N.orphaned) + " " + N.reviews, cls="head"),
84 orphanedReviews,
85 ],
86 )
87 if orphanedReviews
88 else E
89 )
91 statusRep = wfitem.status(N.assessment)
93 return H.div(
94 [criteriaPart, statusRep, H.div(REVIEW_DECISION, cls="head"), reviewPart],
95 )
97 @staticmethod
98 def cEntrySort(r):
99 return (G(r, N.assessment), G(r, N.seq) or 0)