def cardtype_list(request,cur_page=1,template="admin/config/cardtype/list.tpl"): count = CardType.get_count() if count != 0: page = int(cur_page) cardtype_list = CardType.get_list(page) p = Paginator(page,count,page_size=config.default_page_size) if cardtype_list: return render_response(template,request=request,cardtype_list=cardtype_list,p=p) return render_response(template,request=None,cardtype_list=None,p=None)
def cardtype_edit(request,cardtype_id=0,template="admin/config/cardtype/edit.tpl"): cardtype = CardType.get_by_id(cardtype_id) if request.method == "GET": return render_response(template,cardtype=cardtype) elif request.method == "POST": form = CardTypeForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'] card_type = form.cleaned_data['card_type'] is_unlock = form.cleaned_data['is_unlock'] try: cardtype.name = name cardtype.card_type = card_type cardtype.is_unlock = is_unlock cardtype.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:'cardtype_edit'}).close();</script>")