Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
 def test_multiple_args_mixed(self):
     test = [u'with-däsh', 'ascii-with-dash', u'with_ünderscore', 'ascii_with_underscore']
     expected = [u'With d\xe4sh', u'Ascii with dash', u'With \xfcnderscore', u'Ascii with underscore']
     result = unslugify(*test)
     self.assertEqual(result, expected)
Exemplo n.º 4
0
 def test_non_slug(self):
     test = u'My stupid monkey from Mönchengladbach'
     expected = u'My stupid monkey from mönchengladbach'
     result = unslugify(test)
     self.assertEqual(result, expected)
Exemplo n.º 5
0
 def test_unicode_dash_underscores_mixed(self):
     test = u'my_stupid-monkey-from_mönchengladbach'
     expected = u'My stupid monkey from mönchengladbach'
     result = unslugify(test)
     self.assertEqual(result, expected)
Exemplo n.º 6
0
 def test_unicode_slug_to_pretty_text(self):
     test = u'my-stupid-monkey-from-mönchengladbach'
     expected = u'My stupid monkey from mönchengladbach'
     result = unslugify(test)
     self.assertEqual(result, expected)
Exemplo n.º 7
0
 def test_ascii_slug_to_pretty_text(self):
     test = 'my-stupid-monkey'
     expected = 'My stupid monkey'
     result = unslugify(test)
     self.assertEqual(result, expected)