Skip to content

Commit

Permalink
feat: Link rfc/draft document history pages (#5894)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jennifer-richards authored Jun 28, 2023
1 parent bff145f commit 771296b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 18 deletions.
3 changes: 3 additions & 0 deletions ietf/doc/migrations/0007_create_rfc_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
53 changes: 39 additions & 14 deletions ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 14 additions & 4 deletions ietf/templates/doc/document_history.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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"
Expand All @@ -34,7 +44,7 @@ <h2 class="my-3">Document history</h2>
<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>
Expand All @@ -45,7 +55,7 @@ <h2 class="my-3">Document history</h2>
<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>
Expand Down

0 comments on commit 771296b

Please sign in to comment.