Skip to content

Commit c947574

Browse files
committed
Add a /doc/ page for materials (slides, agendas, minutes), link to that from the group materials page
- Legacy-Id: 7825
1 parent 779763e commit c947574

File tree

8 files changed

+124
-22
lines changed

8 files changed

+124
-22
lines changed

ietf/doc/views_doc.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3131
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232

33-
import os, datetime, urllib, json
33+
import os, datetime, urllib, json, glob
3434

3535
from django.http import HttpResponse, Http404
3636
from django.shortcuts import render_to_response, get_object_or_404, redirect
@@ -53,7 +53,7 @@
5353
from ietf.doc.mails import email_ad
5454
from ietf.doc.views_status_change import RELATION_SLUGS as status_change_relationships
5555
from ietf.group.models import Role
56-
from ietf.group.utils import can_manage_group_type
56+
from ietf.group.utils import can_manage_group_type, can_manage_materials
5757
from ietf.ietfauth.utils import has_role, is_authorized_in_doc_stream, user_is_person, role_required
5858
from ietf.name.models import StreamName, BallotPositionName
5959
from ietf.person.models import Email
@@ -481,6 +481,41 @@ def document_main(request, name, rev=None):
481481
),
482482
context_instance=RequestContext(request))
483483

484+
if doc.type_id in ("slides", "agenda", "minutes"):
485+
can_manage_material = can_manage_materials(request.user, doc.group)
486+
if doc.meeting_related():
487+
# disallow editing meeting-related stuff through this
488+
# interface for the time being
489+
can_manage_material = False
490+
491+
basename = "%s-%s" % (doc.canonical_name(), doc.rev)
492+
pathname = os.path.join(doc.get_file_path(), basename)
493+
494+
content = None
495+
other_types = []
496+
globs = glob.glob(pathname + ".*")
497+
for g in globs:
498+
extension = os.path.splitext(g)[1]
499+
t = os.path.splitext(g)[1].lstrip(".")
500+
url = doc.href() + extension
501+
502+
if extension == ".txt":
503+
content = get_document_content(basename, pathname, split=False)
504+
t = "plain text"
505+
506+
other_types.append((t, url))
507+
508+
return render_to_response("doc/document_material.html",
509+
dict(doc=doc,
510+
top=top,
511+
content=content,
512+
revisions=revisions,
513+
snapshot=snapshot,
514+
can_manage_material=can_manage_material,
515+
other_types=other_types,
516+
),
517+
context_instance=RequestContext(request))
518+
484519
raise Http404
485520

486521

ietf/group/edit.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ def edit_material(request, acronym, action="new", name=None, doc_type=None, grou
562562

563563
d.save()
564564

565+
if action == "new":
566+
DocAlias.objects.get_or_create(name=d.name, document=d)
567+
565568
if not existing or prev_rev != d.rev:
566569
e = NewRevisionDocEvent(type="new_revision", doc=d, rev=d.rev)
567570
e.time = d.time

ietf/group/info.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,16 +437,9 @@ def materials(request, acronym, group_type=None):
437437
if not group.features.has_materials:
438438
raise Http404
439439

440-
docs = get_group_materials(group).order_by("type", "-time").select_related("type")
440+
docs = get_group_materials(group).order_by("type__order", "-time").select_related("type")
441441
doc_types = OrderedDict()
442442
for d in docs:
443-
extension = ""
444-
globs = glob.glob(d.get_file_path() + d.name + "-" + d.rev + ".*")
445-
if globs:
446-
extension = os.path.splitext(globs[0])[1]
447-
448-
d.full_url = d.href() + extension
449-
450443
if d.type not in doc_types:
451444
doc_types[d.type] = []
452445
doc_types[d.type].append(d)

ietf/group/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def milestone_reviewer_for_group_type(group_type):
109109
return "Area Director"
110110

111111
def can_manage_materials(user, group):
112-
return group.has_role(user, ("chair", "delegate", "secr")) or has_role(user, 'Secretariat')
112+
return has_role(user, 'Secretariat') or group.has_role(user, ("chair", "delegate", "secr"))
113113

114114
def get_group_or_404(acronym, group_type):
115115
"""Helper to overcome the schism between group-type prefixed URLs and generic."""

ietf/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def skip_suspicious_operations(record):
283283
# who understands this better can take care of it.
284284
#"liai-att": None
285285
#"liaison": None
286-
"slides": 'http://www.ietf.org/slides/',
286+
"slides": 'http://www.ietf.org/slides/{doc.name}-{doc.rev}',
287287
}
288288

