Skip to content

Commit 70890fb

Browse files
committed
WG/RG chairs and secretaries can add comments to document history; get non-active I-Ds from www.ietf.org instead of tools.ietf.org; fixes 1702, 1801, 1831; Commit ready for merge
- Legacy-Id: 10341
1 parent 0b829e6 commit 70890fb

3 files changed

Lines changed: 26 additions & 11 deletions

File tree

ietf/doc/views_doc.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def document_main(request, name, rev=None):
158158
person__user=request.user)))
159159
can_edit_iana_state = has_role(request.user, ("Secretariat", "IANA"))
160160

161-
can_edit_replaces = has_role(request.user, ("Area Director", "Secretariat", "WG Chair", "RG Chair", "WG Secretary", "RG Secretary"))
161+
can_edit_replaces = has_role(request.user, ("Area Director", "Secretariat", "IRTF Chair", "WG Chair", "RG Chair", "WG Secretary", "RG Secretary"))
162162

163163
is_author = unicode(request.user) in set([email.address for email in doc.authors.all()])
164164
can_view_possibly_replaces = can_edit_replaces or is_author
@@ -197,7 +197,7 @@ def document_main(request, name, rev=None):
197197
file_urls.append(("pdf", base + "pdfrfc/" + name + ".txt.pdf"))
198198

199199
if "txt" in found_types:
200-
file_urls.append(("html", "https://tools.ietf.org/html/" + name))
200+
file_urls.append(("html", settings.TOOLS_ID_HTML_URL + name))
201201

202202
if not found_types:
203203
content = "This RFC is not currently available online."
@@ -216,21 +216,19 @@ def document_main(request, name, rev=None):
216216
possible_types = ["pdf", "xml", "ps"]
217217
found_types = ["txt"] + [t for t in possible_types if os.path.exists(base_path + t)]
218218

219-
tools_base = "https://tools.ietf.org/"
220-
221219
if doc.get_state_slug() == "active":
222-
base = "https://www.ietf.org/id/"
220+
base = settings.IETF_ID_URL
223221
else:
224-
base = tools_base + "id/"
222+
base = settings.IETF_ID_ARCHIVE_URL
225223

226224
file_urls = []
227225
for t in found_types:
228226
label = "plain text" if t == "txt" else t
229227
file_urls.append((label, base + doc.name + "-" + doc.rev + "." + t))
230228

231229
if "pdf" not in found_types:
232-
file_urls.append(("pdf", tools_base + "pdf/" + doc.name + "-" + doc.rev + ".pdf"))
233-
file_urls.append(("html", tools_base + "html/" + doc.name + "-" + doc.rev))
230+
file_urls.append(("pdf", settings.TOOLS_ID_PDF_URL + doc.name + "-" + doc.rev + ".pdf"))
231+
file_urls.append(("html", settings.TOOLS_ID_HTML_URL + doc.name + "-" + doc.rev))
234232

235233
# latest revision
236234
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
@@ -648,11 +646,22 @@ def document_history(request, name):
648646
augment_events_with_revision(doc, events)
649647
add_links_in_new_revision_events(doc, events, diff_revisions)
650648

649+
# figure out if the current user can add a comment to the history
650+
if doc.type_id == "draft" and doc.group != None:
651+
can_add_comment = bool(has_role(request.user, ("Area Director", "Secretariat", "IRTF Chair", "IANA", "RFC Editor")) or (
652+
request.user.is_authenticated() and
653+
Role.objects.filter(name__in=("chair", "secr"),
654+
group__acronym=doc.group.acronym,
655+
person__user=request.user)))
656+
else:
657+
can_add_comment = has_role(request.user, ("Area Director", "Secretariat", "IRTF Chair"))
658+
651659
return render_to_response("doc/document_history.html",
652660
dict(doc=doc,
653661
top=top,
654662
diff_revisions=diff_revisions,
655663
events=events,
664+
can_add_comment=can_add_comment,
656665
),
657666
context_instance=RequestContext(request))
658667

@@ -889,7 +898,7 @@ def extract_name(s):
889898
class AddCommentForm(forms.Form):
890899
comment = forms.CharField(required=True, widget=forms.Textarea)
891900

892-
@role_required('Area Director', 'Secretariat', 'IANA', 'RFC Editor')
901+
@role_required('Area Director', 'Secretariat', 'IRTF Chair', 'WG Chair', 'RG Chair', 'WG Secretary', 'RG Secretary', 'IANA', 'RFC Editor')
893902
def add_comment(request, name):
894903
"""Add comment to history of document."""
895904
doc = get_object_or_404(Document, docalias__name=name)

ietf/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747

4848
# Server name of the tools server
4949
TOOLS_SERVER = 'tools.' + IETF_DOMAIN
50+
TOOLS_SERVER_URL = 'https://' + TOOLS_SERVER
51+
TOOLS_ID_PDF_URL = TOOLS_SERVER_URL + '/pdf/'
52+
TOOLS_ID_HTML_URL = TOOLS_SERVER_URL + '/html/'
5053

5154
# Override this in the settings_local.py file:
5255
SERVER_EMAIL = 'Django Server <django-project@' + TOOLS_SERVER + '>'
@@ -97,6 +100,9 @@
97100
USE_TZ = False
98101

99102
MEDIA_URL = 'https://www.ietf.org/'
103+
IETF_ID_URL = MEDIA_URL + 'id/'
104+
IETF_ID_ARCHIVE_URL = MEDIA_URL + 'archive/id/'
105+
100106

101107
# Absolute path to the directory static files should be collected to.
102108
# Example: "/var/www/example.com/static/"

ietf/templates/doc/document_history.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ <h2>Revision differences</h2>
8282
{% endif %}
8383

8484
<h2>Document history</h2>
85-
{% if user|has_role:"Area Director,Secretariat,IANA,RFC Editor" %}
86-
<div class="buttonlist">
85+
{% if can_add_comment %}
86+
<div class="buttonlist">
8787
<a class="btn btn-default" href="{% url "doc_add_comment" name=doc.name %}"><span class="fa fa-plus"></span> Add comment</a>
8888
</div>
8989
{% endif %}

0 commit comments

Comments
 (0)