Hide keyboard shortcuts

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.record import Record 

3from control.html import HtmlElements as H 

4 

5 

6class AssessmentR(Record): 

7 """Logic for assessment records. 

8 

9 Assessment records that are part of a workflow have customised titles, 

10 showing the creator and create data of the assessment. 

11 

12 !!! hint 

13 If the `assessment` record is not part of the workflow, the behaviour 

14 of this class falls back to the base class `control.record.Record`. 

15 """ 

16 

17 def __init__(self, *args, **kwargs): 

18 super().__init__(*args, **kwargs) 

19 

20 def title(self, record=None, *args, **kwargs): 

21 inActualCls = self.inActualCls(record) 

22 wfitem = self.wfitem 

23 if not wfitem: 

24 return super().title(*args, **kwargs) 

25 

26 markup = kwargs.get("markup", True) 

27 datetime = self.field(N.dateCreated).wrapBare(markup=markup) 

28 date = datetime.split(maxsplit=1)[0] 

29 creator = self.field(N.creator).wrapBare(markup=markup) 

30 valBare = f"""on {date} by {creator}""" 

31 return ( 

32 H.span(f"""on {date} by {creator}""", cls=f"small {inActualCls}") 

33 if markup 

34 else valBare 

35 ) 

36 

37 def field(self, fieldName, **kwargs): 

38 """Customised factory function to wrap a field object around the data 

39 of a field. 

40 

41 This function only comes into play when the assigning reviewers. 

42 Office users assign reviewers by editing the fields `reviewerE` and `reviewerF`. 

43 But they may only do so if the assessment is submitted and not 

44 withdrawn and there is not yet a final verdict. 

45 

46 If those conditions apply, the base version of `field` will be called 

47 with a `mayEdit=False` parameter. 

48 """ 

49 

50 if fieldName in {N.reviewerE, N.reviewerF}: 

51 wfitem = self.wfitem 

52 

53 if wfitem: 

54 (stage,) = wfitem.info(N.assessment, N.stage) 

55 if stage not in { 

56 N.submitted, 

57 N.submittedRevised, 

58 N.reviewRevise, 

59 }: 

60 kwargs[N.mayEdit] = False 

61 

62 return super().field(fieldName, **kwargs)