289289
MEETING_DOC_HREFS = {
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{% extends "base.html" %}
2+
3+
{% load ietf_filters %}
4+
5+
{% block title %}{{ doc.canonical_name }}-{{ doc.rev }}{% endblock %}
6+
7+
{% block pagehead %}
8+
<link rel="stylesheet" type="text/css" href="/css/doc.css"></link>
9+
{% endblock %}
10+
11+
{% block content %}
12+
{{ top|safe }}
13+
14+
{% include "doc/revisions_list.html" %}
15+
16+
<div class="ietf-box metabox">
17+
<div>
18+
{% 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
19+
</div>
20+
21+
<table id="metatable" width="100%">
22+
<tr>
23+
<td>Title:</td>
24+
<td>
25+
<a {% if not snapshot and can_manage_material %} class="editlink" href="{% url "status_change_change_state" name=doc.name %}"{% endif %}>{{ doc.title }}</a>
26+
</td>
27+
</tr>
28+
29+
<tr>
30+
<td>State:</td>
31+
<td>
32+
<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>
33+
</td>
34+
</tr>
35+
36+
{% if other_types %}
37+
<tr>
38+
<td>Other versions:</td>
39+
<td>
40+
{% for t, url in other_types %}
41+
<a href="{{ url }}">{{ t }}</a>{% if not forloop.last %},{% endif %}
42+
{% endfor %}
43+
</td>
44+
</tr>
45+
{% endif %}
46+
47+
<tr>
48+
<td>Last updated:</td>
49+
<td>{{ doc.time|date:"Y-m-d" }}</td>
50+
</tr>
51+
52+
{% if not snapshot and can_manage_material %}
53+
<tr><td colspan="2">
54+
<a class="button" href="{% url "group_edit_material" acronym=group.acronym name=d.name %}">Change title/state</a>
55+
56+
<a class="button" href="{% url "group_revise_material" acronym=group.acronym name=d.name %}">Revise content</a>
57+
</td><tr/>
58+
{% endif %}
59+
60+
</table>
61+
</div>
62+
63+
{% if doc.rev and content != None %}
64+
<h3>{{ doc.title }}</h3>
65+
66+
<div class="markup_draft">
67+
{{ content|fill:"80"|safe|linebreaksbr|keep_spacing|sanitize_html|safe }}
68+
</div>
69+
{% else %}
70+
<p>Not available as plain text.</p>
71+
72+
{% if other_types %}
73+
<p class="download-instead"><a href="{{ other_types.0.1 }}">Download as {{ other_types.0.0.upper }}</a></p>
74+
{% endif %}
75+
{% endif %}
76+
77+
{% endblock %}
78+

ietf/templates/group/materials.html

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,7 @@ <h2>{{ doc_type.name }}</h2>
2525

2626
{% for d in docs %}
2727
<tr class="{% cycle "evenrow" "oddrow" %}">
28-
<td>
29-
{% if can_manage_materials %}
30-
<span class="edit-options">
31-
<a href="{% url "group_edit_material" acronym=group.acronym name=d.name %}">edit</a> |
32-
<a href="{% url "group_revise_material" acronym=group.acronym name=d.name %}">revise</a>
33-
</span>
34-
{% endif %}
35-
36-
<a class="title-link" href="{{ d.full_url }}">{{ d.title }}</a>
37-
</td>
28+
<td><a class="title-link" href="{% url "doc_view" name=d.name %}">{{ d.title }}</a></td>
3829
<td>{{ d.rev }}</td>
3930
<td>{{ d.time|date:"Y-m-d" }}</td>
4031
</tr>

static/css/doc.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ h3 a.edit { font-weight: normal; font-size: 13px; display: inline-block; margin-
4646

4747
h4 { margin-bottom: 0; }
4848
h4 + p { margin-top: 0; max-width: 400px; }
49+
50+
p.download-instead a { font-size: 20px; font-weight: bold; color: #2647a0; }

0 commit comments

Comments
 (0)