-
Notifications
You must be signed in to change notification settings - Fork 758
fix: Document type badges #7760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2bdf409
fix: document type badge#7475
holloway 5d64c28
chore: PR feedback (naming)
holloway 16b6396
chore: merging main, resolving conflict document_html.html
holloway a357972
Merge branch 'main' into fix/doc-type-badge
rjsparks 1c3fd00
fix: use type_id rather than str(type) for conditionals in templatetag
rjsparks f501dfc
fix: remove debugging CSS inline style dashed border
holloway 75243b2
Merge branch 'fix/doc-type-badge' of gh-ietf:holloway/datatracker int…
holloway 9e4a1ba
Merge branch 'main' into fix/doc-type-badge
holloway 6b351a4
Merge branch 'main' into fix/doc-type-badge
holloway 60a412c
fix: document type badge template tag passing context variables
holloway 8533d1b
fix: context vars to document_type_badge
holloway 7836862
Merge branch 'main' into fix/doc-type-badge
holloway 8e3253f
fix: badge error logging
holloway 42f3fa2
Merge branch 'fix/doc-type-badge' of gh-ietf:holloway/datatracker int…
holloway File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.