当前位置: 首页>>代码示例>>Python>>正文


Python Page.save方法代码示例

本文整理汇总了Python中models.Page.save方法的典型用法代码示例。如果您正苦于以下问题:Python Page.save方法的具体用法?Python Page.save怎么用?Python Page.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Page的用法示例。


在下文中一共展示了Page.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: edit

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def edit(request, name):
    """Allows users to edit wiki pages."""
    try:
        page = Page.objects.get(name=name)
    except Page.DoesNotExist:
        page = None

    if request.method == "POST":
        form = PageForm(request.POST)
        if form.is_valid():
            if not page:
                page = Page()
            page.name = form.cleaned_data["name"]
            page.content = form.cleaned_data["content"]

            page.save()
            return HttpResponseRedirect("../../%s/" % page.name)
    else:
        if page:
            form = PageForm(initial=page.__dict__)
        else:
            form = PageForm(initial={"name": name})

    return render_to_response(
        "wiki/edit.html",
        {
            "form": form,
            "admin": is_admin(request),
            "user": get_user(request),
            "navbar": Page.objects.get(name="NavBar"),
        },
    )
开发者ID:victorusachev,项目名称:djangy,代码行数:34,代码来源:views.py

示例2: contentapp

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def contentapp(request,resourceName):
	response = "<h1> WELLCOME TO THE JUNGLE! </h1>"
	if request.method == "GET":
		try:
			info = Page.objects.get(name=resourceName)
			return HttpResponse(response + info.contenido)
		except Page.DoesNotExist:
			response += '<body> Valor no encontrado, definalo </body>'
			form = "<form action='' method='POST'>\n"
			form += "Nombre: <input type='text' name='name' value='" + resourceName + "'><br>\n"
			form += "Contenido: <input type='text' name='contenido'><br>\n"
			form += "<input type='submit' value='enviar'>\n"
			form += "</form>\n"
			response += form
			return HttpResponse(response)
	elif request.method == "POST":
		response += '<body> POST </body>' 
		newPage = Page(name=request.POST['name'], contenido=request.POST['contenido'])
		newPage.save()
		response += "Nombre: " + request.POST['name'] 
		response += ", Contenido: " + request.POST['contenido']
		return HttpResponse(response)
	else:
		response += '<body> No way </body>'
		return HttpResponse(response)
开发者ID:alexeal90,项目名称:X-Serv-15.6-Django-CMS_PUT,代码行数:27,代码来源:views.py

示例3: edit

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def edit(request, name):
    """Allows users to edit wiki pages."""
    try:
        page = Page.objects.get(name=name)
    except Page.DoesNotExist:
        page = None

    if request.method == 'POST':
        form = PageForm(request.POST)
        if form.is_valid():
            if not page:
                page = Page()
            page.name = form.cleaned_data['name']
            page.content = form.cleaned_data['content']

            page.save()
            return redirect(view, name=page.name)
    else:
        if page:
            form = PageForm(initial=page.__dict__)
        else:
            form = PageForm(initial={'name': name})

    context = {
        'form': form,
    }

    return render_to_response('wiki/edit.html',
        RequestContext(request, context))
开发者ID:zouf,项目名称:AllSortz,代码行数:31,代码来源:views.py

示例4: processCmsRequest

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def processCmsRequest(request, resource):
    if request.user.is_authenticated():
        loged = "<br><br>Logged in as " + request.user.username +\
                ". <a href='/admin/logout/'>Logout</a><br>"
    else:
        loged = "<br><br>Not logged. <a href='/admin/login/'>Login</a><br>"
    if request.method == 'GET':
        try:
            page = Page.objects.get(name=resource)
            return HttpResponse(page.page + loged)
        except Page.DoesNotExist:
            return HttpResponseNotFound("Page not found" + loged)
    elif request.method == 'PUT':
        if request.user.is_authenticated():
            try:
                newPage = Page.objects.get(name=resource)
                newPage.page = request.body
            except Page.DoesNotExist:
                newPage = Page(name = resource, page = request.body)
            newPage.save()
            return HttpResponse("Added to the list")
        else:
            return HttpResponse("Couldn't add to the list" + loged)
    else:
        return HttpResponse(status=403)
开发者ID:reysam93,项目名称:X-Serv-15.8-CmsUsersPut,代码行数:27,代码来源:views.py

示例5: edit

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def edit(request, name):
    """Allows users to edit wiki pages."""
    try:
        page = Page.objects.get(name=name)
    except Page.DoesNotExist:
        page = None

    if request.method == 'POST':
        form = PageForm(request.POST)
        if form.is_valid():
            if not page:
                page = Page()
            page.name = form.cleaned_data['name']
            page.save()

            revision = Revision()
            revision.page = page
            revision.content = form.cleaned_data['content']
            if request.user.is_authenticated():
                revision.editor = request.user
            revision.save()
            return HttpResponseRedirect(page.get_absolute_url())
    else:
        if page:
            revision = page.get_latest_revision()
            form = PageForm(initial={'name': page.name, 'content': revision.content})
        else:
            form = PageForm(initial={'name': name})

    ctx = { 'form': form }
    return render_to_response('wiki/edit.html', ctx, context_instance=RequestContext(request))
开发者ID:exoanalytic,项目名称:django-wiki,代码行数:33,代码来源:views.py

