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.utils import pick as G 

3from control.table import Table 

4from control.typ.related import castObjectId 

5 

6 

7class ReviewT(Table): 

8 """Logic for the review table. 

9 

10 Inserting a review means also to insert the right 

11 set of reviewEntry records and prefill some of their fields. 

12 """ 

13 

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

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

16 

17 def insert(self, force=False, masterTable=None, masterId=None): 

18 mayInsert = force or self.mayInsert 

19 if not mayInsert: 19 ↛ 20line 19 didn't jump to line 20, because the condition on line 19 was never true

20 return None 

21 

22 if not masterTable or not masterId: 22 ↛ 23line 22 didn't jump to line 23, because the condition on line 22 was never true

23 return None 

24 

25 context = self.context 

26 db = context.db 

27 uid = self.uid 

28 eppn = self.eppn 

29 table = self.table 

30 

31 masterOid = castObjectId(masterId) 

32 masterRecord = context.getItem(N.assessment, masterOid) 

33 contribId = G(masterRecord, N.contrib) 

34 if not contribId: 34 ↛ 35line 34 didn't jump to line 35, because the condition on line 34 was never true

35 return None 

36 

37 wfitem = context.getWorkflowItem(contribId) 

38 

39 if not wfitem.permission(N.startReview): 39 ↛ 40line 39 didn't jump to line 40, because the condition on line 39 was never true

40 return contribId 

41 

42 (contribType,) = wfitem.info(N.contrib, N.type) 

43 (assessmentTitle,) = wfitem.info(N.assessment, N.title) 

44 

45 fields = { 

46 N.contrib: contribId, 

47 masterTable: masterOid, 

48 N.reviewType: contribType, 

49 N.title: f"review of {assessmentTitle}", 

50 } 

51 reviewId = db.insertItem(table, uid, eppn, False, **fields) 

52 

53 criteriaEntries = db.getDetails( 

54 N.criteriaEntry, 

55 N.assessment, 

56 masterOid, 

57 sortKey=lambda r: G(r, N.seq, default=0), 

58 ) 

59 records = [ 

60 { 

61 N.seq: G(critEntry, N.seq, default=0), 

62 N.criteria: G(critEntry, N.criteria), 

63 N.criteriaEntry: G(critEntry, N._id), 

64 N.assessment: masterOid, 

65 N.review: reviewId, 

66 } 

67 for critEntry in criteriaEntries 

68 ] 

69 db.insertMany(N.reviewEntry, uid, eppn, records) 

70 self.adjustWorkflow(contribId, new=False) 

71 

72 return contribId