-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: document type badge#7475 * chore: PR feedback (naming) * fix: use type_id rather than str(type) for conditionals in templatetag * fix: remove debugging CSS inline style dashed border * fix: document type badge template tag passing context variables * fix: context vars to document_type_badge * fix: badge error logging --------- Co-authored-by: Robert Sparks <[email protected]>
- Loading branch information
Showing
6 changed files
with
68 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright The IETF Trust 2015-2020, All Rights Reserved | ||
from django import template | ||
from django.conf import settings | ||
from django.template.loader import render_to_string | ||
from ietf.utils.log import log | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def document_type_badge(doc, snapshot, submission, resurrected_by): | ||
context = {"doc": doc, "snapshot": snapshot, "submission": submission, "resurrected_by": resurrected_by} | ||
if doc.type_id == "rfc": | ||
return render_to_string( | ||
"doc/badge/doc-badge-rfc.html", | ||
context, | ||
) | ||
elif doc.type_id == "draft": | ||
return render_to_string( | ||
"doc/badge/doc-badge-draft.html", | ||
context, | ||
) | ||
else: | ||
error_message = f"Unsupported document type {doc.type_id}." | ||
if settings.SERVER_MODE != 'production': | ||
raise ValueError(error_message) | ||
else: | ||
log(error_message) | ||
return "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% load origin %} | ||
{% load static %} | ||
{% load ietf_filters %} | ||
{% load person_filters %} | ||
{% origin %} | ||
{# Non-RFC #} | ||
|
||
{% if doc.became_rfc %} | ||
<div{% if document_html %} class="alert alert-warning small"{% endif %}>This is an older version of an Internet-Draft that was ultimately published as <a href="{% if document_html %}{% url 'ietf.doc.views_doc.document_html' name=doc.became_rfc.name %}{% else %}{% url 'ietf.doc.views_doc.document_main' name=doc.became_rfc.name %}{% endif %}">{{doc.became_rfc.name|prettystdname}}</a>.</div> | ||
{% elif snapshot and doc.rev != latest_rev %} | ||
<div{% if document_html %} class="alert alert-warning small p-2 mt-2"{% endif %}>This is an older version of an Internet-Draft whose latest revision state is "{{ doc.doc.get_state }}".</div> | ||
{% else %} | ||
<span class="{% if doc.get_state_slug == 'active' %}text-success{% elif doc.get_state_slug == 'expired' or doc.get_state_slug == 'repl' %}text-danger{% endif %}">{% if snapshot and doc.rev == latest_rev %}{{ doc.doc.get_state }}{% else %}{{ doc.get_state }}{% endif %} Internet-Draft</span> | ||
{% if submission %}({{ submission|safe }}){% endif %} | ||
{% if resurrected_by %}- resurrect requested by {{ resurrected_by }}{% endif %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% load origin %} | ||
{% load static %} | ||
{% load ietf_filters %} | ||
{% load person_filters %} | ||
{% origin %} | ||
|
||
<span class="text-success">RFC | ||
{% if not document_html %} | ||
- {{ doc.std_level }} | ||
{% else %} | ||
<span class="badge rounded-pill badge-{% if not snapshot %}{{ doc|std_level_to_label_format }}{% else %}generic{% endif %}">{{ doc.std_level }}</span> | ||
{% endif %} | ||
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters