From c94757405d68caa05abded5586389f75bfe75c16 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Mon, 2 Jun 2014 12:18:42 +0000 Subject: [PATCH] Add a /doc/ page for materials (slides, agendas, minutes), link to that from the group materials page - Legacy-Id: 7825 --- ietf/doc/views_doc.py | 39 +++++++++++- ietf/group/edit.py | 3 + ietf/group/info.py | 9 +-- ietf/group/utils.py | 2 +- ietf/settings.py | 2 +- ietf/templates/doc/document_material.html | 78 +++++++++++++++++++++++ ietf/templates/group/materials.html | 11 +--- static/css/doc.css | 2 + 8 files changed, 124 insertions(+), 22 deletions(-) create mode 100644 ietf/templates/doc/document_material.html diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index 133ab5ea0..5bc56768e 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -30,7 +30,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import os, datetime, urllib, json +import os, datetime, urllib, json, glob from django.http import HttpResponse, Http404 from django.shortcuts import render_to_response, get_object_or_404, redirect @@ -53,7 +53,7 @@ from ietf.community.models import CommunityList from ietf.doc.mails import email_ad from ietf.doc.views_status_change import RELATION_SLUGS as status_change_relationships from ietf.group.models import Role -from ietf.group.utils import can_manage_group_type +from ietf.group.utils import can_manage_group_type, can_manage_materials from ietf.ietfauth.utils import has_role, is_authorized_in_doc_stream, user_is_person, role_required from ietf.name.models import StreamName, BallotPositionName from ietf.person.models import Email @@ -481,6 +481,41 @@ def document_main(request, name, rev=None): ), context_instance=RequestContext(request)) + if doc.type_id in ("slides", "agenda", "minutes"): + can_manage_material = can_manage_materials(request.user, doc.group) + if doc.meeting_related(): + # disallow editing meeting-related stuff through this + # interface for the time being + can_manage_material = False + + basename = "%s-%s" % (doc.canonical_name(), doc.rev) + pathname = os.path.join(doc.get_file_path(), basename) + + content = None + other_types = [] + globs = glob.glob(pathname + ".*") + for g in globs: + extension = os.path.splitext(g)[1] + t = os.path.splitext(g)[1].lstrip(".") + url = doc.href() + extension + + if extension == ".txt": + content = get_document_content(basename, pathname, split=False) + t = "plain text" + + other_types.append((t, url)) + + return render_to_response("doc/document_material.html", + dict(doc=doc, + top=top, + content=content, + revisions=revisions, + snapshot=snapshot, + can_manage_material=can_manage_material, + other_types=other_types, + ), + context_instance=RequestContext(request)) + raise Http404 diff --git a/ietf/group/edit.py b/ietf/group/edit.py index 67fcbf95b..6e8200193 100644 --- a/ietf/group/edit.py +++ b/ietf/group/edit.py @@ -562,6 +562,9 @@ def edit_material(request, acronym, action="new", name=None, doc_type=None, grou d.save() + if action == "new": + DocAlias.objects.get_or_create(name=d.name, document=d) + if not existing or prev_rev != d.rev: e = NewRevisionDocEvent(type="new_revision", doc=d, rev=d.rev) e.time = d.time diff --git a/ietf/group/info.py b/ietf/group/info.py index 39881fc40..727cc5d44 100644 --- a/ietf/group/info.py +++ b/ietf/group/info.py @@ -437,16 +437,9 @@ def materials(request, acronym, group_type=None): if not group.features.has_materials: raise Http404 - docs = get_group_materials(group).order_by("type", "-time").select_related("type") + docs = get_group_materials(group).order_by("type__order", "-time").select_related("type") doc_types = OrderedDict() for d in docs: - extension = "" - globs = glob.glob(d.get_file_path() + d.name + "-" + d.rev + ".*") - if globs: - extension = os.path.splitext(globs[0])[1] - - d.full_url = d.href() + extension - if d.type not in doc_types: doc_types[d.type] = [] doc_types[d.type].append(d) diff --git a/ietf/group/utils.py b/ietf/group/utils.py index c6a96a03d..c4de6a8a7 100644 --- a/ietf/group/utils.py +++ b/ietf/group/utils.py @@ -109,7 +109,7 @@ def milestone_reviewer_for_group_type(group_type): return "Area Director" def can_manage_materials(user, group): - return group.has_role(user, ("chair", "delegate", "secr")) or has_role(user, 'Secretariat') + return has_role(user, 'Secretariat') or group.has_role(user, ("chair", "delegate", "secr")) def get_group_or_404(acronym, group_type): """Helper to overcome the schism between group-type prefixed URLs and generic.""" diff --git a/ietf/settings.py b/ietf/settings.py index 3321622ee..3856ded0f 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -283,7 +283,7 @@ DOC_HREFS = { # who understands this better can take care of it. #"liai-att": None #"liaison": None - "slides": 'http://www.ietf.org/slides/', + "slides": 'http://www.ietf.org/slides/{doc.name}-{doc.rev}', } MEETING_DOC_HREFS = { diff --git a/ietf/templates/doc/document_material.html b/ietf/templates/doc/document_material.html new file mode 100644 index 000000000..4c4902126 --- /dev/null +++ b/ietf/templates/doc/document_material.html @@ -0,0 +1,78 @@ +{% extends "base.html" %} + +{% load ietf_filters %} + +{% block title %}{{ doc.canonical_name }}-{{ doc.rev }}{% endblock %} + +{% block pagehead %} + +{% endblock %} + +{% block content %} +{{ top|safe }} + +{% include "doc/revisions_list.html" %} + +
+
+ {% if snapshot %}Snapshot of{% endif %} {% if doc.meeting_related %}Meeting{% endif %} {{ doc.type.name }} for {{ doc.group.acronym }} group +
+ + + + + + + + + + + + + {% if other_types %} + + + + + {% endif %} + + + + + + + {% if not snapshot and can_manage_material %} + + {% endif %} + +
Title: + {{ doc.title }} +
State: + {{ doc.get_state.name }} +
Other versions: + {% for t, url in other_types %} + {{ t }}{% if not forloop.last %},{% endif %} + {% endfor %} +
Last updated:{{ doc.time|date:"Y-m-d" }}
+ Change title/state + + Revise content +
+
+ +{% if doc.rev and content != None %} +

{{ doc.title }}

+ +
+ {{ content|fill:"80"|safe|linebreaksbr|keep_spacing|sanitize_html|safe }} +
+{% else %} +

Not available as plain text.

+ + {% if other_types %} +

Download as {{ other_types.0.0.upper }}

+ {% endif %} +{% endif %} + +{% endblock %} + diff --git a/ietf/templates/group/materials.html b/ietf/templates/group/materials.html index 4287e1ff0..221e00e1f 100644 --- a/ietf/templates/group/materials.html +++ b/ietf/templates/group/materials.html @@ -25,16 +25,7 @@ {% for d in docs %} - - {% if can_manage_materials %} - - edit | - revise - - {% endif %} - - {{ d.title }} - + {{ d.title }} {{ d.rev }} {{ d.time|date:"Y-m-d" }} diff --git a/static/css/doc.css b/static/css/doc.css index deaa737d9..1482408dc 100644 --- a/static/css/doc.css +++ b/static/css/doc.css @@ -46,3 +46,5 @@ h3 a.edit { font-weight: normal; font-size: 13px; display: inline-block; margin- h4 { margin-bottom: 0; } h4 + p { margin-top: 0; max-width: 400px; } + +p.download-instead a { font-size: 20px; font-weight: bold; color: #2647a0; }