Skip to content

Commit 09c0829

Browse files
committed
Use the "M, j" format for last call end date too.
Add the year to the date field when it's not this year, using a new template tag "thisyear" which returns a boolean. Also implement template tag "inpast" which I think could be useful for the meeting materials page. - Legacy-Id: 599
1 parent c454d56 commit 09c0829

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

ietf/idtracker/templatetags/ietf_filters.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
except ImportError:
88
from email import Utils as emailutils
99
import re
10+
import datetime
1011
#from ietf.utils import log
1112

1213
register = template.Library()
@@ -155,3 +156,17 @@ def rfcnospace(string):
155156
def lstripw(string, chars):
156157
"""Strip matching leading characters from words in string"""
157158
return " ".join([word.lstrip(chars) for word in string.split()])
159+
160+
@register.filter(name='thisyear')
161+
def thisyear(date):
162+
"""Returns a boolean of whether or not the argument is this year."""
163+
if date:
164+
return date.year == datetime.date.today().year
165+
return True
166+
167+
@register.filter(name='inpast')
168+
def inpast(date):
169+
"""Returns a boolean of whether or not the argument is in the past."""
170+
if date:
171+
return date < datetime.datetime.now()
172+
return True

ietf/templates/idtracker/document_entry.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<td nowrap>
55
{% ifequal doc.cur_state.state "In Last Call" %}
66
{% if doc.document.lc_expiration_date %}
7-
{{ doc.document.lc_expiration_date }}
7+
{{ doc.document.lc_expiration_date|date:"M j" }}{% if not doc.lc_expiration_date|thisyear %}, {{ doc.lc_expiration_date|date:"Y" }}{% endif %}
88
{% endif %}
99
{% else %}
1010
{% if doc.status_date %}
11-
{{ doc.status_date|date:"M j" }}
11+
{{ doc.status_date|date:"M j" }}{% if not doc.status_date|thisyear %}, {{ doc.status_date|date:"Y" }}{% endif %}
1212
{% endif %}
1313
{% endifequal %}</td>
1414
{% else %}

0 commit comments

Comments
 (0)