@@ -140,6 +140,12 @@ class InternetDraft(models.Model):
140140 def save (self ):
141141 self .id_document_key = self .id_document_name .upper ()
142142 super (InternetDraft , self ).save ()
143+ def displayname (self ):
144+ return "%s-%s.txt" % ( self .filename , self .revision )
145+ def doclink (self ):
146+ return "http://www.ietf.org/internet-drafts/%s" % ( self .displayname () )
147+ def group_acronym (self ):
148+ return self .group .acronym
143149 def __str__ (self ):
144150 return self .filename
145151 def idstate (self ):
@@ -233,12 +239,114 @@ def __str__(self):
233239 class Meta :
234240 db_table = 'area_directors'
235241
242+ ###
243+ # RFC tables
244+
245+ class RfcIntendedStatus (models .Model ):
246+ intended_status_id = models .AutoField (primary_key = True )
247+ status = models .CharField (maxlength = 25 , db_column = 'status_value' )
248+ def __str__ (self ):
249+ return self .status
250+ class Meta :
251+ db_table = 'rfc_intend_status'
252+ verbose_name = 'RFC Intended Status Field'
253+ class Admin :
254+ pass
255+
256+ class RfcStatus (models .Model ):
257+ status_id = models .AutoField (primary_key = True )
258+ status = models .CharField (maxlength = 25 , db_column = 'status_value' )
259+ def __str__ (self ):
260+ return self .status
261+ class Meta :
262+ db_table = 'rfc_status'
263+ verbose_name = 'RFC Status'
264+ verbose_name_plural = 'RFC Statuses'
265+ class Admin :
266+ pass
267+
268+ class Rfc (models .Model ):
269+ rfc_number = models .IntegerField (primary_key = True )
270+ rfc_name = models .CharField (maxlength = 200 )
271+ rfc_name_key = models .CharField (maxlength = 200 , editable = False )
272+ group_acronym = models .CharField (blank = True , maxlength = 8 )
273+ area_acronym = models .CharField (blank = True , maxlength = 8 )
274+ status = models .ForeignKey (RfcStatus , db_column = "status_id" )
275+ intended_status = models .ForeignKey (RfcIntendedStatus , db_column = "intended_status_id" )
276+ fyi_number = models .CharField (blank = True , maxlength = 20 )
277+ std_number = models .CharField (blank = True , maxlength = 20 )
278+ txt_page_count = models .IntegerField (null = True , blank = True )
279+ online_version = models .CharField (blank = True , maxlength = 3 )
280+ rfc_published_date = models .DateField (null = True , blank = True )
281+ proposed_date = models .DateField (null = True , blank = True )
282+ draft_date = models .DateField (null = True , blank = True )
283+ standard_date = models .DateField (null = True , blank = True )
284+ historic_date = models .DateField (null = True , blank = True )
285+ lc_sent_date = models .DateField (null = True , blank = True )
286+ lc_expiration_date = models .DateField (null = True , blank = True )
287+ b_sent_date = models .DateField (null = True , blank = True )
288+ b_approve_date = models .DateField (null = True , blank = True )
289+ comments = models .TextField (blank = True )
290+ last_modified_date = models .DateField ()
291+ def __str__ (self ):
292+ return "RFC%04d" % ( self .rfc_number )
293+ def save (self ):
294+ self .rfc_name_key = self .rfc_name .upper ()
295+ super (Rfc , self ).save ()
296+ def displayname (self ):
297+ return "rfc%d.txt" % ( self .rfc_number )
298+ def doclink (self ):
299+ return "http://www.ietf.org/rfc/%s" % ( self .displayname () )
300+ class Meta :
301+ db_table = 'rfcs'
302+ verbose_name = 'RFC'
303+ verbose_name_plural = 'RFCs'
304+ class Admin :
305+ search_fields = ['rfc_name' , 'group' , 'area' ]
306+ list_display = ['rfc_number' , 'rfc_name' ]
307+ pass
308+
309+ class RfcAuthor (models .Model ):
310+ rfc = models .ForeignKey (Rfc , unique = True , db_column = 'rfc_number' , related_name = 'authors' , edit_inline = models .TABULAR )
311+ person = models .ForeignKey (PersonOrOrgInfo , db_column = 'person_or_org_tag' , raw_id_admin = True , core = True )
312+ def __str__ (self ):
313+ return "%s, %s" % ( self .person .last_name , self .person .first_name )
314+ class Meta :
315+ db_table = 'rfc_authors'
316+ verbose_name = 'RFC Author'
317+
318+ class RfcObsolete (models .Model ):
319+ rfc = models .ForeignKey (Rfc , db_column = 'rfc_number' , raw_id_admin = True , related_name = 'updates_or_obsoletes' )
320+ action = models .CharField (maxlength = 20 , core = True )
321+ rfc_acted_on = models .ForeignKey (Rfc , db_column = 'rfc_acted_on' , raw_id_admin = True , related_name = 'updated_or_obsoleted_by' )
322+ def __str__ (self ):
323+ return "RFC%04d %s RFC%04d" % (self .rfc_id , self .action , self .rfc_acted_on_id )
324+ class Meta :
325+ db_table = 'rfcs_obsolete'
326+ verbose_name = 'RFC updates or obsoletes'
327+ verbose_name_plural = verbose_name
328+ class Admin :
329+ pass
330+
331+ ## End RFC Tables
332+
236333class IDInternal (models .Model ):
334+ """
335+ An IDInternal represents a document that has been added to the
336+ I-D tracker. It can be either an Internet Draft or an RFC.
337+ The table has only a single primary key field, meaning that
338+ there is the danger of RFC number collision with low-numbered
339+ Internet Drafts.
340+
341+ Since it's most common to be an Internet Draft, the draft
342+ field is defined as a FK to InternetDrafts. One side effect
343+ of this is that select_related() will only work with
344+ rfc_flag=0.
345+ """
237346 draft = models .ForeignKey (InternetDraft , primary_key = True , unique = True , db_column = 'id_document_tag' )
238- # the above ignores the possibility that it's an RFC.
239347 rfc_flag = models .IntegerField (null = True )
240348 ballot_id = models .IntegerField ()
241- primary_flag = models .IntegerField (null = True , blank = True )
349+ primary_flag = models .IntegerField ()
242350 group_flag = models .IntegerField (blank = True )
243351 token_name = models .CharField (blank = True , maxlength = 25 )
244352 token_email = models .CharField (blank = True , maxlength = 255 )
@@ -266,9 +374,27 @@ class IDInternal(models.Model):
266374 approved_in_minute = models .IntegerField (null = True , blank = True )
267375 def __str__ (self ):
268376 if self .rfc_flag :
269- return "RFC%04d" % ( self .id_document_tag )
377+ return "RFC%04d" % ( self .draft_id )
378+ else :
379+ return self .draft .filename
380+ def get_absolute_url (self ):
381+ if self .rfc_flag :
382+ return "/idtracker/rfc%d/" % ( self .draft_id )
383+ else :
384+ return "/idtracker/%s/" % ( self .draft .filename )
385+ _cached_rfc = None
386+ def document (self ):
387+ if self .rfc_flag :
388+ if self ._cached_rfc is None :
389+ self ._cached_rfc = Rfc .objects .get (rfc_number = self .draft_id )
390+ return self ._cached_rfc
270391 else :
271- return self .id_document_tag .filename
392+ return self .draft
393+ def comments (self ):
394+ return self .documentcomment_set .all ().filter (rfc_flag = self .rfc_flag ).order_by ('-comment_date' ,'-comment_time' )
395+ def ballot_set (self ):
396+ # can't access manager via self; use the class name
397+ return IDInternal .objects .filter (ballot_id = self .ballot_id )
272398 class Meta :
273399 db_table = 'id_internal'
274400 verbose_name = 'IDTracker Draft'
@@ -301,6 +427,11 @@ def get_author(self):
301427 return self .created_by .__str__ ()
302428 else :
303429 return "system"
430+ def get_username (self ):
431+ if self .created_by :
432+ return self .created_by .login_name
433+ else :
434+ return "system"
304435 class Meta :
305436 db_table = 'document_comments'
306437
0 commit comments