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

1#!/usr/local/bin/python 

2# encoding: utf-8 

3""" 

4*Create the change PI form* 

5 

6:Author: 

7 David Young 

8""" 

9import sys 

10import os 

11import khufu 

12 

13def change_pi_form( 

14 log, 

15 request, 

16 discoveryDataDictionary 

17): 

18 """change_pi_form 

19 

20 **Key Arguments** 

21 

22 - ``log`` -- the logger 

23 - ``request`` -- the pyramid request 

24 - ``discoveryDataDictionary`` -- dictionary of the transient's discovery data 

25  

26 

27 **Return** 

28 

29 - ``changePiForm`` -- the change PI modal form 

30  

31 """ 

32 postToScriptUrl = request.route_path( 

33 'transients_element', elementId=discoveryDataDictionary["transientBucketId"], _query={'method': 'put'}) 

34 thisModal = khufu.modals.modalForm( 

35 log=log, 

36 title="Update PI details for %(masterName)s" % discoveryDataDictionary, 

37 postToScriptUrl=postToScriptUrl, 

38 reloadToUrl=request.path_qs 

39 ) 

40 nameInput = khufu.formInput( 

41 # [ text | password | datetime | datetime-local | date | month | time | week | number | email | url | search | tel | color ] 

42 ttype='text', 

43 placeholder='first and last name', 

44 span=6, 

45 htmlId="piName", 

46 required=True 

47 ) 

48 thisModal.add_form_object( 

49 formObject=nameInput, 

50 label="Name" 

51 ) 

52 

53 emailInput = khufu.formInput( 

54 # [ text | password | datetime | datetime-local | date | month | time | week | number | email | url | search | tel | color ] 

55 ttype='email', 

56 placeholder='PI email address', 

57 span=6, 

58 htmlId="piEmail", 

59 required=True 

60 ) 

61 thisModal.add_form_object( 

62 formObject=emailInput, 

63 label="Email" 

64 ) 

65 modalForm, modalTrigger = thisModal.get() 

66 

67 if discoveryDataDictionary["pi_name"]: 

68 buttonText = """<i class="icon-user7"></i>&nbspPI""" 

69 details = "change the PI details" 

70 else: 

71 buttonText = """<i class="icon-user-add"></i>&nbspPI""" 

72 details = "add a PI for this object" 

73 

74 popover = khufu.popover( 

75 tooltip=True, 

76 placement="bottom", # [ top | bottom | left | right ] 

77 trigger="hover", # [ False | click | hover | focus | manual ] 

78 title=details, 

79 content=False, 

80 delay=20 

81 ) 

82 

83 icon = """<i class="icon-target2"></i>&nbsp""" 

84 thisButton = khufu.button( 

85 buttonText=buttonText, 

86 # [ default | primary | info | success | warning | danger | inverse | link ] 

87 buttonStyle='success', 

88 buttonSize='large', # [ large | default | small | mini ] 

89 href=modalTrigger, 

90 pull="right", # right, left, center 

91 submit=False, 

92 block=False, 

93 disable=False, 

94 dataToggle="modal", # [ modal ] 

95 popover=popover 

96 ) 

97 

98 return modalForm, thisButton