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*The comments tab for the PESSTO Object tickets* 

5 

6:Author: 

7 David Young 

8""" 

9import sys 

10import os 

11import datetime 

12import khufu 

13 

14def comments_tab( 

15 log, 

16 request, 

17 discoveryDataDictionary, 

18 objectComments, 

19 objectAkas, 

20 atelData, 

21 lightcurveData, 

22 transientCrossmatches): 

23 """comments tab 

24 

25 **Key Arguments** 

26 

27 - ``log`` -- logger 

28 - ``request`` -- the pyramid request 

29 - ``discoveryDataDictionary`` -- the unique discoveryData dictionary of the object in the pessto marshall database (from view_object_contextual_data) 

30 - ``objectComments`` -- the comments for the object 

31 - ``objectAkas`` -- object akas 

32 - ``lightcurveData`` -- the lightcurve data for the objects displayed on the webpage 

33 - ``atelData`` -- the atel matches for the objects displayed on the webpage 

34 - ``transientCrossmatches`` -- info from the transient crossmatcher 

35  

36 

37 **Return** 

38 

39 - ``comments_tab`` -- for each transient ticket in the transient listings pages 

40  

41 """ 

42 from marshall_webapp.templates.commonelements.tickets.single_ticket import ticket_building_blocks, tabs 

43 from marshall_webapp.templates.commonelements.tickets import single_ticket 

44 from marshall_webapp.templates.commonelements import forms 

45 

46 log.debug('starting the ``comments_tab`` function') 

47 

48 commentCount, comments_block = ticket_building_blocks.comments_block.comments_block( 

49 log=log, 

50 request=request, 

51 discoveryDataDictionary=discoveryDataDictionary, 

52 objectComments=objectComments 

53 ) 

54 

55 newCommentForm = forms.add_new_comment_to_object_form.add_new_comment_to_object_form( 

56 log=log, 

57 request=request, 

58 transientBucketId=discoveryDataDictionary["transientBucketId"] 

59 ) 

60 

61 # EXTRA OVERVIEW INFO 

62 ## VARIABLES ## 

63 

64 identity_block = ticket_building_blocks.identity_block.identity_block( 

65 log=log, 

66 request=request, 

67 discoveryDataDictionary=discoveryDataDictionary, 

68 objectAkas=objectAkas, 

69 ) 

70 

71 object_info_block = ticket_building_blocks.object_info_block.object_info_block( 

72 log=log, 

73 request=request, 

74 discoveryDataDictionary=discoveryDataDictionary, 

75 ) 

76 

77 host_info_block = ticket_building_blocks.host_info_block.host_info_block( 

78 log=log, 

79 request=request, 

80 discoveryDataDictionary=discoveryDataDictionary, 

81 transientCrossmatches=transientCrossmatches 

82 ) 

83 

84 lightcurve_block = ticket_building_blocks.lightcurve_block.lightcurve_block( 

85 log=log, 

86 request=request, 

87 discoveryDataDictionary=discoveryDataDictionary, 

88 lightcurveData=lightcurveData, 

89 objectAkas=objectAkas 

90 ) 

91 

92 classification_block = ticket_building_blocks.classification_block.classification_block( 

93 log=log, 

94 request=request, 

95 discoveryDataDictionary=discoveryDataDictionary, 

96 ) 

97 

98 if classification_block: 

99 theseBlocks = [identity_block, object_info_block, classification_block, 

100 host_info_block, lightcurve_block] 

101 else: 

102 theseBlocks = [identity_block, object_info_block, 

103 host_info_block, lightcurve_block] 

104 

105 thisRow = "" 

106 blockCount = len(theseBlocks) 

107 span = int(round(12. / (len(theseBlocks)) - 0.5)) 

108 remainingSpans = 12 - span * len(theseBlocks) 

109 count = 1 

110 for block in theseBlocks: 

111 thisSpan = span 

112 if count <= remainingSpans: 

113 thisSpan = span + 1 

114 count += 1 

115 block = khufu.grid_column( 

116 span=thisSpan, # 1-12 

117 offset=0, # 1-12 

118 content=block 

119 ) 

120 thisRow = """%(thisRow)s %(block)s""" % locals() 

121 

122 overviewWell = khufu.grid_row( 

123 responsive=True, 

124 columns=thisRow 

125 ) 

126 

127 overviewWell = khufu.well( 

128 wellText=overviewWell, 

129 wellSize='default', # [ "default" | "large" | "small" ] 

130 htmlClass="overviewWell" 

131 ) 

132 

133 comments_block = u"""%(newCommentForm)s %(overviewWell)s %(comments_block)s""" % locals( 

134 ) 

135 

136 comments_tab = single_ticket._ticket_tab_template( 

137 log, 

138 request=request, 

139 tabHeader=False, 

140 blockList=[comments_block], 

141 tabFooter=False, 

142 htmlId="commentstab" 

143 ) 

144 

145 log.debug('completed the ``comments_tab`` function') 

146 return commentCount, "%(comments_tab)s" % locals()