diff --git a/ietf/templates/feeds/group_description.html b/ietf/templates/feeds/group_description.html new file mode 100644 index 000000000..8cb921700 --- /dev/null +++ b/ietf/templates/feeds/group_description.html @@ -0,0 +1,3 @@ +{# Copyright The IETF Trust 2011, All Rights Reserved #} +{% load ietf_filters %} +

{{ obj.desc|safe|linebreaksbr }}

diff --git a/ietf/templates/feeds/wg_charter_description.html b/ietf/templates/feeds/wg_charter_description.html deleted file mode 100644 index 879bee2a2..000000000 --- a/ietf/templates/feeds/wg_charter_description.html +++ /dev/null @@ -1,35 +0,0 @@ -{# Copyright The IETF Trust 2011, All Rights Reserved #} -{% load ietf_filters %} -

{{ obj.info.text|safe|linebreaksbr }}

- -{% with obj.group as wg %} -

- WG name: {{ wg.name }}
- WG acronym: {{ wg.acronym }}
- IETF area: {{ wg.parent|default:"-" }}
-

- -

- WG chairs: {% for n in obj.chairs %}{{ n }}{% if not forloop.last %}, {% endif %}{% endfor %}
- WG secretaries: {% for n in obj.secr %}{{ n }}{% if not forloop.last %}, {% endif %}{% endfor %}
- WG technical advisors: {% for n in obj.techadv %}{{ n }}{% if not forloop.last %}, {% endif %}{% endfor %}
- Assigned AD: {{ wg.ad }}
-

- -

- Mailing list: {{ wg.list_email }}
- Mailing list subscribe {{ wg.list_subscribe }}
- Mailing list archive: {{ wg.list_archive }}
- Other web sites: {% for a in wg.groupurl_set.all %}{{ a.url }} {% if a.name %}({{ a.name }}){% endif %}{% if not forloop.last %}, {% endif %}{% endfor %}
-

- -

- WG State: {{ wg.state|safe }}
- Charter State: {% if wg.charter %}{{ wg.charter.get_state|safe }}{% endif %}
-

-{% if obj.rev %} -{{ obj.charter|safe }} -{% else %} -The WG does not yet have a charter -{% endif %} -{% endwith %} diff --git a/ietf/templates/feeds/wg_charter_title.html b/ietf/templates/feeds/wg_charter_title.html deleted file mode 100644 index 29cd881f9..000000000 --- a/ietf/templates/feeds/wg_charter_title.html +++ /dev/null @@ -1 +0,0 @@ -{% load ietf_filters %}WG Charter for {{obj.group.name}} ({{ obj.group.acronym|safe }}) diff --git a/ietf/urls.py b/ietf/urls.py index f5cf13bce..7c4d41534 100644 --- a/ietf/urls.py +++ b/ietf/urls.py @@ -9,7 +9,7 @@ from ietf.idtracker.feeds import DocumentComments, InLastCall from ietf.ipr.feeds import LatestIprDisclosures from ietf.proceedings.feeds import LatestWgProceedingsActivity from ietf.liaisons.feeds import Liaisons -from ietf.wgcharter.feeds import GroupEvents +from ietf.wgcharter.feeds import GroupChanges from ietf.idtracker.sitemaps import IDTrackerMap, DraftMap from ietf.liaisons.sitemaps import LiaisonMap @@ -25,7 +25,7 @@ feeds = { 'iesg-agenda': IESGAgenda, 'last-call': InLastCall, 'comments': DocumentComments, - 'wgchanges': GroupEvents, + 'group-changes': GroupChanges, 'ipr': LatestIprDisclosures, 'liaison': Liaisons, 'wg-proceedings' : LatestWgProceedingsActivity diff --git a/ietf/wgcharter/feeds.py b/ietf/wgcharter/feeds.py index 912c3a571..31369daf8 100644 --- a/ietf/wgcharter/feeds.py +++ b/ietf/wgcharter/feeds.py @@ -5,72 +5,24 @@ import datetime, re, os from django.conf import settings from django.contrib.syndication.feeds import Feed, FeedDoesNotExist from django.utils.feedgenerator import Atom1Feed -from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse as urlreverse -from django.template.defaultfilters import truncatewords_html +from django.utils.html import strip_tags +from django.utils.text import truncate_words -from ietf.idtracker.templatetags.ietf_filters import format_textarea, fill -from ietf.wgcharter.utils import * from ietf.utils.history import find_history_active_at -from ietf.group.models import Group -from ietf.idrfc.views_doc import _get_html +from ietf.group.models import Group, GroupEvent +from ietf.doc.models import DocEvent -def _get_history(wg, versions=None): - results = [] - for e in wg.charter.docevent_set.all().order_by('-time'): - 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.plain_name() - info['textSnippet'] = truncatewords_html(format_textarea(fill(info['text'], 80)), 25) - info['snipped'] = info['textSnippet'][-3:] == "..." - if e.type == "new_revision": - if charter_history: - charter = get_charter_for_revision(wg.charter, charter_history.rev) - group = get_group_for_revision(wg, charter_history.rev) - else: - charter = get_charter_for_revision(wg.charter, wg.charter.rev) - group = get_group_for_revision(wg, wg.charter.rev) - - if versions: - vl = [x['rev'] for x in versions] - if vl: - prev_charter = get_charter_for_revision(wg.charter, vl[vl.index(charter.rev) - 1]) - else: - prev_charter = get_charter_for_revision(wg.charter, prev_revision(charter.rev)) - prev_group = get_group_for_revision(wg, prev_revision(charter.rev)) - results.append({'comment':e, 'info':info, 'date':e.time, 'group': group, - 'charter': charter, 'prev_charter': prev_charter, - 'prev_group': prev_group, - 'txt_url': settings.CHARTER_TXT_URL, - 'is_rev':True}) - else: - results.append({'comment':e, 'info':info, 'date':e.time, 'group': wg, 'is_com':True}) - - # convert plain dates to datetimes (required for sorting) - for x in results: - if not isinstance(x['date'], datetime.datetime): - if x['date']: - x['date'] = datetime.datetime.combine(x['date'], datetime.time(0,0,0)) - else: - x['date'] = datetime.datetime(1970,1,1) - - results.sort(key=lambda x: x['date']) - results.reverse() - return results - -class GroupEvents(Feed): +class GroupChanges(Feed): feed_type = Atom1Feed - title_template = "feeds/wg_charter_title.html" - description_template = "feeds/wg_charter_description.html" + description_template = "feeds/group_description.html" def get_object(self, bits): if len(bits) != 1: raise Group.DoesNotExist return Group.objects.get(acronym=bits[0]) def title(self, obj): - return "WG changes for %s" % obj.acronym + return u"Changes for %s %s" % (obj.acronym, obj.type) def link(self, obj): if not obj: @@ -81,34 +33,26 @@ class GroupEvents(Feed): return self.title(obj) def items(self, obj): - history = _get_history(obj) - for h in history: - gh = find_history_active_at(obj, h['date']) - if gh: - h['chairs'] = [x.person.plain_name() for x in gh.rolehistory_set.filter(name__slug="chair")] - h['secr'] = [x.person.plain_name() for x in gh.rolehistory_set.filter(name__slug="secr")] - h['techadv'] = [x.person.plain_name() for x in gh.rolehistory_set.filter(name__slug="techadv")] - else: - h['chairs'] = [x.person.plain_name() for x in obj.role_set.filter(name__slug="chair")] - h['secr'] = [x.person.plain_name() for x in obj.role_set.filter(name__slug="secr")] - h['techadv'] = [x.person.plain_name() for x in obj.role_set.filter(name__slug="techadv")] - dh = find_history_active_at(obj.charter, h['date']) - if dh: - h['rev'] = dh.rev - h['charter'] = _get_html( - str(dh.name)+"-"+str(dh.rev)+",html", - os.path.join(dh.get_file_path(), dh.name+"-"+dh.rev+".txt"), False) - else: - h['rev'] = obj.charter.rev - h['charter'] = _get_html( - "charter-ietf-"+str(obj.acronym)+"-"+str(obj.charter.rev)+",html", - os.path.join(obj.charter.get_file_path(), "charter-ietf-"+obj.acronym+"-"+obj.charter.rev+".txt"), False) - return history + events = list(obj.groupevent_set.all().select_related("group")) + if obj.charter: + events += list(obj.charter.docevent_set.all()) + + events.sort(key=lambda e: (e.time, e.id), reverse=True) + + return events def item_link(self, obj): - return urlreverse('wg_charter', kwargs={'acronym': obj['group'].acronym}) + if isinstance(obj, DocEvent): + return urlreverse("doc_view", kwargs={'name': obj.doc_id }) + elif isinstance(obj, GroupEvent): + return urlreverse('wg_charter', kwargs={'acronym': obj.group.acronym }) def item_pubdate(self, obj): - return obj['date'] + return obj.time + def item_title(self, obj): + title = u"%s - %s" % (truncate_words(strip_tags(obj.desc), 10), obj.by) + if isinstance(obj, DocEvent): + title = u"Chartering: %s" % title + return title diff --git a/ietf/wgcharter/utils.py b/ietf/wgcharter/utils.py index 7c191c9a5..ac8c23d29 100644 --- a/ietf/wgcharter/utils.py +++ b/ietf/wgcharter/utils.py @@ -15,49 +15,6 @@ def log_state_changed(request, doc, by, prev_state): e.save() return e -def get_charter_for_revision(charter, r): - if r == None: - return None - - l = charter.history_set.filter(rev=r).order_by('-time') - if l: - return l[0] - - # Get the lastest history entry - l = charter.history_set.all().order_by('-time') - if not l: - # no history, just return charter - return charter - - class FakeHistory(object): - def __init__(self, name, rev, time): - self.name = name - self.rev = rev - self.time = time - - return FakeHistory(l[0].name, charter.rev, charter.time) - -def get_group_for_revision(wg, r): - if r == None: - return None - else: - l = list(wg.charter.history_set.filter(rev=r).order_by('-time')) - if l != []: - o = list(wg.history_set.filter(time__lte=l[0].time).order_by('-time')) - if o != []: - return o[0] - else: - return wg - else: - return wg - -def prev_revision(rev): - m = re.match(r"(?P[0-9][0-9])(-(?P[0-9][0-9]))?", rev) - if m.group('minor') and m.group('minor') != "00": - return "%s-%#02d" % (m.group('major'), int(m.group('minor')) - 1) - else: - return None - def next_revision(rev): if rev == "": return "00-00"