Ejemplo n.º 1
0
def market_list(request,cur_page=1,template="admin/market/list.tpl"):  
    count = Market.get_count()
    if count != 0:
        page = int(cur_page)
        market_list = Market.get_list(page,config.default_page_size)
        p = Paginator(page,count,page_size=config.default_page_size)
        if market_list:
            return render_response(template,request=request,market_list=market_list,p=p)
    return render_response(template,request=None,market_list=None,p=None)
Ejemplo n.º 2
0
def market_edit(request,market_id=0,template="admin/market/edit.tpl"):
    market = Market.get_by_id(market_id)
    if request.method == "GET":
        return render_response(template,market=market)
    elif request.method == "POST":
        form = MarketForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            e_name = form.cleaned_data['e_name']
            description = form.cleaned_data['description']
            try:
                market.name = name
                market.e_name = e_name
                market.description = description
                market.save()
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'market_edit'}).close();</script>")