Пример #1
0
def manage_sponsor(request):
    if request.method =='POST' and request.POST['button'] == 'Save':
        logging.warning("Existing form:")
        form=SponsorForm(request.POST)
        logging.warning(request.POST)
        logging.warning(str(form))
        if form.is_valid():
            form.save()
    elif request.method =='POST' and request.POST['button'] == 'Delete':
        sponsor_q = Sponsor.all().filter('__key__ =', db.Key(request.POST['sponsor_key']))
        sponsor = sponsor_q.get()
        sponsor.delete()
    elif request.method =='POST' and request.POST['button'] == 'Enable':
        sponsor_q = Sponsor.all().filter('__key__ =', db.Key(request.POST['sponsor_key']))
        sponsor = sponsor_q.get()
        logging.warning(str(sponsor))
        sponsor.active = True
        sponsor.put()
    elif request.method =='POST' and request.POST['button'] == 'Disable':
        sponsor_q = Sponsor.all().filter('__key__ =', db.Key(request.POST['sponsor_key']))
        sponsor = sponsor_q.get()
        sponsor.active = False
        sponsor.put()

    sponsors=Sponsor.all()

    #upcoming=[event for event in upcoming if
    response= render_to_response('eventsite/manage_sponsor.html', locals(), context_instance=RequestContext(request))
    return response
Пример #2
0
def front_page(request, tag=None):
    start=request.site.today
    logging.warning("rendering front page of %s starting %s" % (request.site.name, request.site.today+request.site.tz.utcoffset(request.site.tz)))
    upcoming=Event.all().filter('status = ', 'approved').order('local_start').filter('local_start >= ', start).fetch(30)
    sponsors=Sponsor.all().filter('active =', True).order('order_rank')

    #upcoming=[event for event in upcoming if
    response= render_to_response('eventsite/front-page.html', locals(), context_instance=RequestContext(request))
    response['Cache-Control']="public; max-age=300;"
    return response