From 04bce1052142e89faf3d74a0609429a5aa31fbd0 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Tue, 17 Jan 2012 16:10:14 +0000 Subject: [PATCH] Add History tab at /wg/[acronym]/ page, move group history entries from charter to this page - Legacy-Id: 3818 --- ietf/idtracker/templatetags/ietf_filters.py | 11 ++++++++- ietf/templates/wginfo/history.html | 25 +++++++++++++++++++++ ietf/templates/wginfo/wg_base.html | 5 +++-- ietf/wgcharter/views.py | 13 +---------- ietf/wginfo/urls.py | 1 + ietf/wginfo/views.py | 20 +++++++++++++++++ static/js/history.js | 5 +++++ 7 files changed, 65 insertions(+), 15 deletions(-) create mode 100644 ietf/templates/wginfo/history.html create mode 100644 static/js/history.js diff --git a/ietf/idtracker/templatetags/ietf_filters.py b/ietf/idtracker/templatetags/ietf_filters.py index ce216e8d7..3beac0987 100644 --- a/ietf/idtracker/templatetags/ietf_filters.py +++ b/ietf/idtracker/templatetags/ietf_filters.py @@ -4,7 +4,7 @@ import textwrap from django import template from django.conf import settings from django.utils.html import escape, fix_ampersands -from django.template.defaultfilters import linebreaksbr, wordwrap, stringfilter +from django.template.defaultfilters import linebreaksbr, wordwrap, stringfilter, urlize, truncatewords_html from django.template import resolve_variable from django.utils.safestring import mark_safe, SafeData try: @@ -440,6 +440,15 @@ def ad_area(user): return g[0].acronym return None +@register.filter +def format_history_text(text): + """Run history text through some cleaning and add ellipsis if it's too long.""" + full = mark_safe(sanitize_html(keep_spacing(linebreaksbr(urlize(mark_safe(text)))))) + snipped = truncatewords_html(format_textarea(fill(text, 80)), 25) + if snipped[-3:] == "...": + return mark_safe(u'
%s
[show all]
' % (snipped, full)) + return full + def _test(): import doctest doctest.testmod() diff --git a/ietf/templates/wginfo/history.html b/ietf/templates/wginfo/history.html new file mode 100644 index 000000000..d064b4a5d --- /dev/null +++ b/ietf/templates/wginfo/history.html @@ -0,0 +1,25 @@ +{% extends "wginfo/wg_base.html" %} +{% load ietf_filters %} + +{% block wg_titledetail %}History{% endblock %} + +{% block wg_content %} +{% load ietf_filters %} + +

WG History

+ + + + {% for e in events %} + + + + + + {% endfor %} +
DateByText
{{ e.time|date:"Y-m-d"}}{{ e.by.name }}{{ e.desc|format_history_text }}
+{% endblock %} + +{% block content_end %} + +{% endblock %} diff --git a/ietf/templates/wginfo/wg_base.html b/ietf/templates/wginfo/wg_base.html index 26dfea424..7fcb6788a 100644 --- a/ietf/templates/wginfo/wg_base.html +++ b/ietf/templates/wginfo/wg_base.html @@ -58,9 +58,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

{{wg.group_acronym.name}} ({{wg.group_acronym.acronym}}){% if concluded %}
(concluded WG){% endif %}{% if proposed %}
(proposed WG){% endif %}

-{% ifequal selected "documents" %}Documents{% else %}Documents{% endifequal %} | -{% ifequal selected "charter" %}Charter{% else %}Charter{% endifequal %} | +{% ifequal selected "documents" %}Documents{% else %}Documents{% endifequal %} | +{% ifequal selected "charter" %}Charter{% else %}Charter{% endifequal %} | {% wgchairs_admin_options wg %} +History | {% if wg.clean_email_archive|startswith:"http:" or wg.clean_email_archive|startswith:"ftp:" %} List Archive » | {% endif %} diff --git a/ietf/wgcharter/views.py b/ietf/wgcharter/views.py index 92c32026a..b15a4c00f 100644 --- a/ietf/wgcharter/views.py +++ b/ietf/wgcharter/views.py @@ -84,7 +84,7 @@ def wg_main(request, name, rev, tab): "charter-ietf-"+str(gh.acronym)+"-"+str(ch.rev)+".txt", os.path.join(file_path, "charter-ietf-"+gh.acronym+"-"+ch.rev+".txt")) active_ads = Person.objects.filter(email__role__name="ad", email__role__group__state="active").distinct() - started_process = datetime.datetime.min + started_process = datetime.min e = wg.charter.latest_event(type="started_iesg_process") if e: started_process = e.time @@ -148,17 +148,6 @@ def wg_main(request, name, rev, tab): def _get_history(wg, versions=None): results = [] - for e in wg.groupevent_set.all().select_related('by').order_by('-time', 'id'): - info = {} - - charter_history = find_history_active_at(wg.charter, e.time) - info['version'] = charter_history.rev if charter_history else wg.charter.rev - info['text'] = e.desc - info['by'] = e.by.name - info['textSnippet'] = truncatewords_html(format_textarea(fill(info['text'], 80)), 25) - info['snipped'] = info['textSnippet'][-3:] == "..." - results.append({'comment':e, 'info':info, 'date':e.time, 'group': wg, 'is_com':True}) - for e in wg.charter.docevent_set.all().order_by('-time'): info = {} charter_history = find_history_active_at(wg.charter, e.time) diff --git a/ietf/wginfo/urls.py b/ietf/wginfo/urls.py index ce0663c26..62936669d 100644 --- a/ietf/wginfo/urls.py +++ b/ietf/wginfo/urls.py @@ -16,5 +16,6 @@ urlpatterns = patterns('', (r'^(?P[a-zA-Z0-9-]+)/documents/txt/$', views.wg_documents_txt), (r'^(?P[a-zA-Z0-9-]+)/$', views.wg_documents_html), (r'^(?P[a-zA-Z0-9-]+)/charter/$', views.wg_charter), + (r'^(?P[a-zA-Z0-9-]+)/history/', views.history), (r'^(?P[^/]+)/management/', include('ietf.wgchairs.urls')), ) diff --git a/ietf/wginfo/views.py b/ietf/wginfo/views.py index 46c253e19..a274b9b28 100644 --- a/ietf/wginfo/views.py +++ b/ietf/wginfo/views.py @@ -40,6 +40,7 @@ from ietf.idtracker.models import Area, IETFWG from ietf.idrfc.views_search import SearchForm, search_query from ietf.idrfc.idrfc_wrapper import IdRfcWrapper from ietf.ipr.models import IprDetail +from redesign.group.models import Group def fill_in_charter_info(wg, include_drafts=False): @@ -156,3 +157,22 @@ def wg_charter(request, acronym): RequestContext(request)) return render_to_response('wginfo/wg_charter.html', {'wg': wg, 'concluded':concluded, 'proposed': proposed, 'selected':'charter'}, RequestContext(request)) + +def get_wg_menu_context(wg, selected): + # it would probably be better to refactor this file into rendering + # the menu separately instead of each view having to include the information + + return dict(wg=wg, concluded=wg.state_id == "conclude", proposed=wg.state_id == "proposed", selected=selected) + +def history(request, acronym): + wg = get_object_or_404(Group, acronym=acronym) + + events = wg.groupevent_set.all().select_related('by').order_by('-time', '-id') + + context = get_wg_menu_context(wg, "history") + context.update(dict(events=events, + )) + + wg.group_acronym = wg # hack for compatibility with old templates + + return render_to_response('wginfo/history.html', context, RequestContext(request)) diff --git a/static/js/history.js b/static/js/history.js new file mode 100644 index 000000000..843c8f79a --- /dev/null +++ b/static/js/history.js @@ -0,0 +1,5 @@ +jQuery(function () { + jQuery("table.history .snipped .showAll").click(function () { + jQuery(this).parents("snipped").hide().siblings("full").show(); + }); +});