def recharge_list(request, cur_page=1, template="admin/mall/recharge/list.tpl"): count = Recharge.get_count() if count != 0: page = int(cur_page) recharge_list = Recharge.get_list(page, config.default_page_size) p = Paginator(page, count, page_size=config.default_page_size) if recharge_list: return render_response(template, request=request, recharge_list=recharge_list, p=p) return render_response(template, request=None, recharge_list=None, p=None)
def recharge_edit(request, recharge_id=0, template="admin/mall/recharge/edit.tpl"): recharge = Recharge.get_by_id(recharge_id) if request.method == "GET": return render_response(template, recharge=recharge) elif request.method == "POST": form = RechargeForm(request.POST) if form.is_valid(): name = form.cleaned_data["name"] # type_id = form.cleaned_data['type_id'] money = form.cleaned_data["money"] rm = form.cleaned_data["rm"] discount = form.cleaned_data["discount"] description = form.cleaned_data["description"] # status = form.cleaned_data['status'] try: recharge.name = name # recharge.type_id = type_id recharge.money = money recharge.rm = rm recharge.discount = discount recharge.description = description # recharge.status = status recharge.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:'recharge_edit'}).close();</script>" )