11# Copyright The IETF Trust 2007, All Rights Reserved
22
3+ from django .conf import settings
34from django .db import models
45from ietf .utils import FKAsOneToOne
56from django .test import TestCase
@@ -117,6 +118,7 @@ class Admin:
117118 pass
118119
119120class InternetDraft (models .Model ):
121+ DAYS_TO_EXPIRE = 185
120122 id_document_tag = models .AutoField (primary_key = True )
121123 title = models .CharField (maxlength = 255 , db_column = 'id_document_name' )
122124 id_document_key = models .CharField (maxlength = 255 , editable = False )
@@ -153,9 +155,19 @@ def save(self):
153155 self .id_document_key = self .title .upper ()
154156 super (InternetDraft , self ).save ()
155157 def displayname (self ):
156- return "%s-%s.txt" % ( self .filename , self .revision_display () )
158+ if self .status .status == "Replaced" :
159+ css = "replaced"
160+ else :
161+ css = "active"
162+ return '<span class="' + css + '">' + self .filename + '</span>'
163+ def displayname_with_link (self ):
164+ if self .status .status == "Replaced" :
165+ css = "replaced"
166+ else :
167+ css = "active"
168+ return '<a class="' + css + '" href="%s">%s</a>' % ( self .doclink (), self .filename )
157169 def doclink (self ):
158- return "http://www.ietf.org/internet-drafts /%s" % ( self .displayname () )
170+ return "http://" + settings . TOOLS_SERVER + "/html /%s" % ( self .filename )
159171 def group_acronym (self ):
160172 return self .group .acronym
161173 def __str__ (self ):
@@ -176,12 +188,26 @@ def doctype(self):
176188 def filename_with_link (self , text = None ):
177189 if text is None :
178190 text = self .filename
179- if self .status .status != 'Active' :
180- return text
181- else :
182- return '<a href="%s">%s</a>' % ( self .doclink (), text )
183- def displayname_with_link (self ):
184- return self .filename_with_link (self .displayname ())
191+ return '<a href="%s">%s</a>' % ( self .doclink (), text )
192+ def expiration (self ):
193+ return self .revision_date + datetime .timedelta (self .DAYS_TO_EXPIRE )
194+ def can_expire (self ):
195+ # Copying the logic from expire-ids-1 without thinking
196+ # much about it.
197+ if self .review_by_rfc_editor :
198+ return False
199+ idinternal = self .idinternal
200+ if idinternal :
201+ cur_state_id = idinternal .cur_state_id
202+ # 42 is "AD is Watching"; this matches what's in the
203+ # expire-ids-1 perl script.
204+ # A better way might be to add a column to the table
205+ # saying whether or not a document is prevented from
206+ # expiring.
207+ if cur_state_id < 42 :
208+ return False
209+ return True
210+
185211 class Meta :
186212 db_table = "internet_drafts"
187213 class Admin :
@@ -364,7 +390,7 @@ def revision(self):
364390 def revision_display (self ):
365391 return "RFC"
366392 def doclink (self ):
367- return "http://www.ietf.org/rfc /%s" % ( self .displayname () )
393+ return "http://" + settings . TOOLS_SERVER + "/html /%s" % ( self .displayname () )
368394 def doctype (self ):
369395 return "RFC"
370396 def filename_with_link (self ):
@@ -581,12 +607,17 @@ def get_author(self):
581607 if self .created_by_id and self .created_by_id != 999 :
582608 return self .created_by .__str__ ()
583609 else :
584- return "system "
610+ return "(System) "
585611 def get_username (self ):
586612 if self .created_by_id and self .created_by_id != 999 :
587613 return self .created_by .login_name
588614 else :
589- return "system"
615+ return "(System)"
616+ def get_fullname (self ):
617+ if self .created_by_id and self .created_by_id != 999 :
618+ return self .created_by .first_name + " " + self .created_by .last_name
619+ else :
620+ return "(System)"
590621 def datetime (self ):
591622 # this is just a straightforward combination, except that the time is
592623 # stored incorrectly in the database.
0 commit comments