<s> from django . contrib . syndication . feeds import Feed , FeedDoesNotExist <EOL> from django . utils . feedgenerator import Atom1Feed <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . core . exceptions import ObjectDoesNotExist <EOL> from django . core . urlresolvers import reverse <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from django . http import Http404 <EOL> from django . shortcuts import get_object_or_404 , render_to_response <EOL> from django . template import Context , Template <EOL> from django . template . loader import get_template <EOL> from wiki . models import ChangeSet , Article <EOL> from wiki . utils import get_ct <EOL> import atomformat as atom <EOL> ALL_ARTICLES = Article . objects . all ( ) <EOL> ALL_CHANGES = ChangeSet . objects . all ( ) <EOL> class RssHistoryFeed ( Feed ) : <EOL> title = '<STR_LIT>' <EOL> link = '<STR_LIT>' <EOL> description = '<STR_LIT>' <EOL> def __init__ ( self , request , <EOL> group_slug = None , bridge = None , <EOL> article_qs = ALL_ARTICLES , changes_qs = ALL_CHANGES , <EOL> extra_context = None , <EOL> title_template = u'<STR_LIT>' , <EOL> description_template = u'<STR_LIT>' , <EOL> * args , ** kw ) : <EOL> if group_slug is not None : <EOL> try : <EOL> group = bridge . get_group ( group_slug ) <EOL> except ObjectDoesNotExist : <EOL> raise Http404 <EOL> self . changes_qs = changes_qs . filter ( article__content_type = get_ct ( group ) , <EOL> article__object_id = group . id ) <EOL> else : <EOL> self . changes_qs = changes_qs <EOL> self . title_template = title_template <EOL> self . description_template = description_template <EOL> super ( RssHistoryFeed , self ) . __init__ ( '<STR_LIT>' , request ) <EOL> def items ( self ) : <EOL> return self . changes_qs . order_by ( '<STR_LIT>' ) [ : <NUM_LIT:30> ] <EOL> def item_pubdate ( self , item ) : <EOL> """<STR_LIT>""" <EOL> return item . modified <EOL> class AtomHistoryFeed ( atom . Feed ) : <EOL> feed_title = '<STR_LIT>' <EOL> feed_subtitle = '<STR_LIT>' <EOL> def __init__ ( self , request , <EOL> group_slug = None , bridge = None , <EOL> article_qs = ALL_ARTICLES , changes_qs = ALL_CHANGES , <EOL> extra_context = None , <EOL> title_template = u'<STR_LIT>' , <EOL> description_template = u'<STR_LIT>' , <EOL> * args , ** kw ) : <EOL> if group_slug is not None : <EOL> try : <EOL> group = bridge . get_group ( group_slug ) <EOL> except ObjectDoesNotExist : <EOL> raise Http404 <EOL> self . changes_qs = changes_qs . filter ( article__content_type = get_ct ( group ) , <EOL> article__object_id = group . id ) <EOL> else : <EOL> self . changes_qs = changes_qs <EOL> self . title_template = get_template ( title_template ) <EOL> self . description_template = get_template ( description_template ) <EOL> super ( AtomHistoryFeed , self ) . __init__ ( '<STR_LIT>' , request ) <EOL> def feed_id ( self ) : <EOL> return "<STR_LIT>" <EOL> def items ( self ) : <EOL> return self . changes_qs . order_by ( '<STR_LIT>' ) [ : <NUM_LIT:30> ] <EOL> def item_id ( self , item ) : <EOL> return "<STR_LIT:%s>" % item . id <EOL> def item_title ( self , item ) : <EOL> c = Context ( { '<STR_LIT>' : item } ) <EOL> return self . title_template . render ( c ) <EOL> def item_updated ( self , item ) : <EOL> return item . modified <EOL> def item_authors ( self , item ) : <EOL> if item . is_anonymous_change ( ) : <EOL> return [ { '<STR_LIT:name>' : _ ( '<STR_LIT>' ) } , ] <EOL> return [ { '<STR_LIT:name>' : item . editor . username } , ] <EOL> def item_links ( self , item ) : <EOL> return [ { '<STR_LIT>' : item . get_absolute_url ( ) } , ] <EOL> def item_content ( self , item ) : <EOL> c = Context ( { '<STR_LIT>' : item , } ) <EOL> return ( { '<STR_LIT:type>' : '<STR_LIT:html>' } , self . description_template . render ( c ) ) <EOL> class RssArticleHistoryFeed ( Feed ) : <EOL> def __init__ ( self , title , request , <EOL> group_slug = None , bridge = None , <EOL> article_qs = ALL_ARTICLES , changes_qs = ALL_CHANGES , <EOL> extra_context = None , <EOL> title_template = u'<STR_LIT>' , <EOL> description_template = u'<STR_LIT>' , <EOL> * args , ** kw ) : <EOL> if group_slug is not None : <EOL> try : <EOL> group = bridge . get_group ( group_slug ) <EOL> except ObjectDoesNotExist : <EOL> raise Http404 <EOL> self . article_qs = article_qs . filter ( content_type = get_ct ( group ) , <EOL> object_id = group . id ) <EOL> else : <EOL> self . article_qs = article_qs <EOL> self . title_template = title_template <EOL> self . description_template = description_template <EOL> super ( RssArticleHistoryFeed , self ) . __init__ ( title , request ) <EOL> def get_object ( self , bits ) : <EOL> return self . article_qs . get ( title = bits [ <NUM_LIT:0> ] ) <EOL> def title ( self , obj ) : <EOL> return "<STR_LIT>" % obj . title <EOL> def link ( self , obj ) : <EOL> if not obj : <EOL> raise FeedDoesNotExist <EOL> return obj . get_absolute_url ( ) <EOL> def description ( self , obj ) : <EOL> return "<STR_LIT>" % obj . title <EOL> def items ( self , obj ) : <EOL> return ChangeSet . objects . filter ( article__id__exact = obj . id ) . order_by ( '<STR_LIT>' ) [ : <NUM_LIT:30> ] <EOL> def item_pubdate ( self , item ) : <EOL> """<STR_LIT>""" <EOL> return item . modified <EOL> class AtomArticleHistoryFeed ( atom . Feed ) : <EOL> def __init__ ( self , title , request , <EOL> group_slug = None , bridge = None , <EOL> article_qs = ALL_ARTICLES , changes_qs = ALL_CHANGES , <EOL> extra_context = None , <EOL> title_template = u'<STR_LIT>' , <EOL> description_template = u'<STR_LIT>' , <EOL> * args , ** kw ) : <EOL> if group_slug is not None : <EOL> try : <EOL> group = bridge . get_group ( group_slug ) <EOL> except ObjectDoesNotExist : <EOL> raise Http404 <EOL> self . article_qs = article_qs . filter ( content_type = get_ct ( group ) , <EOL> object_id = group . id ) <EOL> else : <EOL> self . article_qs = article_qs <EOL> self . title_template = get_template ( title_template ) <EOL> self . description_template = get_template ( description_template ) <EOL> super ( AtomArticleHistoryFeed , self ) . __init__ ( '<STR_LIT>' , request ) <EOL> def get_object ( self , bits ) : <EOL> return self . article_qs . get ( title = bits [ <NUM_LIT:0> ] ) <EOL> def feed_title ( self , obj ) : <EOL> return "<STR_LIT>" % obj . title <EOL> def feed_subtitle ( self , obj ) : <EOL> return "<STR_LIT>" % obj . title <EOL> def feed_id ( self ) : <EOL> return "<STR_LIT>" <EOL> def items ( self , obj ) : <EOL> return ChangeSet . objects . filter ( article__id__exact = obj . id ) . order_by ( '<STR_LIT>' ) [ : <NUM_LIT:30> ] <EOL> def item_id ( self , item ) : <EOL> return "<STR_LIT:%s>" % item . id <EOL> def item_title ( self , item ) : <EOL> c = Context ( { '<STR_LIT>' : item } ) <EOL> return self . title_template . render ( c ) <EOL> def item_updated ( self , item ) : <EOL> return item . modified <EOL> def item_authors ( self , item ) : <EOL> if item . is_anonymous_change ( ) : <EOL> return [ { '<STR_LIT:name>' : _ ( '<STR_LIT>' ) } , ] <EOL> return [ { '<STR_LIT:name>' : item . editor . username } , ] <EOL> def item_links ( self , item ) : <EOL> return [ { '<STR_LIT>' : item . get_absolute_url ( ) } , ] <EOL> def item_content ( self , item ) : <EOL> c = Context ( { '<STR_LIT>' : item , } ) <EOL> return ( { '<STR_LIT:type>' : '<STR_LIT:html>' } , self . description_template . render ( c ) ) </s>
