Skip to content

Commit 04bce10

Browse files
committed
Add History tab at /wg/[acronym]/ page, move group history entries
from charter to this page - Legacy-Id: 3818
1 parent 201edb3 commit 04bce10

7 files changed

Lines changed: 65 additions & 15 deletions

File tree

ietf/idtracker/templatetags/ietf_filters.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django import template
55
from django.conf import settings
66
from django.utils.html import escape, fix_ampersands
7-
from django.template.defaultfilters import linebreaksbr, wordwrap, stringfilter
7+
from django.template.defaultfilters import linebreaksbr, wordwrap, stringfilter, urlize, truncatewords_html
88
from django.template import resolve_variable
99
from django.utils.safestring import mark_safe, SafeData
1010
try:
@@ -440,6 +440,15 @@ def ad_area(user):
440440
return g[0].acronym
441441
return None
442442

443+
@register.filter
444+
def format_history_text(text):
445+
"""Run history text through some cleaning and add ellipsis if it's too long."""
446+
full = mark_safe(sanitize_html(keep_spacing(linebreaksbr(urlize(mark_safe(text))))))
447+
snipped = truncatewords_html(format_textarea(fill(text, 80)), 25)
448+
if snipped[-3:] == "...":
449+
return mark_safe(u'<div class="snipped">%s<div class="showAll">[show all]</div><div><div style="display:none" class="full">%s</div>' % (snipped, full))
450+
return full
451+
443452
def _test():
444453
import doctest
445454
doctest.testmod()

ietf/templates/wginfo/history.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{% extends "wginfo/wg_base.html" %}
2+
{% load ietf_filters %}
3+
4+
{% block wg_titledetail %}History{% endblock %}
5+
6+
{% block wg_content %}
7+
{% load ietf_filters %}
8+
9+
<h2>WG History</h2>
10+
11+
<table class="ietf-table history">
12+
<tr><th>Date</th><th>By</th><th>Text</th></tr>
13+
{% for e in events %}
14+
<tr class="{% cycle oddrow,evenrow %}">
15+
<td>{{ e.time|date:"Y-m-d"}}</td>
16+
<td>{{ e.by.name }}</td>
17+
<td>{{ e.desc|format_history_text }}</td>
18+
</tr>
19+
{% endfor %}
20+
</table>
21+
{% endblock %}
22+
23+
{% block content_end %}
24+
<script src="/js/history.js" type="text/javascript"></script>
25+
{% endblock %}

ietf/templates/wginfo/wg_base.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@
5858
<h1>{{wg.group_acronym.name}} ({{wg.group_acronym.acronym}}){% if concluded %}<br/><span class="ietf-concluded-warning">(concluded WG)</span>{% endif %}{% if proposed %}<br/><span class="ietf-proposed-warning">(proposed WG)</span>{% endif %}</h1>
5959

6060
<div class="ietf-navset">
61-
{% ifequal selected "documents" %}<span class="selected">Documents</span>{% else %}<a href="/wg/{{wg}}/">Documents</a>{% endifequal %} |
62-
{% ifequal selected "charter" %}<span class="selected">Charter</span>{% else %}<a href="/wg/{{wg}}/charter/">Charter</a>{% endifequal %} |
61+
{% ifequal selected "documents" %}<span class="selected">Documents</span>{% else %}<a href="{% url wginfo.views.wg_documents_html acronym=wg.group_acronym.acronym %}">Documents</a>{% endifequal %} |
62+
{% ifequal selected "charter" %}<span class="selected">Charter</span>{% else %}<a href="{% url wginfo.views.wg_charter acronym=wg.group_acronym.acronym %}">Charter</a>{% endifequal %} |
6363
{% wgchairs_admin_options wg %}
64+
<a {% if selected == "history" %}class="selected"{% else %}href="{% url wginfo.views.history acronym=wg.group_acronym.acronym %}"{% endif %}>History</a> |
6465
{% if wg.clean_email_archive|startswith:"http:" or wg.clean_email_archive|startswith:"ftp:" %}
6566
<a href="{{ wg.clean_email_archive }}">List Archive &#187;</a> |
6667
{% endif %}

