@@ -87,35 +87,32 @@ def sort_key(t):
8787 positions = list (doc .active_ballot ().active_ad_positions ().items ())
8888 positions .sort (key = sort_key )
8989
90- edit_position_url = ""
91- if has_role (user , "Area Director" ):
92- edit_position_url = urlreverse ('ietf.doc.views_ballot.edit_position' , kwargs = dict (name = doc .name , ballot_id = ballot .pk ))
93-
94- title = "IESG positions (click to show more%s)" % (", right-click to edit position" if edit_position_url else "" )
95-
96- res = ['<a href="%s" data-popup="%s" data-edit="%s" title="%s" class="ballot-icon"><table>' % (
97- urlreverse ("doc_ballot" , kwargs = dict (name = doc .name , ballot_id = ballot .pk )),
90+ res = ['<a href="%s" data-toggle="modal" data-target="#modal-%d" title="IESG positions (click to show more)" class="ballot-icon"><table>' % (
9891 urlreverse ("ietf.doc.views_doc.ballot_popup" , kwargs = dict (name = doc .name , ballot_id = ballot .pk )),
99- edit_position_url ,
100- title
101- )]
92+ ballot .pk )]
10293
10394 res .append ("<tr>" )
10495
10596 for i , (ad , pos ) in enumerate (positions ):
10697 if i > 0 and i % 5 == 0 :
107- res .append ("</tr>" )
108- res .append ("<tr>" )
98+ res .append ("</tr><tr>" )
10999
110100 c = "position-%s" % (pos .pos .slug if pos else "norecord" )
111101
112102 if user_is_person (user , ad ):
113103 c += " my"
114104
115- res .append ('<td class="%s" />' % c )
105+ res .append ('<td class="%s"></td>' % c )
106+
107+ # add sufficient table calls to last row to avoid HTML validation warning
108+ while (i + 1 ) % 5 != 0 :
109+ res .append ('<td class="empty"></td>' )
110+ i = i + 1
116111
117- res .append ("</tr>" )
118- res .append ("</table></a>" )
112+ res .append ("</tr></table></a>" )
113+ # XXX FACELIFT: Loading via href will go away in bootstrap 4.
114+ # See http://getbootstrap.com/javascript/#modals-usage
115+ res .append ('<div id="modal-%d" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog modal-lg"><div class="modal-content"></div></div></div>' % ballot .pk )
119116
120117 return "" .join (res )
121118
@@ -137,7 +134,8 @@ def ballotposition(doc, user):
137134
138135
139136@register .filter
140- def state_age_colored (doc ):
137+ # FACELIFT: added flavor argument for styling
138+ def state_age_colored (doc , flavor = "" ):
141139 if doc .type_id == 'draft' :
142140 if not doc .get_state_slug () in ["active" , "rfc" ]:
143141 # Don't show anything for expired/withdrawn/replaced drafts
@@ -156,7 +154,7 @@ def state_age_colored(doc):
156154 except IndexError :
157155 state_date = datetime .date (1990 ,1 ,1 )
158156 days = (datetime .date .today () - state_date ).days
159- # loosely based on
157+ # loosely based on
160158 # http://trac.tools.ietf.org/group/iesg/trac/wiki/PublishPath
161159 if iesg_state == "lc" :
162160 goal1 = 30
@@ -180,16 +178,26 @@ def state_age_colored(doc):
180178 goal1 = 14
181179 goal2 = 28
182180 if days > goal2 :
183- class_name = "ietf-small ietf-highlight-r"
181+ if flavor == "facelift" :
182+ class_name = "label label-danger"
183+ else :
184+ class_name = "ietf-small ietf-highlight-r"
184185 elif days > goal1 :
185- class_name = "ietf-small ietf-highlight-y"
186+ if flavor == "facelift" :
187+ class_name = "label label-warning"
188+ else :
189+ class_name = "ietf-small ietf-highlight-y"
186190 else :
187191 class_name = "ietf-small"
188192 if days > goal1 :
189193 title = ' title="Goal is <%d days"' % (goal1 ,)
190194 else :
191195 title = ''
192- return mark_safe ('<span class="%s"%s>(for %d day%s)</span>' % (
193- class_name , title , days , 's' if days != 1 else '' ))
196+ # It's too bad that this function returns HTML; this makes it hard to
197+ # style. For the facelift, I therefore needed to add a new "flavor"
198+ # parameter, which is ugly.
199+ return mark_safe ('<span class="%s"%s>%sfor %d day%s%s</span>' % (
200+ class_name , title , '(' if flavor != "facelift" else "" , days ,
201+ 's' if days != 1 else '' , '(' if flavor != "facelift" else "" ))
194202 else :
195203 return ""
0 commit comments