示例6: testBlogPaginate

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
    def testBlogPaginate(self):
        """Test view and template of a paginated blog
        Must have :
            - "Previous" link
            - "Next" link
            - Antichronological order

        """
        # Populate blog with temporary content
        temp = []
        for i in range(30):
            a = Page(title="temp_%s" % i, slug="temp-%s" % i, parent=self.blog21, folder_type=0, publish_state=Page.PUBLISHED )
            a.save()
            temp += [a]
        # Test Page 1
        response = self.client.get(urlblog('categ_2-fr/blog_21-fr', 1))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, temp[29].get_title())
        self.assertContains(response, urlblog('categ_2-fr/blog_21-fr', 2)) # Previous link
        self.assertNotContains(response, temp[1].get_title())
        # Test page 3
        response = self.client.get(urlblog('categ_2-fr/blog_21-fr', 3))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, urlblog('categ_2-fr/blog_21-fr', 2)) # Previous link
        self.assertContains(response, urlblog('categ_2-fr/blog_21-fr', 4)) # Next Link
        self.assertNotContains(response, temp[29].get_title())
        self.assertContains(response, temp[19].get_title())
开发者ID:bearstech,项目名称:OursID,代码行数:29,代码来源:tests.py

示例7: test_page_app_name_after_save

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
 def test_page_app_name_after_save(self):
     p = Page()
     p.save()
     self.assertEqual(p.app_model, 'pages.Page',
                      'Value for app_model is not correct after save.')
     self.assertEqual(p.get_app_model(), 'pages.Page',
                      'Value for get_app_model() is not correct after save.')
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:9,代码来源:tests.py

示例8: addPage

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def addPage(name, content):
    try:
        newPage = Page.objects.get(name=name)
        newPage.page = content
    except Page.DoesNotExist:
        newPage = Page(name = name, page = content)
    newPage.save()
开发者ID:reysam93,项目名称:X-Serv-CSS-Elaborado,代码行数:9,代码来源:views.py

示例9: page_edit_about

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def page_edit_about(request):
    shop = request.shop
    static_pages = Page.objects.filter(shop=shop)
    dynamic_pages = DynamicPageContent.objects.filter(shop=shop)
    try:
        about = About.objects.filter(shop=shop).get()
    except About.DoesNotExist:
        about = Page(shop=shop)
        about.save()

    if request.method == "POST":
        form = AboutForm(request.POST)
        if form.is_valid():
            about.title = form.cleaned_data['title']
            about.body = form.cleaned_data['body']
            about.meta_content = form.cleaned_data['meta_content']
            about.save()
            request.flash['message'] = unicode(_("Page successfully saved."))
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse('page_edit_about'))
    else:
        form = AboutForm(instance=about)

    return render_to_response('store_admin/web_store/pages_edit_about.html',
                              {'form': form, 'static_pages': static_pages, 'dynamic_pages': dynamic_pages},
                              RequestContext(request))
开发者ID:HengWang,项目名称:CollectorCity-Market-Place,代码行数:28,代码来源:views.py

示例10: edit

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def edit(request, slug):
    params = {"slug": slug}
    page = get_or_none(Page, slug=slug)

    text = page.current_revision.text if page and page.current_revision else ""
    form = EditForm(data=request.POST or None, initial={"text": text})

    if request.method == "POST" and form.is_valid():
        if not page:
            page = Page(title=unslugify(slug), slug=slug)
            page.save()
        form.save(page, request.user)
        return redirect(reverse("wiki-detail", kwargs={"slug": page.slug}))

    params["form"] = form
    if page:
        params["action"] = "Edit"
        params["title"] = page.title
        params["modified"] = page.modified_on
        params["action"] = "Edit"
    else:
        params["title"] = unslugify(slug)
        params["modified"] = "NULL"
        params["action"] = "Create"

    return render(request, "edit.html", params)
开发者ID:Corea,项目名称:algospot,代码行数:28,代码来源:views.py

示例11: test_page_content_ptr_app_name

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
 def test_page_content_ptr_app_name(self):
     p = Page()
     p.save()
     c = p.content_ptr
     self.assertEqual(c.app_model, 'pages.Page',
                      'Value for content.app_model is not correct.')
     self.assertEqual(c.get_app_model(), 'pages.Page',
                      'Value for get_app_model() is not correct after save.')
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:10,代码来源:tests.py

示例12: page_update_or_create

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def page_update_or_create(name, content):
    """Update or create a Wiki Page"""
    try:
        p = Page.objects.get(name=name)
    except Page.DoesNotExist:
        p = Page(name=name)
    finally:
        p.content = content
        p.save()
开发者ID:honestappalachia,项目名称:honestappalachia,代码行数:11,代码来源:views.py

示例13: addPage

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def addPage(resource, body):
    try:
        Page.objects.get(name=resource)
        salida = "That page was in the server"
    except Page.DoesNotExist:
        newpage = Page(name=resource, page=body)
        newpage.save()
        salida = "New page added"
    return salida
开发者ID:jjmerchante,项目名称:X-Serv-CSS-Elaborado,代码行数:11,代码来源:views.py

示例14: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
 def post(self):
     if not (session and session.get('uid')):
         return jsonify({'error': 'Not logged in'})
     page = Page(slug=request.form['slug'])
     page.url = request.form['url']
     page.author = User.objects(id=ObjectId(session.get('uid')))
     page.save()
     node = Node.objects(id=ObjectId(request.form['nid']))[0]
     nodes.pages.append(page)
     node.save(cascade=True)
     
 	return jsonify({'success':1})
开发者ID:ArchanPatel890,项目名称:SpaceBubbles,代码行数:14,代码来源:api.py

示例15: show_pages

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import save [as 别名]
def show_pages():
    if request.method == "POST" and g.site.domain == g.user:
        name = request.form['name']
        if name:
            p = Page()
            p.name = name
            p.slug = slugify(name)
            p.site = g.site.domain
            p.save()
            return redirect(url_for(".edit_page", slug=p.slug))
    pages = Page.objects(site=g.site.domain)
    return render_template('pages.html', pages=pages)
开发者ID:abal09,项目名称:samklang,代码行数:14,代码来源:pages.py


注:本文中的models.Page.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。