def GetContext(self, **kwargs): cid = int(kwargs.get("cid", 0)) action = self.GetGetData("action", "edit") if action == "edit": if cid > 0: catInfo = self.GetCat(cid) if catInfo is None: self.message = "分类不存在" self.SetTemplateName("message") self.redirectUrl = "/admin/catlist/" self.autoRedirect = False return locals() else: catInfo = Category() catTree = "var data=Array();" catTree += self.BuildCatTreeJs(0, -1, cid) self.SetTemplateName("cat") else: if action == "delete": catInfo = self.GetCat(cid) if catInfo is not None: Category.objects.filter(id=cid).delete() Category.objects.filter(parent_id=cid).update( parent_id=catInfo.parent_id) self.redirectUrl = "/admin/catlist/" return locals()
def category(request, action="", cid=-1): viewsTopArticles = common.viewsTopArticles() remarkTopArticles = common.remarkTopArticles() newTopArticles = common.newTopArticles() categoryList = common.categoryList() if request.POST.has_key('ok'): name = request.POST['name'] if cid != -1: categoryInfo = Category(name=name) else: categoryInfo = Category.objects.get(id=cid) categoryInfo.name = name categoryInfo.save() return HttpResponseRedirect('/') else: return my_render_to_response(request, "category.html", locals())
def category(request,action="",cid=-1): viewsTopArticles=common.viewsTopArticles() remarkTopArticles=common.remarkTopArticles() newTopArticles=common.newTopArticles() categoryList=common.categoryList() if request.POST.has_key('ok'): name = request.POST['name'] if cid!=-1: categoryInfo=Category(name=name) else: categoryInfo=Category.objects.get(id=cid) categoryInfo.name=name categoryInfo.save() return HttpResponseRedirect('/') else: return my_render_to_response(request,"category.html",locals())
def add(request): uid=int(-1) userInfos=common.Users(request,uid) currentUser=userInfos["currentuser"] name=utility.GetPostData(request,"name") sortnum=utility.GetPostData(request,"sortnum") if request.POST.has_key('ok'): categoryInfo=Category() categoryInfo.name=name categoryInfo.sortnum=sortnum categoryInfo.user_id=currentUser.id categoryInfo.save() return HttpResponseRedirect(categoryroot %currentUser.id)
def PostContext(self, **kwargs): uid=int(kwargs.get("uid",0)) if self.HasPostData('ok'): name=self.GetPostData("name") sortnum=self.GetPostData("sortnum") isnav=self.GetPostData("isnav",False) categoryInfo=Category() categoryInfo.name=name categoryInfo.sortnum=sortnum categoryInfo.save() return locals()
def PostContext(self, **kwargs): if self.HasPostData('ok'): cid=int(kwargs.get("cid",0)) parentId=self.GetPostData("parentId",0) name=self.GetPostData("name") alias=self.GetPostData("alias") sortnum=self.GetPostData("sortnum",0) template=self.GetPostData("template","normal") sidebar=self.GetPostData("sidebar","normal") sidebarfloat=self.GetPostData("sidebarfloat","none") catInfo=self.GetCat(cid) if catInfo is None: catInfo=Category() catInfo.parent_id=parentId catInfo.name=name catInfo.alias=alias catInfo.sortnum=0 if sortnum=="" else sortnum catInfo.articles=0 catInfo.template=template catInfo.sidebar=sidebar catInfo.sidebarfloat=sidebarfloat catInfo.save() self.redirectUrl="/admin/catlist" return locals()
def PostContext(self, **kwargs): if self.HasPostData('ok'): parentId=self.GetPostData("parentId",0) name=self.GetPostData("name") alias=self.GetPostData("alias",name) sortnum=utility.ToInt(self.GetPostData("sortnum")) template=self.GetPostData("template","normal") sidebar=self.GetPostData("sidebar","normal") sidebarfloat=self.GetPostData("sidebarfloat","none") catInfo=Category() catInfo.parent_id=parentId catInfo.name=name catInfo.alias=alias catInfo.sortnum=0 if sortnum=="" else sortnum catInfo.articles=0 catInfo.template=template catInfo.sidebar=sidebar catInfo.sidebarfloat=sidebarfloat catInfo.save() if self.HasPostData("okSort"): for key,value in self.request.POST.items(): if key.find("item_sortnum_")==0: dot=key.rfind("_") catId=key[dot+1:] Category.objects.filter(id=catId).update(sortnum=utility.ToInt(value,0)) return locals()
def PostContext(self, **kwargs): if self.HasPostData('ok'): cid = int(kwargs.get("cid", 0)) parentId = self.GetPostData("parentId", 0) name = self.GetPostData("name") alias = self.GetPostData("alias") sortnum = self.GetPostData("sortnum", 0) template = self.GetPostData("template", "normal") sidebar = self.GetPostData("sidebar", "normal") sidebarfloat = self.GetPostData("sidebarfloat", "none") catInfo = self.GetCat(cid) if catInfo is None: catInfo = Category() catInfo.parent_id = parentId catInfo.name = name catInfo.alias = alias catInfo.sortnum = 0 if sortnum == "" else sortnum catInfo.articles = 0 catInfo.template = template catInfo.sidebar = sidebar catInfo.sidebarfloat = sidebarfloat catInfo.save() self.redirectUrl = "/admin/catlist" return locals()
def PostContext(self, **kwargs): if self.HasPostData('ok'): parentId = self.GetPostData("parentId", 0) name = self.GetPostData("name") alias = self.GetPostData("alias", name) sortnum = utility.ToInt(self.GetPostData("sortnum")) template = self.GetPostData("template", "normal") sidebar = self.GetPostData("sidebar", "normal") sidebarfloat = self.GetPostData("sidebarfloat", "none") catInfo = Category() catInfo.parent_id = parentId catInfo.name = name catInfo.alias = alias catInfo.sortnum = 0 if sortnum == "" else sortnum catInfo.articles = 0 catInfo.template = template catInfo.sidebar = sidebar catInfo.sidebarfloat = sidebarfloat catInfo.save() if self.HasPostData("okSort"): for key, value in self.request.POST.items(): if key.find("item_sortnum_") == 0: dot = key.rfind("_") catId = key[dot + 1:] Category.objects.filter(id=catId).update( sortnum=utility.ToInt(value, 0)) return locals()