def good_list(request, cur_page=1, template="admin/mall/good/list.tpl"): count = Good.get_count() if count != 0: page = int(cur_page) good_list = Good.get_list(page, config.default_page_size) p = Paginator(page, count, page_size=config.default_page_size) if good_list: return render_response(template, request=request, good_list=good_list, p=p) return render_response(template, request=None, good_list=None, p=None)
def good_edit(request, good_id=0, template="admin/mall/good/edit.tpl"): good = Good.get_by_id(good_id) if request.method == "GET": return render_response(template, good=good) elif request.method == "POST": form = GoodForm(request.POST) if form.is_valid(): name = form.cleaned_data["name"] type_id = form.cleaned_data["type_id"] vm = form.cleaned_data["vm"] rm = form.cleaned_data["rm"] discount = form.cleaned_data["discount"] description = form.cleaned_data["description"] image = form.cleaned_data["image"] is_new = form.cleaned_data["is_new"] is_hot = form.cleaned_data["is_hot"] is_unlock = form.cleaned_data["is_unlock"] try: good.name = name good.type_id = type_id good.vm = vm good.rm = rm good.discount = discount good.description = description good.image = image good.is_new = is_new good.is_hot = is_hot good.is_unlock = is_unlock good.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:'good_edit'}).close();</script>" )