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 Config as C, Names as N 

2from control.table import Table 

3from control.utils import pick as G, thisYear 

4 

5CW = C.web 

6 

7UNKNOWN = CW.unknown 

8Qt = G(UNKNOWN, N.title) 

9 

10 

11class ContribT(Table): 

12 """Logic for the contrib table. 

13 

14 When we insert a contrib record, we want to fill in 

15 

16 * the current year 

17 * the country of the current user 

18 * the name of the current user 

19 * the email address of the current user 

20 

21 set of criteriaEntry records and prefill some of their fields. 

22 """ 

23 

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

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

26 

27 def insert(self, force=False): 

28 mayInsert = force or self.mayInsert 

29 if not mayInsert: 

30 return None 

31 

32 context = self.context 

33 db = context.db 

34 auth = context.auth 

35 uid = self.uid 

36 eppn = self.eppn 

37 countryId = self.countryId 

38 table = self.table 

39 

40 (name, email) = auth.nameEmail() 

41 

42 prefilledFields = { 

43 N.title: Qt, 

44 N.year: G(db.yearInv, thisYear()), 

45 N.country: countryId, 

46 N.contactPersonName: [name], 

47 N.contactPersonEmail: [email], 

48 } 

49 

50 result = db.insertItem(table, uid, eppn, False, **prefilledFields) 

51 self.adjustWorkflow(result) 

52 

53 return result