chore: Remove various unused template tags (#4101)
* chore: Remove various unused template tags * Replace rfcnospace with parameterized prettystdname * Use URL resolver * Use the URL resolver more
This commit is contained in:
parent
bbeb9aece7
commit
63d80bff4c
|
@ -6,8 +6,6 @@ import datetime
|
|||
import re
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from email.utils import parseaddr
|
||||
|
||||
from django import template
|
||||
from django.conf import settings
|
||||
from django.utils.html import escape
|
||||
|
@ -47,21 +45,6 @@ def unindent(value):
|
|||
"""Remove indentation from string."""
|
||||
return re.sub("\n +", "\n", value)
|
||||
|
||||
@register.filter
|
||||
def strip_email(value):
|
||||
"""Get rid of email part of name/email string like 'Some Name <email@example.com>'."""
|
||||
if not value:
|
||||
return ""
|
||||
if "@" not in value:
|
||||
return value
|
||||
return parseaddr(value)[0]
|
||||
|
||||
@register.filter(name='fix_angle_quotes')
|
||||
def fix_angle_quotes(value):
|
||||
if "<" in value:
|
||||
value = re.sub(r"<([\w\-\.]+@[\w\-\.]+)>", "<\1>", value)
|
||||
return value
|
||||
|
||||
# there's an "ahref -> a href" in GEN_UTIL
|
||||
# but let's wait until we understand what that's for.
|
||||
@register.filter(name='make_one_per_line')
|
||||
|
@ -142,44 +125,10 @@ def bracketpos(pos,posslug):
|
|||
|
||||
register.filter('fill', fill)
|
||||
|
||||
@register.filter(name='rfcspace')
|
||||
def rfcspace(string):
|
||||
"""
|
||||
If the string is an RFC designation, and doesn't have
|
||||
a space between 'RFC' and the rfc-number, a space is
|
||||
added
|
||||
"""
|
||||
string = str(string)
|
||||
if string[:3].lower() == "rfc" and string[3] != " ":
|
||||
return string[:3].upper() + " " + string[3:]
|
||||
else:
|
||||
return string
|
||||
|
||||
@register.filter(name='rfcnospace')
|
||||
def rfcnospace(string):
|
||||
"""
|
||||
If the string is an RFC designation, and does have
|
||||
a space between 'RFC' and the rfc-number, remove it.
|
||||
"""
|
||||
string = str(string)
|
||||
if string[:3].lower() == "rfc" and string[3] == " ":
|
||||
return string[:3] + string[4:]
|
||||
else:
|
||||
return string
|
||||
|
||||
@register.filter
|
||||
def prettystdname(string):
|
||||
def prettystdname(string, space=" "):
|
||||
from ietf.doc.utils import prettify_std_name
|
||||
return prettify_std_name(force_text(string or ""))
|
||||
|
||||
@register.filter(name='rfcurl')
|
||||
def rfclink(string):
|
||||
"""
|
||||
This takes just the RFC number, and turns it into the
|
||||
URL for that RFC.
|
||||
"""
|
||||
string = str(string);
|
||||
return "https://datatracker.ietf.org/doc/html/rfc" + string;
|
||||
return prettify_std_name(force_text(string or ""), space)
|
||||
|
||||
@register.filter
|
||||
def rfceditor_info_url(rfcnum : str):
|
||||
|
@ -365,11 +314,6 @@ def underline(string):
|
|||
"""Return string with an extra line underneath of dashes, for plain text underlining."""
|
||||
return string + "\n" + ("-" * len(string))
|
||||
|
||||
@register.filter(name='lstrip')
|
||||
def lstripw(string, chars):
|
||||
"""Strip matching leading characters from words in string"""
|
||||
return " ".join([word.lstrip(chars) for word in string.split()])
|
||||
|
||||
@register.filter(name='timesince_days')
|
||||
def timesince_days(date):
|
||||
"""Returns the number of days since 'date' (relative to now)"""
|
||||
|
@ -378,14 +322,6 @@ def timesince_days(date):
|
|||
delta = datetime.datetime.now() - date
|
||||
return delta.days
|
||||
|
||||
@register.filter(name='truncate_ellipsis')
|
||||
def truncate_ellipsis(text, arg):
|
||||
num = int(arg)
|
||||
if len(text) > num:
|
||||
return escape(text[:num-1])+"…"
|
||||
else:
|
||||
return escape(text)
|
||||
|
||||
@register.filter
|
||||
def split(text, splitter=None):
|
||||
return text.split(splitter)
|
||||
|
@ -399,11 +335,6 @@ def compress_empty_lines(text):
|
|||
text = re.sub("( *\n){3,}", "\n\n", text)
|
||||
return text
|
||||
|
||||
@register.filter(name="remove_empty_lines")
|
||||
def remove_empty_lines(text):
|
||||
text = re.sub("( *\n){2,}", "\n", text)
|
||||
return text
|
||||
|
||||
@register.filter(name='linebreaks_crlf')
|
||||
def linebreaks_crlf(text):
|
||||
"""
|
||||
|
@ -634,11 +565,6 @@ def lower_allcaps(text):
|
|||
result = result.replace(token, token.lower())
|
||||
return result
|
||||
|
||||
@register.filter
|
||||
def emailwrap(email):
|
||||
email = str(email)
|
||||
return mark_safe(email.replace('@', '<wbr>@'))
|
||||
|
||||
@register.filter
|
||||
def document_content(doc):
|
||||
if doc is None:
|
||||
|
@ -653,10 +579,6 @@ def format_timedelta(timedelta):
|
|||
minutes, seconds = divmod(remainder, 60)
|
||||
return '{hours:02d}:{minutes:02d}'.format(hours=hours,minutes=minutes)
|
||||
|
||||
@register.filter()
|
||||
def nbsp(value):
|
||||
return mark_safe(" ".join(value.split(' ')))
|
||||
|
||||
@register.filter()
|
||||
def comma_separated_list(seq, end_word="and"):
|
||||
if len(seq) < 2:
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# Copyright The IETF Trust 2020, All Rights Reserved
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Custom tags for the agenda filter template"""
|
||||
|
||||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def agenda_width_scale(filter_categories, spacer_scale):
|
||||
"""Compute the width scale for the agenda filter button table
|
||||
|
||||
Button columns are spacer_scale times as wide as the spacer columns between
|
||||
categories. There is one fewer spacer column than categories.
|
||||
"""
|
||||
category_count = len(filter_categories)
|
||||
column_count = sum([len(cat) for cat in filter_categories])
|
||||
# Refuse to return less than 1 to avoid width calculation problems.
|
||||
return max(spacer_scale * column_count + category_count - 1, 1)
|
|
@ -6593,29 +6593,6 @@ class HasMeetingsTests(TestCase):
|
|||
|
||||
class AgendaFilterTests(TestCase):
|
||||
"""Tests for the AgendaFilter template"""
|
||||
def test_agenda_width_scale_filter(self):
|
||||
"""Test calculation of UI column width by agenda_width_scale filter"""
|
||||
template = Template('{% load agenda_filter_tags %}{{ categories|agenda_width_scale:spacing }}')
|
||||
|
||||
# Should get '1' as min value when input is empty
|
||||
context = Context({'categories': [], 'spacing': 7})
|
||||
self.assertEqual(template.render(context), '1')
|
||||
|
||||
# 3 columns, no spacers
|
||||
context = Context({'categories': [range(3)], 'spacing': 7})
|
||||
self.assertEqual(template.render(context), '21')
|
||||
|
||||
# 6 columns, 1 spacer
|
||||
context = Context({'categories': [range(3), range(3)], 'spacing': 7})
|
||||
self.assertEqual(template.render(context), '43')
|
||||
|
||||
# 10 columns, 2 spacers
|
||||
context = Context({'categories': [range(3), range(3), range(4)], 'spacing': 7})
|
||||
self.assertEqual(template.render(context), '72')
|
||||
|
||||
# 10 columns, 2 spacers, different spacer scale
|
||||
context = Context({'categories': [range(3), range(3), range(4)], 'spacing': 5})
|
||||
self.assertEqual(template.render(context), '52')
|
||||
|
||||
def test_agenda_filter_template(self):
|
||||
"""Test rendering of input data by the agenda filter template"""
|
||||
|
|
|
@ -284,7 +284,7 @@ $ curl -S -F "apikey=DgAAAMLSi3coaE5TjrRs518xO8eBRlCmFF3eQcC8_SjUTtRGLGiJh7-1SYP
|
|||
<p>
|
||||
When sending notifications to other APIs, the datatracker may sign
|
||||
information with a
|
||||
<a href="https://datatracker.ietf.org/doc/html/rfc7515">
|
||||
<a href="{% url 'ietf.doc.views_doc.document_html' name='rfc7515' %}">
|
||||
RFC
|
||||
7515: JSON Web Signature (JWS)
|
||||
</a>,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{% origin %}
|
||||
<h1>Personal Information in the Datatracker</h1>
|
||||
<p>
|
||||
<a href="https://datatracker.ietf.org/doc/html/rfc3935">RFC 3935, "A Mission Statement for the IETF"</a>
|
||||
<a href="{% url 'ietf.doc.views_doc.document_html' name='rfc3935' %}">RFC 3935, "A Mission Statement for the IETF"</a>
|
||||
lays out
|
||||
the goal and the mission of the IETF as follows
|
||||
</p>
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<tbody>
|
||||
<tr>
|
||||
<th scope="col" class="table-info" colspan="3">
|
||||
Results for {{ doc.name|rfcspace|lstrip:"0"|urlize_ietf_docs }} ("{{ doc.document.title }}"){% if not forloop.first %}{% if doc.related %}, which was {{ doc.relation|lower }} {{ doc.related.source|rfcspace|lstrip:"0"|urlize_ietf_docs }} ("{{ doc.related.source.title }}"){% endif %}{% endif %}
|
||||
Results for {{ doc.name|prettystdname|urlize_ietf_docs }} ("{{ doc.document.title }}"){% if not forloop.first %}{% if doc.related %}, which was {{ doc.relation|lower }} {{ doc.related.source|prettystdname|urlize_ietf_docs }} ("{{ doc.related.source.title }}"){% endif %}{% endif %}
|
||||
</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -81,7 +81,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td>
|
||||
No IPR disclosures have been submitted directly on {{ doc.name|rfcspace|lstrip:"0"|urlize_ietf_docs }}{% if iprs %},
|
||||
No IPR disclosures have been submitted directly on {{ doc.name|prettystdname|urlize_ietf_docs }}{% if iprs %},
|
||||
but there are disclosures on {% if docs|length == 2 %}a related document{% else %}related documents{% endif %}, listed on this page{% endif %}.
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -122,4 +122,4 @@
|
|||
|
||||
{% block js %}
|
||||
<script src="{% static "ietf/js/list.js" %}"></script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
|
@ -28,9 +28,9 @@
|
|||
<tbody>
|
||||
<tr>
|
||||
<th scope="col" class="table-info" colspan="3">
|
||||
IPR that is related to {{ alias.name|lstrip:"0"|rfcnospace|urlize_ietf_docs }} ("{{ alias.document.title }}")
|
||||
IPR that is related to {{ alias.name|prettystdname:""|urlize_ietf_docs }} ("{{ alias.document.title }}")
|
||||
{% if alias.related %}
|
||||
that was {{ alias.relation|lower }} {{ alias.related.source.name|lstrip:"0"|rfcnospace|urlize_ietf_docs }} ("{{ alias.related.source.title }}")
|
||||
that was {{ alias.relation|lower }} {{ alias.related.source.name|prettystdname:""|urlize_ietf_docs }} ("{{ alias.related.source.title }}")
|
||||
{% endif %}
|
||||
</th>
|
||||
</tr>
|
||||
|
@ -58,7 +58,7 @@
|
|||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>No IPR disclosures related to {{ alias.name|lstrip:"0"|urlize_ietf_docs }} have been submitted.</td>
|
||||
<td>No IPR disclosures related to {{ alias.name|prettystdname|urlize_ietf_docs }} have been submitted.</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
|
@ -68,4 +68,4 @@
|
|||
{% endblock %}
|
||||
{% block js %}
|
||||
<script src="{% static "ietf/js/list.js" %}"></script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
|
@ -24,9 +24,9 @@
|
|||
<tbody>
|
||||
<tr class="table-info">
|
||||
<th scope="col" colspan="3">
|
||||
IPR related to {{ alias.name|rfcspace|lstrip:"0"|urlize_ietf_docs }} ("{{ alias.document.title }}")
|
||||
IPR related to {{ alias.name|prettystdname|urlize_ietf_docs }} ("{{ alias.document.title }}")
|
||||
{% if alias.related %}
|
||||
that was {{ alias.relation|lower }} {{ alias.related.source|rfcspace|lstrip:"0"|urlize_ietf_docs }} ("{{ alias.related.source.title|escape }}")
|
||||
that was {{ alias.relation|lower }} {{ alias.related.source|prettystdname|urlize_ietf_docs }} ("{{ alias.related.source.title|escape }}")
|
||||
{% endif %}
|
||||
{% if alias.product_of_this_wg %}, a product of the {{ q }} WG{% endif %}
|
||||
:
|
||||
|
@ -57,7 +57,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td>
|
||||
No IPR disclosures related to <i>{{ alias.name|rfcspace|lstrip:"0" }}</i> have been submitted.
|
||||
No IPR disclosures related to <i>{{ alias.name|prettystdname|urlize_ietf_docs }}</i> have been submitted.
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
@ -68,4 +68,4 @@
|
|||
{% endblock %}
|
||||
{% block js %}
|
||||
<script src="{% static "ietf/js/list.js" %}"></script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
|
@ -34,7 +34,7 @@
|
|||
<p>
|
||||
For definitive information on generating liaison statements, please
|
||||
see
|
||||
<a href="{{ "4053"|rfcurl }}">RFC 4053 (BCP 103) "Procedures for Handling Liaison Statements to and from the IETF."</a>
|
||||
<a href="{% url 'ietf.doc.views_doc.document_html' name='rfc4053' %}">RFC 4053 (BCP 103) "Procedures for Handling Liaison Statements to and from the IETF."</a>
|
||||
</p>
|
||||
<table class="table table-sm table-striped tablesorter">
|
||||
<thead>
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ "4052"|rfcurl }}">RFC 4052 (BCP 102), "IAB Processes for Management of IETF Liaison Relationships"</a>
|
||||
<a href="{% url 'ietf.doc.views_doc.document_html' name='rfc4052' %}">RFC 4052 (BCP 102), "IAB Processes for Management of IETF Liaison Relationships"</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ "4053"|rfcurl }}">RFC 4053 (BCP 103), "Procedures for Handling Liaison Statements to and from the IETF"</a>
|
||||
<a href="{% url 'ietf.doc.views_doc.document_html' name='rfc4053' %}">RFC 4053 (BCP 103), "Procedures for Handling Liaison Statements to and from the IETF"</a>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="table table-sm table-striped tablesorter">
|
||||
|
@ -114,7 +114,7 @@
|
|||
<p>
|
||||
<sup><small>(1)</small></sup> Please see Section 4., "Approval and Transmission of Liaison Statements,"
|
||||
of
|
||||
<a href="{{ "4052"|rfcurl }}">
|
||||
<a href="{% url 'ietf.doc.views_doc.document_html' name='rfc4052' %}">
|
||||
RFC 4052
|
||||
</a>
|
||||
for information on who may submit a liaison statement on behalf of an IETF entity, and who should be copied.
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<p>
|
||||
For definitive information on generating liaison statements, please
|
||||
see
|
||||
<a href="{{ "4053"|rfcurl }}">RFC 4053 (BCP 103) "Procedures for Handling Liaison Statements to and from the IETF."</a>
|
||||
<a href="{% url 'ietf.doc.views_doc.document_html' name='rfc4053' %}">RFC 4053 (BCP 103) "Procedures for Handling Liaison Statements to and from the IETF."</a>
|
||||
</p>
|
||||
<table class="table table-sm table-striped tablesorter">
|
||||
<thead>
|
||||
|
|
|
@ -6,7 +6,6 @@ Optional parameters:
|
|||
always_show - if False or absent, menu closes when not in use and "Customize" button is shown
|
||||
customize_button_text - text to show on the "Customize" button (defaults to "Customize...")
|
||||
{% endcomment %}
|
||||
{% load agenda_filter_tags %}
|
||||
<div class="accordion mb-3" id="accordion">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="heading">
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
{% for rfc in rfcs %}
|
||||
<tr>
|
||||
<td class="text-nowrap">
|
||||
<a href="{{ rfc.doc.get_absolute_url }}">{{ rfc.doc.canonical_name|rfcspace|upper }}</a>
|
||||
<a href="{{ rfc.doc.get_absolute_url }}">{{ rfc.doc.canonical_name|prettystdname }}</a>
|
||||
</td>
|
||||
<td class="text-nowrap">{{ rfc.doc.intended_std_level.name }}</td>
|
||||
<td>
|
||||
|
|
|
@ -52,15 +52,15 @@
|
|||
<h2 class="mt-5" id="references">References</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://datatracker.ietf.org/doc/rfc2026/">The Internet Standards Process (RFC 2026)</a>
|
||||
<a href="{% url 'ietf.doc.views_doc.document_main' name='rfc2026' %}">The Internet Standards Process (RFC 2026)</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://datatracker.ietf.org/doc/rfc8713/">
|
||||
<a href="{% url 'ietf.doc.views_doc.document_main' name='rfc8713' %}">
|
||||
IAB, IESG, IETF Trust, and IETF LLC Selection, Confirmation, and Recall Process: Operation of the IETF Nominating and Recall Committees (RFC 8713) (Also BCP10)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://datatracker.ietf.org/doc/rfc3797/">
|
||||
<a href="{% url 'ietf.doc.views_doc.document_main' name='rfc3797' %}">
|
||||
Publicly Verifiable Nominations Committee (NomCom) Random Selection (RFC 3797)
|
||||
</a>
|
||||
</li>
|
||||
|
@ -68,4 +68,4 @@
|
|||
{% endblock %}
|
||||
{% block js %}
|
||||
<script src="{% static "ietf/js/list.js" %}"></script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
|
@ -101,7 +101,7 @@
|
|||
<td>
|
||||
<a class="text-nowrap" href="{{ doc.get_absolute_url }}">RFC {{ doc.rfc_number }}</a>
|
||||
</td>
|
||||
<td>{{ doc.pub_date|date:"b Y"|title|nbsp }}</td>
|
||||
<td>{{ doc.pub_date|date:"b Y"|title }}</td>
|
||||
<td>{{ doc.title|urlize_ietf_docs }}</td>
|
||||
<td class="text-end">
|
||||
{% with doc.referenced_by_rfcs.count as refbycount %}
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
will require additional consideration by the stream manager (for example, the
|
||||
IESG), and publication may be declined unless sufficient justification is
|
||||
provided. See
|
||||
<a href="https://datatracker.ietf.org/doc/html/rfc7322#section-4.1.1">RFC 7322, section 4.1.1</a>
|
||||
<a href="{% url 'ietf.doc.views_doc.document_html' name='rfc7322' %}">RFC 7322, section 4.1.1</a>
|
||||
for details.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
@ -598,4 +598,4 @@
|
|||
{{ all_forms|merge_media:'js' }}
|
||||
<script src="{% static "ietf/js/list.js" %}"></script>
|
||||
<script src="{% static "ietf/js/draft-submit.js" %}"></script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
Loading…
Reference in a new issue