datatracker/ietf/group/feeds.py
Henrik Levkowetz 815602351f This is a series of 50 migrations that changes the Document and DocAlias
primary keys from character strings to integers, and makes corresponding code
changes.

This was prompted by database limitations discovered when trying to make
DocAlias use a m2m document field; with 255 long strings as primary keys for
Document and DocAlias this violated the MySQL database limitations.

Changing the primary keys to integers should also improve efficiency.  

Due to the data migrations which create the new integer primary keys and adds
corresponding integer foreign keys matching the previous string foreign keys
in all tables having foreign keys to Document and DocAlias, some of these
migrations take a long time.  The total set of migrations are expected to have
a runtime on the order of 2 hours.
 - Legacy-Id: 16237
2019-06-10 11:32:46 +00:00

54 lines
1.6 KiB
Python

# Copyright The IETF Trust 2011, All Rights Reserved
from django.contrib.syndication.views import Feed, FeedDoesNotExist
from django.utils.feedgenerator import Atom1Feed
from django.urls import reverse as urlreverse
from django.utils.html import strip_tags
from django.template.defaultfilters import truncatewords
from ietf.group.models import Group, GroupEvent
from ietf.doc.models import DocEvent
class GroupChangesFeed(Feed):
feed_type = Atom1Feed
description_template = "group/feed_item_description.html"
def get_object(self, request, acronym):
return Group.objects.get(acronym=acronym)
def title(self, obj):
return u"Changes for %s %s" % (obj.acronym, obj.type)
def link(self, obj):
if not obj:
raise FeedDoesNotExist
return obj.about_url()
def description(self, obj):
return self.title(obj)
def items(self, obj):
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):
if isinstance(obj, DocEvent):
return urlreverse("ietf.doc.views_doc.document_main", kwargs={'name': obj.doc.name })
elif isinstance(obj, GroupEvent):
return obj.group.about_url()
def item_pubdate(self, obj):
return obj.time
def item_title(self, obj):
title = u"%s - %s" % (truncatewords(strip_tags(obj.desc), 10), obj.by)
if isinstance(obj, DocEvent):
title = u"Chartering: %s" % title
return title