示例#1
0
文件: views.py 项目: ogonbat/chano
    def post(self, request, *args, **kwargs):
        #find parent node
        node_parent = Nodes.objects.get(path=request.POST.get('parent'))
        #add new node
        node_add = Nodes()
        node_add.path = request.POST.get('parent')+"/"+slugify(request.POST.get('title'))
        node_add.description = request.POST.get('title')
        node_add.parent = node_parent
        node_add.is_secure = request.POST.get('is_secure',False)
        node_add.is_active = request.POST.get('is_active',False)
        node_add.domain = Domains.objects.get(pk=request.POST.get('domain'))
        node_add.save()

        page_add = Pages()
        page_add.title = request.POST.get('title')
        page_add.slug = slugify(request.POST.get('title'))
        page_add.node=node_add
        page_add.short_description = request.POST.get('short_description')
        page_add.large_description = request.POST.get('large_description','')
        if not request.POST.get('author',False):
            page_add.author_text = request.POST.get('author_text')
        else:
            page_add.author = Accounts.objects.get(pk=request.POST.get('author'))
        page_add.save()
        messages.success(request,_("Page Added"))
        return redirect('/admin/cms')
示例#2
0
文件: views.py 项目: ogonbat/chano
    def post(self, request, *args, **kwargs):
        #find parent node
        node_parent = Nodes.objects.get(path=request.POST.get('parent'))
        #add new node
        node_add = Nodes()
        node_add.path = request.POST.get('parent')+"/"+slugify(request.POST.get('title'))
        node_add.description = request.POST.get('title')
        node_add.parent = node_parent
        node_add.is_secure = request.POST.get('is_secure',False)
        node_add.is_active = request.POST.get('is_active',False)
        node_add.domain = Domains.objects.get(pk=request.POST.get('domain'))
        node_add.save()

        news_add = News()
        news_add.title = request.POST.get('title')
        news_add.slug = request.POST.get('title')
        news_add.node=node_add
        news_add.description = request.POST.get('description')
        news_add.save()
        messages.success(request,_("News Added"))
        return redirect('/admin/cms/news')