1313from ietf .group .models import Group
1414from ietf .name .models import BallotPositionName
1515from ietf .person .models import Person
16- from ietf .idrfc .lastcall import request_last_call
17- from ietf .idrfc .mails import email_owner , email_state_changed
18- from ietf .idrfc .utils import add_document_comment
16+ from ietf .doc .lastcall import request_last_call
17+ from ietf .doc .mails import email_ad , email_state_changed
18+ # from ietf.idrfc.utils import add_document_comment
1919from ietf .iesg .models import TelechatDate , TelechatAgendaItem , WGAction
2020from ietf .iesg .views import _agenda_data
2121
@@ -55,9 +55,9 @@ def get_doc_list(agenda):
5555 docs = []
5656 for key in sorted (agenda ['docs' ]):
5757 docs .extend (agenda ['docs' ][key ])
58-
58+
5959 return [x ['obj' ] for x in docs ]
60-
60+
6161def get_doc_writeup (doc ):
6262 '''
6363 This function takes a Document object and returns the ballot writeup for display
@@ -73,24 +73,24 @@ def get_doc_writeup(doc):
7373 path = os .path .join (doc .get_file_path (),doc .filename_with_rev ())
7474 writeup = get_document_content (doc .name ,path ,split = False ,markup = False )
7575 return writeup
76-
76+
7777def get_last_telechat_date ():
7878 '''
7979 This function returns the date of the last telechat
8080 Tried TelechatDocEvent.objects.latest but that will return today's telechat
8181 '''
8282 return TelechatDate .objects .filter (date__lt = datetime .date .today ()).order_by ('-date' )[0 ].date
8383 #return '2011-11-01' # uncomment for testing
84-
84+
8585def get_next_telechat_date ():
8686 '''
8787 This function returns the date of the next telechat
8888 '''
8989 return TelechatDate .objects .filter (date__gte = datetime .date .today ()).order_by ('date' )[0 ].date
90-
90+
9191def get_section_header (file ,agenda ):
9292 '''
93- This function takes a filename and an agenda dictionary and returns the
93+ This function takes a filename and an agenda dictionary and returns the
9494 agenda section header as a string for use in the doc template
9595 '''
9696 h1 = {'2' :'Protocol Actions' ,'3' :'Document Actions' ,'4' :'Working Group Actions' }
@@ -100,18 +100,18 @@ def get_section_header(file,agenda):
100100 h3a = {'1' :'New Item' ,'2' :'Returning Item' ,'3' :'For Action' }
101101 h3b = {'1' :'Proposed for IETF Review' ,'2' :'Proposed for Approval' }
102102 h3c = {'1' :'Under Evaluation for IETF Review' ,'2' :'Proposed for Approval' }
103-
103+
104104 # Robert updated _agenda_data to return Document objects instead of the ID wrapper
105105 #doc = InternetDraft.objects.get(filename=file)
106106 doc = Document .objects .get (name = file )
107-
107+
108108 test = {'obj' :doc }
109109 for k ,v in agenda ['docs' ].iteritems ():
110110 if test in v :
111111 section = k
112112 count = '%s of %s' % (v .index (test ) + 1 , len (v ))
113113 break
114-
114+
115115 header = [ '%s %s' % (section [1 ], h1 [section [1 ]]) ]
116116 if section [1 ] == '2' :
117117 header .append ('%s.%s %s' % (section [1 ], section [2 ], h2a [section [2 ]]))
@@ -127,7 +127,7 @@ def get_section_header(file,agenda):
127127 else :
128128 header .append ('%s.%s.%s %s' % (section [1 ], section [2 ], section [3 ], h3a [section [3 ]]))
129129 header .append (count )
130-
130+
131131 return header
132132
133133def get_first_doc (agenda ):
@@ -137,28 +137,28 @@ def get_first_doc(agenda):
137137 for k ,v in sorted (agenda ['docs' ].iteritems ()):
138138 if v :
139139 return v [0 ]['obj' ]
140-
140+
141141 return None
142-
142+
143143# -------------------------------------------------
144144# View Functions
145145# -------------------------------------------------
146146def bash (request , date ):
147-
147+
148148 agenda = _agenda_data (request , date = date )
149-
149+
150150 return render_to_response ('telechat/bash.html' , {
151151 'agenda' : agenda ,
152152 'date' : date },
153153 RequestContext (request , {}),
154154 )
155-
155+
156156def doc (request , date ):
157157 '''
158158 This view redirects to doc_detail using the first document in the agenda or
159159 displays the message "No Documents"
160160 '''
161-
161+
162162 agenda = _agenda_data (request , date = date )
163163 doc = get_first_doc (agenda )
164164 if doc :
@@ -171,29 +171,29 @@ def doc(request, date):
171171 'document' : None },
172172 RequestContext (request , {}),
173173 )
174-
174+
175175def doc_detail (request , date , name ):
176176 '''
177177 This view displays the ballot information for the document, and lets the user make
178178 changes to ballot positions and document state.
179179 '''
180180 doc = get_object_or_404 (Document , docalias__name = name )
181-
182- # As of Datatracker v4.32, Conflict Review (conflrev) Document Types can
181+
182+ # As of Datatracker v4.32, Conflict Review (conflrev) Document Types can
183183 # be added to the Telechat agenda. If Document.type_id == draft use draft-iesg
184184 # for state type
185185 state_type = doc .type_id
186186 if doc .type_id == 'draft' :
187187 state_type = 'draft-iesg'
188-
188+
189189 started_process = doc .latest_event (type = "started_iesg_process" )
190190 login = request .user .get_profile ()
191-
191+
192192 if doc .active_ballot ():
193193 ballots = doc .active_ballot ().active_ad_positions () # returns dict of ad:ballotpositiondocevent
194194 else :
195195 ballots = []
196-
196+
197197 # setup form initials
198198 initial_ballot = []
199199 open_positions = 0
@@ -203,30 +203,30 @@ def doc_detail(request, date, name):
203203 open_positions += 1
204204 elif not ballots [key ]:
205205 open_positions += 1
206-
206+
207207 tags = doc .tags .filter (slug__in = TELECHAT_TAGS )
208208 tag = tags [0 ].pk if tags else None
209-
209+
210210 writeup = get_doc_writeup (doc )
211-
211+
212212 initial_state = {'state' :doc .get_state (state_type ).pk ,
213213 'substate' :tag }
214-
214+
215215 BallotFormset = formset_factory (BallotForm , extra = 0 )
216216 agenda = _agenda_data (request , date = date )
217217 header = get_section_header (name ,agenda ) if name else ''
218-
218+
219219 # nav button logic
220220 doc_list = get_doc_list (agenda )
221221 nav_start = nav_end = False
222222 if doc == doc_list [0 ]:
223223 nav_start = True
224224 if doc == doc_list [- 1 ]:
225225 nav_end = True
226-
226+
227227 if request .method == 'POST' :
228228 button_text = request .POST .get ('submit' , '' )
229-
229+
230230 # logic from idrfc/views_ballot.py EditPositionRedesign
231231 if button_text == 'update_ballot' :
232232 formset = BallotFormset (request .POST , initial = initial_ballot )
@@ -248,12 +248,12 @@ def doc_detail(request, date, name):
248248 pos .desc = '[Ballot Position Update] Position for %s has been changed to %s by %s' % (ad .name , pos .pos .name , login .name )
249249 pos .save ()
250250 has_changed = True
251-
251+
252252 if has_changed :
253253 messages .success (request ,'Ballot position changed.' )
254254 url = reverse ('telechat_doc_detail' , kwargs = {'date' :date ,'name' :name })
255255 return HttpResponseRedirect (url )
256-
256+
257257 # logic from idrfc/views_edit.py change_stateREDESIGN
258258 elif button_text == 'update_state' :
259259 formset = BallotFormset (initial = initial_ballot )
@@ -267,45 +267,45 @@ def doc_detail(request, date, name):
267267 # as if IESG tags are a substate
268268 prev_tag = doc .tags .filter (slug__in = (TELECHAT_TAGS ))
269269 prev_tag = prev_tag [0 ] if prev_tag else None
270-
270+
271271 #if state != prev or tag != prev_tag:
272272 if state_form .changed_data :
273273 save_document_in_history (doc )
274274 old_description = doc .friendly_state ()
275-
275+
276276 if 'state' in state_form .changed_data :
277277 doc .set_state (state )
278-
278+
279279 if 'substate' in state_form .changed_data :
280280 if prev_tag :
281281 doc .tags .remove (prev_tag )
282282 if tag :
283283 doc .tags .add (tag )
284-
284+
285285 new_description = doc .friendly_state ()
286286 e = log_state_changed (request , doc , login , new_description , old_description )
287287 doc .time = e .time
288288 doc .save ()
289-
289+
290290 email_state_changed (request , doc , e .desc )
291- email_owner (request , doc , doc .ad , login , e .desc )
292-
291+ email_ad (request , doc , doc .ad , login , e .desc )
292+
293293 if state .slug == "lc-req" :
294294 request_last_call (request , doc )
295-
295+
296296 messages .success (request ,'Document state updated' )
297297 url = reverse ('telechat_doc_detail' , kwargs = {'date' :date ,'name' :name })
298- return HttpResponseRedirect (url )
298+ return HttpResponseRedirect (url )
299299 else :
300300 formset = BallotFormset (initial = initial_ballot )
301301 state_form = ChangeStateForm (initial = initial_state )
302-
302+
303303 # if this is a conflict review document add referenced document
304304 if doc .type_id == 'conflrev' :
305- conflictdoc = doc .relateddocument_set .get (relationship__slug = 'conflrev' ).target .document
305+ conflictdoc = doc .relateddocument_set .get (relationship__slug = 'conflrev' ).target .document
306306 else :
307307 conflictdoc = None
308-
308+
309309 return render_to_response ('telechat/doc.html' , {
310310 'date' : date ,
311311 'document' : doc ,
@@ -320,10 +320,10 @@ def doc_detail(request, date, name):
320320 'nav_end' : nav_end },
321321 RequestContext (request , {}),
322322 )
323-
323+
324324def doc_navigate (request , date , name , nav ):
325325 '''
326- This view takes three arguments:
326+ This view takes three arguments:
327327 date - the date of the Telechat
328328 name - the name of the current document being displayed
329329 nav - [next|previous] which direction the user wants to navigate in the list of docs
@@ -332,22 +332,22 @@ def doc_navigate(request, date, name, nav):
332332 doc = get_object_or_404 (Document , docalias__name = name )
333333 agenda = _agenda_data (request , date = date )
334334 target = name
335-
335+
336336 docs = get_doc_list (agenda )
337337 index = docs .index (doc )
338-
338+
339339 if nav == 'next' and index < len (docs ) - 1 :
340340 target = docs [index + 1 ].name
341341 elif nav == 'previous' and index != 0 :
342342 target = docs [index - 1 ].name
343-
343+
344344 url = reverse ('telechat_doc_detail' , kwargs = {'date' :date ,'name' :target })
345345 return HttpResponseRedirect (url )
346346
347347def main (request ):
348348 '''
349349 The is the main view where the user selects an existing telechat or creates a new one.
350-
350+
351351 NOTES ON EXTERNAL HELPER FUNCTIONS:
352352 _agenda_data(): returns dictionary of agenda sections
353353 get_ballot(name): returns a BallotWrapper and RfcWrapper or IdWrapper
@@ -356,7 +356,7 @@ def main(request):
356356 date = request .POST ['date' ]
357357 url = reverse ('telechat_doc' , kwargs = {'date' :date })
358358 return HttpResponseRedirect (url )
359-
359+
360360 choices = [ (d .date .strftime ('%Y-%m-%d' ),
361361 d .date .strftime ('%Y-%m-%d' )) for d in TelechatDate .objects .all () ]
362362 next_telechat = get_next_telechat_date ().strftime ('%Y-%m-%d' )
@@ -366,22 +366,22 @@ def main(request):
366366 'form' : form },
367367 RequestContext (request , {}),
368368 )
369-
369+
370370def management (request , date ):
371371 '''
372372 This view displays management issues and lets the user update the status
373373 '''
374-
374+
375375 agenda = _agenda_data (request , date = date )
376376 issues = TelechatAgendaItem .objects .filter (type = 3 ).order_by ('id' )
377-
377+
378378 return render_to_response ('telechat/management.html' , {
379379 'agenda' : agenda ,
380380 'date' : date ,
381381 'issues' : issues },
382382 RequestContext (request , {}),
383383 )
384-
384+
385385def minutes (request , date ):
386386 '''
387387 This view shows a list of documents that were approved since the last telechat
@@ -396,9 +396,9 @@ def minutes(request, date):
396396 docs = [ e .doc for e in events ]
397397 pa_docs = [ d for d in docs if d .intended_std_level .slug not in ('inf' ,'exp' ,'hist' ) ]
398398 da_docs = [ d for d in docs if d .intended_std_level .slug in ('inf' ,'exp' ,'hist' ) ]
399-
399+
400400 agenda = _agenda_data (request , date = date )
401-
401+
402402 return render_to_response ('telechat/minutes.html' , {
403403 'agenda' : agenda ,
404404 'date' : date ,
@@ -407,7 +407,7 @@ def minutes(request, date):
407407 'da_docs' : da_docs },
408408 RequestContext (request , {}),
409409 )
410-
410+
411411def new (request ):
412412 '''
413413 This view creates a new telechat agenda and redirects to the default view
@@ -416,21 +416,20 @@ def new(request):
416416 date = request .POST ['date' ]
417417 # create legacy telechat record
418418 Telechat .objects .create (telechat_date = date )
419-
419+
420420 messages .success (request ,'New Telechat Agenda created' )
421421 url = reverse ('telechat_doc' , kwargs = {'date' :date ,'name' :name })
422- return HttpResponseRedirect (url )
423-
422+ return HttpResponseRedirect (url )
423+
424424def roll_call (request , date ):
425-
425+
426426 agenda = _agenda_data (request , date = date )
427427 ads = Person .objects .filter (role__name = 'ad' )
428428 sorted_ads = sorted (ads , key = lambda a : a .name_parts ()[3 ])
429-
429+
430430 return render_to_response ('telechat/roll_call.html' , {
431431 'agenda' : agenda ,
432432 'date' : date ,
433433 'people' :sorted_ads },
434434 RequestContext (request , {}),
435435 )
436-
0 commit comments