Beispiel #1
0
def main_page_view(request, key):
    banner = MainPageBanner.get(key)
    form = MainPageBannerEditForm()
    if request.method == 'POST' and form.validate(request.form):
        banner.name = form['name']
        banner.desc = form['desc']
        banner.url = form['url']
        banner.put()
        return redirect('/banner/admin/main_page/')
    form = MainPageBannerEditForm(instance=banner)
    return render_to_response('banner/admin/main_page_view.html', {'form':form.as_widget(),'banner':banner})
Beispiel #2
0
def main_page(request):
    form = MainPageBannerForm()
    if request.method == 'POST' and form.validate(request.form, request.files):
        raw_img = form['raw_img']
        name = form['name']
        if not name:
            name = ''
        url = form['url']
        desc = form['desc']
        if not desc:
            desc = ''
        thumb_img = ThumbImage()
        thumb_img.add_new_thumb(blob_img=raw_img, thumb_size=(960, 400),
                                    title=name, content_type='image/png')
        thumb_img.add_new_thumb(blob_img=raw_img, thumb_size=(192, 80),
                                    title=name, content_type='image/png')
        thumb_img.put()
        banner = MainPageBanner(name=name, url=url, desc=desc, img = thumb_img)
        banner.put()
        form = MainPageBannerForm()
    banners = MainPageBanner.all()
    return render_to_response('banner/admin/main_page.html', {'banners':banners, 'form':form.as_widget()})
Beispiel #3
0
def index(request):
    gifts_list = Gift.all().order('-rating')
    gifts_list = filter_leftovers(gifts_list)
    paginator = Paginator(gifts_list, 24)
    banners = MainPageBanner.all()
    try:
        page = int(request.args.get('page', 1))
    except ValueError:
        page = 1
    try:
        gifts = paginator.page(page)
    except (EmptyPage, InvalidPage):
        gifts = paginator.page(paginator.num_pages())
    categories = get_cat_subcat()
    return render_to_response('index_page/main_page.html',
            {'gifts': gifts,
             'banners': banners,
             'categories': categories[0],
             'subcategories': categories[1],
             'subcategories_keys': categories[2],
             'price_modif': GlobalPriceModif.get_price_modif()})
Beispiel #4
0
def main_page_delete(request, key):
    banner = MainPageBanner.get(key)
    if banner:
        banner.delete()
    return redirect('/banner/admin/main_page/')