Add a /doc/ page for materials (slides, agendas, minutes), link to that from the group materials page

- Legacy-Id: 7825
This commit is contained in:
Ole Laursen 2014-06-02 12:18:42 +00:00
parent 779763e58e
commit c94757405d
8 changed files with 124 additions and 22 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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."""

View file

@ -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 = {

View file

@ -0,0 +1,78 @@
{% extends "base.html" %}
{% load ietf_filters %}
{% block title %}{{ doc.canonical_name }}-{{ doc.rev }}{% endblock %}
{% block pagehead %}
<link rel="stylesheet" type="text/css" href="/css/doc.css"></link>
{% endblock %}
{% block content %}
{{ top|safe }}
{% include "doc/revisions_list.html" %}
<div class="ietf-box metabox">
<div>
{% if snapshot %}Snapshot of{% endif %} {% if doc.meeting_related %}Meeting{% endif %} {{ doc.type.name }} for <a href="{{ doc.group.about_url }}">{{ doc.group.acronym }}</a> group
</div>
<table id="metatable" width="100%">
<tr>
<td>Title:</td>
<td>
<a {% if not snapshot and can_manage_material %} class="editlink" href="{% url "status_change_change_state" name=doc.name %}"{% endif %}>{{ doc.title }}</a>
</td>
</tr>
<tr>
<td>State:</td>
<td>
<a title="{{ doc.get_state.desc }}"{% if not snapshot and can_manage_material %} class="editlink" href="{% url "status_change_change_state" name=doc.name %}"{% endif %}>{{ doc.get_state.name }}</a>
</td>
</tr>
{% if other_types %}
<tr>
<td>Other versions:</td>
<td>
{% for t, url in other_types %}
<a href="{{ url }}">{{ t }}</a>{% if not forloop.last %},{% endif %}
{% endfor %}
</td>
</tr>
{% endif %}
<tr>
<td>Last updated:</td>
<td>{{ doc.time|date:"Y-m-d" }}</td>
</tr>
{% if not snapshot and can_manage_material %}
<tr><td colspan="2">
<a class="button" href="{% url "group_edit_material" acronym=group.acronym name=d.name %}">Change title/state</a>
<a class="button" href="{% url "group_revise_material" acronym=group.acronym name=d.name %}">Revise content</a>
</td><tr/>
{% endif %}
</table>
</div>
{% if doc.rev and content != None %}
<h3>{{ doc.title }}</h3>
<div class="markup_draft">
{{ content|fill:"80"|safe|linebreaksbr|keep_spacing|sanitize_html|safe }}
</div>
{% else %}
<p>Not available as plain text.</p>
{% if other_types %}
<p class="download-instead"><a href="{{ other_types.0.1 }}">Download as {{ other_types.0.0.upper }}</a></p>
{% endif %}
{% endif %}
{% endblock %}

View file

@ -25,16 +25,7 @@
{% for d in docs %}
<tr class="{% cycle "evenrow" "oddrow" %}">
<td>
{% if can_manage_materials %}
<span class="edit-options">
<a href="{% url "group_edit_material" acronym=group.acronym name=d.name %}">edit</a> |
<a href="{% url "group_revise_material" acronym=group.acronym name=d.name %}">revise</a>
</span>
{% endif %}
<a class="title-link" href="{{ d.full_url }}">{{ d.title }}</a>
</td>
<td><a class="title-link" href="{% url "doc_view" name=d.name %}">{{ d.title }}</a></td>
<td>{{ d.rev }}</td>
<td>{{ d.time|date:"Y-m-d" }}</td>
</tr>

View file

@ -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; }