<s> from django import http <EOL> from django . utils . translation import ugettext as _ <EOL> from olympia . amo . helpers import absolutify , page_name <EOL> from olympia . amo . urlresolvers import reverse <EOL> from olympia . amo . feeds import NonAtomicFeed <EOL> from olympia . access import acl <EOL> from olympia . addons . models import Addon <EOL> from olympia . browse . feeds import AddonFeedMixin <EOL> from . import views <EOL> class CollectionFeedMixin ( NonAtomicFeed ) : <EOL> """<STR_LIT>""" <EOL> def item_link ( self , c ) : <EOL> return absolutify ( c . get_url_path ( ) ) <EOL> def item_title ( self , c ) : <EOL> return unicode ( c . name or '<STR_LIT>' ) <EOL> def item_description ( self , c ) : <EOL> return unicode ( c . description or '<STR_LIT>' ) <EOL> def item_author_name ( self , c ) : <EOL> return c . author_username <EOL> def item_pubdate ( self , c ) : <EOL> sort = self . request . GET . get ( '<STR_LIT>' ) <EOL> return c . created if sort == '<STR_LIT>' else c . modified <EOL> class CollectionFeed ( CollectionFeedMixin , NonAtomicFeed ) : <EOL> request = None <EOL> def get_object ( self , request ) : <EOL> self . request = request <EOL> def title ( self , c ) : <EOL> app = page_name ( self . request . APP ) <EOL> return _ ( u'<STR_LIT>' ) % app <EOL> def link ( self ) : <EOL> return absolutify ( reverse ( '<STR_LIT>' ) ) <EOL> def description ( self ) : <EOL> return _ ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> def items ( self ) : <EOL> return views . get_filter ( self . request ) . qs [ : <NUM_LIT:20> ] <EOL> class CollectionDetailFeed ( AddonFeedMixin , NonAtomicFeed ) : <EOL> def get_object ( self , request , username , slug ) : <EOL> self . request = request <EOL> c = views . get_collection ( request , username , slug ) <EOL> if not ( c . listed or acl . check_collection_ownership ( request , c ) ) : <EOL> raise http . Http404 ( ) <EOL> return c <EOL> def title ( self , c ) : <EOL> app = page_name ( self . request . APP ) <EOL> return _ ( u'<STR_LIT>' ) . format ( c . name , app ) <EOL> def link ( self , c ) : <EOL> return absolutify ( c . feed_url ( ) ) <EOL> def description ( self , c ) : <EOL> return c . description <EOL> def items ( self , c ) : <EOL> addons = Addon . objects . valid ( ) & c . addons . all ( ) <EOL> return addons . order_by ( '<STR_LIT>' ) [ : <NUM_LIT:20> ] </s>