ietf/wgcharter/views.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def wg_main(request, name, rev, tab):
8484
"charter-ietf-"+str(gh.acronym)+"-"+str(ch.rev)+".txt",
8585
os.path.join(file_path, "charter-ietf-"+gh.acronym+"-"+ch.rev+".txt"))
8686
active_ads = Person.objects.filter(email__role__name="ad", email__role__group__state="active").distinct()
87-
started_process = datetime.datetime.min
87+
started_process = datetime.min
8888
e = wg.charter.latest_event(type="started_iesg_process")
8989
if e:
9090
started_process = e.time
@@ -148,17 +148,6 @@ def wg_main(request, name, rev, tab):
148148

149149
def _get_history(wg, versions=None):
150150
results = []
151-
for e in wg.groupevent_set.all().select_related('by').order_by('-time', 'id'):
152-
info = {}
153-
154-
charter_history = find_history_active_at(wg.charter, e.time)
155-
info['version'] = charter_history.rev if charter_history else wg.charter.rev
156-
info['text'] = e.desc
157-
info['by'] = e.by.name
158-
info['textSnippet'] = truncatewords_html(format_textarea(fill(info['text'], 80)), 25)
159-
info['snipped'] = info['textSnippet'][-3:] == "..."
160-
results.append({'comment':e, 'info':info, 'date':e.time, 'group': wg, 'is_com':True})
161-
162151
for e in wg.charter.docevent_set.all().order_by('-time'):
163152
info = {}
164153
charter_history = find_history_active_at(wg.charter, e.time)

ietf/wginfo/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
(r'^(?P<acronym>[a-zA-Z0-9-]+)/documents/txt/$', views.wg_documents_txt),
1717
(r'^(?P<acronym>[a-zA-Z0-9-]+)/$', views.wg_documents_html),
1818
(r'^(?P<acronym>[a-zA-Z0-9-]+)/charter/$', views.wg_charter),
19+
(r'^(?P<acronym>[a-zA-Z0-9-]+)/history/', views.history),
1920
(r'^(?P<acronym>[^/]+)/management/', include('ietf.wgchairs.urls')),
2021
)

ietf/wginfo/views.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from ietf.idrfc.views_search import SearchForm, search_query
4141
from ietf.idrfc.idrfc_wrapper import IdRfcWrapper
4242
from ietf.ipr.models import IprDetail
43+
from redesign.group.models import Group
4344

4445

4546
def fill_in_charter_info(wg, include_drafts=False):
@@ -156,3 +157,22 @@ def wg_charter(request, acronym):
156157
RequestContext(request))
157158

158159
return render_to_response('wginfo/wg_charter.html', {'wg': wg, 'concluded':concluded, 'proposed': proposed, 'selected':'charter'}, RequestContext(request))
160+
161+
def get_wg_menu_context(wg, selected):
162+
# it would probably be better to refactor this file into rendering
163+
# the menu separately instead of each view having to include the information
164+
165+
return dict(wg=wg, concluded=wg.state_id == "conclude", proposed=wg.state_id == "proposed", selected=selected)
166+
167+
def history(request, acronym):
168+
wg = get_object_or_404(Group, acronym=acronym)
169+
170+
events = wg.groupevent_set.all().select_related('by').order_by('-time', '-id')
171+
172+
context = get_wg_menu_context(wg, "history")
173+
context.update(dict(events=events,
174+
))
175+
176+
wg.group_acronym = wg # hack for compatibility with old templates
177+
178+
return render_to_response('wginfo/history.html', context, RequestContext(request))

static/js/history.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
jQuery(function () {
2+
jQuery("table.history .snipped .showAll").click(function () {
3+
jQuery(this).parents("snipped").hide().siblings("full").show();
4+
});
5+
});

0 commit comments

Comments
 (0)