<s> import datetime <EOL> from django . contrib . auth . decorators import user_passes_test <EOL> from django . core import urlresolvers <EOL> from django . http import Http404 <EOL> from django . shortcuts import get_object_or_404 , render_to_response <EOL> from payment . config import credit_choices <EOL> from product . models import Product , Category <EOL> from satchmo_store . shop . models import Config <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> @ user_passes_test ( lambda u : u . is_authenticated ( ) and u . is_staff , login_url = '<STR_LIT>' ) <EOL> def admin_product_feed ( request , category = None , template = "<STR_LIT>" , mimetype = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> return product_feed ( request , category = category , template = template , mimetype = mimetype ) <EOL> def product_feed ( request , category = None , template = "<STR_LIT>" , mimetype = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> shop_config = Config . objects . get_current ( ) <EOL> if category : <EOL> try : <EOL> cat = Category . objects . active ( ) . get ( slug = category ) <EOL> products = cat . active_products ( ) <EOL> except Category . DoesNotExist : <EOL> raise Http404 , _ ( "<STR_LIT>" % category ) <EOL> else : <EOL> cat = None <EOL> products = Product . objects . active_by_site ( ) <EOL> products = filter ( lambda product : "<STR_LIT>" not in product . get_subtypes ( ) , products ) <EOL> params = { } <EOL> view = '<STR_LIT>' <EOL> if category : <EOL> params [ '<STR_LIT>' ] = category <EOL> view = '<STR_LIT>' <EOL> url = shop_config . base_url + urlresolvers . reverse ( view , None , params ) <EOL> payment_choices = [ c [ <NUM_LIT:1> ] for c in credit_choices ( None , True ) ] <EOL> return render_to_response ( template , { <EOL> '<STR_LIT>' : products , <EOL> '<STR_LIT>' : cat , <EOL> '<STR_LIT:url>' : url , <EOL> '<STR_LIT>' : shop_config , <EOL> '<STR_LIT>' : payment_choices , <EOL> '<STR_LIT:date>' : datetime . datetime . now ( ) , <EOL> } , <EOL> mimetype = mimetype ) </s>
