feat: Link rfc/draft document history pages (#5894)

* fix: Do not show "rev" column for rfc document history

* style: Reformat document_history() using Black

* refactor: Use "is not None" instead of "!= None"

* refactor: Convert dict() to dict literal

* fix: Migrate group, stream, and ad from draft to rfc Document

* feat: Link rfc/draft history pages
This commit is contained in:
Jennifer Richards 2023-06-28 17:51:31 -03:00 committed by GitHub
parent bff145f975
commit 771296bbe6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 18 deletions

View file

@ -41,10 +41,13 @@ def forward(apps, schema_editor):
name=rfc_alias.name,
rfc_number=int(rfc_alias.name[3:]),
title=draft.title,
stream=draft.stream,
group=draft.group,
abstract=draft.abstract,
pages=draft.pages,
words=draft.words,
std_level=draft.std_level,
ad=draft.ad,
external_url=draft.external_url,
uploaded_filename=draft.uploaded_filename,
note=draft.note,

View file

@ -1028,21 +1028,46 @@ def document_history(request, name):
add_events_message_info(events)
# figure out if the current user can add a comment to the history
if doc.type_id == "draft" and doc.group != None:
can_add_comment = bool(has_role(request.user, ("Area Director", "Secretariat", "IRTF Chair", "IANA", "RFC Editor")) or (
request.user.is_authenticated and
Role.objects.filter(name__in=("chair", "secr"),
group__acronym=doc.group.acronym,
person__user=request.user)))
if doc.type_id in ("draft", "rfc") and doc.group is not None:
can_add_comment = bool(
has_role(
request.user,
("Area Director", "Secretariat", "IRTF Chair", "IANA", "RFC Editor"),
)
or (
request.user.is_authenticated
and Role.objects.filter(
name__in=("chair", "secr"),
group__acronym=doc.group.acronym,
person__user=request.user,
)
)
)
else:
can_add_comment = has_role(request.user, ("Area Director", "Secretariat", "IRTF Chair"))
return render(request, "doc/document_history.html",
dict(doc=doc,
top=top,
diff_revisions=diff_revisions,
events=events,
can_add_comment=can_add_comment,
))
can_add_comment = has_role(
request.user, ("Area Director", "Secretariat", "IRTF Chair")
)
# Get related docs whose history should be linked
if doc.type_id == "draft":
related = doc.related_that_doc("became-rfc")
elif doc.type_id == "rfc":
related = doc.related_that("became-rfc")
else:
related = []
return render(
request,
"doc/document_history.html",
{
"doc": doc,
"top": top,
"diff_revisions": diff_revisions,
"events": events,
"related": related,
"can_add_comment": can_add_comment,
},
)
def document_bibtex(request, name, rev=None):

View file

@ -11,7 +11,7 @@
<link rel="alternate"
type="application/atom+xml"
href="/feed/document-changes/{{ doc.name }}/">
<link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
<link rel="stylesheet" href="{% static 'ietf/css/list.css' %}">
{% endblock %}
{% block content %}
{% origin %}
@ -20,7 +20,17 @@
<h2 class="my-3">Revision differences</h2>
{% include "doc/document_history_form.html" with doc=doc diff_revisions=diff_revisions action=rfcdiff_base_url snapshot=snapshot only %}
{% endif %}
<h2 class="my-3">Document history</h2>
<h2 class="my-3">Document history
{% if related %}
<div class="float-end">
{% for related_docalias in related %}
<a class="btn btn-outline-primary btn-sm"
href="{% url 'ietf.doc.views_doc.document_history' name=related_docalias.name %}">
Related history for {{ related_docalias.name }}
</a>
{% endfor %}
</div>
{% endif %}</h2>
{% if can_add_comment %}
<div class="buttonlist">
<a class="btn btn-primary"
@ -34,7 +44,7 @@
<thead>
<tr>
<th scope="col" data-sort="date">Date</th>
<th scope="col" data-sort="rev">Rev.</th>
{% if doc.type_id != "rfc" %}<th scope="col" data-sort="rev">Rev.</th>{% endif %}
<th scope="col" data-sort="by">By</th>
<th scope="col" data-sort="action">Action</th>
</tr>
@ -45,7 +55,7 @@
<td>
<div title="{{ e.time|date:'Y-m-d H:i:s O' }}">{{ e.time|date:"Y-m-d" }}</div>
</td>
<td class="text-end">{{ e.rev }}</td>
{% if doc.type_id != "rfc" %}<td class="text-end">{{ e.rev }}</td>{% endif %}
<td>{{ e.by|escape }}</td>
<td>{{ e.desc|format_history_text }}</td>
</tr>