Merged in [10341] from housley@vigilsec.com:

Fixes issues #1702, #1801, #1831.

    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;
 - Legacy-Id: 10354
Note: SVN reference [10341] has been migrated to Git commit 70890fb4c0
This commit is contained in:
Henrik Levkowetz 2015-10-31 23:26:29 +00:00
commit 92e0178a9a
3 changed files with 26 additions and 11 deletions

View file

@ -158,7 +158,7 @@ def document_main(request, name, rev=None):
person__user=request.user)))
can_edit_iana_state = has_role(request.user, ("Secretariat", "IANA"))
can_edit_replaces = has_role(request.user, ("Area Director", "Secretariat", "WG Chair", "RG Chair", "WG Secretary", "RG Secretary"))
can_edit_replaces = has_role(request.user, ("Area Director", "Secretariat", "IRTF Chair", "WG Chair", "RG Chair", "WG Secretary", "RG Secretary"))
is_author = unicode(request.user) in set([email.address for email in doc.authors.all()])
can_view_possibly_replaces = can_edit_replaces or is_author
@ -197,7 +197,7 @@ def document_main(request, name, rev=None):
file_urls.append(("pdf", base + "pdfrfc/" + name + ".txt.pdf"))
if "txt" in found_types:
file_urls.append(("html", "https://tools.ietf.org/html/" + name))
file_urls.append(("html", settings.TOOLS_ID_HTML_URL + name))
if not found_types:
content = "This RFC is not currently available online."
@ -216,12 +216,10 @@ def document_main(request, name, rev=None):
possible_types = ["pdf", "xml", "ps"]
found_types = ["txt"] + [t for t in possible_types if os.path.exists(base_path + t)]
tools_base = "https://tools.ietf.org/"
if doc.get_state_slug() == "active":
base = "https://www.ietf.org/id/"
base = settings.IETF_ID_URL
else:
base = tools_base + "id/"
base = settings.IETF_ID_ARCHIVE_URL
file_urls = []
for t in found_types:
@ -229,8 +227,8 @@ def document_main(request, name, rev=None):
file_urls.append((label, base + doc.name + "-" + doc.rev + "." + t))
if "pdf" not in found_types:
file_urls.append(("pdf", tools_base + "pdf/" + doc.name + "-" + doc.rev + ".pdf"))
file_urls.append(("html", tools_base + "html/" + doc.name + "-" + doc.rev))
file_urls.append(("pdf", settings.TOOLS_ID_PDF_URL + doc.name + "-" + doc.rev + ".pdf"))
file_urls.append(("html", settings.TOOLS_ID_HTML_URL + doc.name + "-" + doc.rev))
# latest revision
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
@ -648,11 +646,22 @@ def document_history(request, name):
augment_events_with_revision(doc, events)
add_links_in_new_revision_events(doc, events, diff_revisions)
# 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)))
else:
can_add_comment = has_role(request.user, ("Area Director", "Secretariat", "IRTF Chair"))
return render_to_response("doc/document_history.html",
dict(doc=doc,
top=top,
diff_revisions=diff_revisions,
events=events,
can_add_comment=can_add_comment,
),
context_instance=RequestContext(request))
@ -889,7 +898,7 @@ def document_json(request, name):
class AddCommentForm(forms.Form):
comment = forms.CharField(required=True, widget=forms.Textarea)
@role_required('Area Director', 'Secretariat', 'IANA', 'RFC Editor')
@role_required('Area Director', 'Secretariat', 'IRTF Chair', 'WG Chair', 'RG Chair', 'WG Secretary', 'RG Secretary', 'IANA', 'RFC Editor')
def add_comment(request, name):
"""Add comment to history of document."""
doc = get_object_or_404(Document, docalias__name=name)

View file

@ -47,6 +47,9 @@ ALLOWED_HOSTS = [".ietf.org", ".ietf.org.", "209.208.19.216", "4.31.198.44", ]
# Server name of the tools server
TOOLS_SERVER = 'tools.' + IETF_DOMAIN
TOOLS_SERVER_URL = 'https://' + TOOLS_SERVER
TOOLS_ID_PDF_URL = TOOLS_SERVER_URL + '/pdf/'
TOOLS_ID_HTML_URL = TOOLS_SERVER_URL + '/html/'
# Override this in the settings_local.py file:
SERVER_EMAIL = 'Django Server <django-project@' + TOOLS_SERVER + '>'
@ -97,6 +100,9 @@ USE_I18N = False
USE_TZ = False
MEDIA_URL = 'https://www.ietf.org/'
IETF_ID_URL = MEDIA_URL + 'id/'
IETF_ID_ARCHIVE_URL = MEDIA_URL + 'archive/id/'
# Absolute path to the directory static files should be collected to.
# Example: "/var/www/example.com/static/"

View file

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