Exemplo n.º 1
0
def new(request, slug=None):
    if request.POST:
        form = NewArticleForm(request.POST)
        if form.is_valid():
            slug = request.POST.get('slug')
            article = Article(slug=slug)
            article.save()

            article_content = form.save(commit=False)
            article_content.article = article
            article_content.edited_by = request.user
            article_content.save()
            return HttpResponseRedirect(article_content.get_absolute_url())
    else:
        article_content = None
        if slug:
            slug = slug.upper()
            article_content = ArticleContent(article=Article(slug=slug),
                                             lang=None)
        form = NewArticleForm(instance=article_content)

    return render(request, 'edit.html', {
        'mathjax': True,
        'form': form,
        'title': 'Create compendium',
    })
Exemplo n.º 2
0
def new(request):
    if request.POST:
        form = NewArticleForm(request.POST)
        if form.is_valid():
            slug = request.POST.get('slug')
            article = Article(slug=slug)
            article.save()

            articleContent = form.save(commit=False)
            articleContent.article = article
            articleContent.edited_by = request.user
            articleContent.save()
            return HttpResponseRedirect(articleContent.get_absolute_url())
    else:
        form = NewArticleForm()

    return render(request, 'edit.html', {
        "mathjax": True,
        "form": form,
        "title": "Create article",
    })
Exemplo n.º 3
0
def new(request, slug=None):
    if request.POST:
        form = NewArticleForm(request.POST)
        if form.is_valid():
            slug = request.POST.get("slug")
            article = Article(slug=slug)
            article.save()

            articleContent = form.save(commit=False)
            articleContent.article = article
            articleContent.edited_by = request.user
            articleContent.save()
            return HttpResponseRedirect(articleContent.get_absolute_url())
    else:
        articleContent = None
        if slug:
            slug = slug.upper()
            articleContent = ArticleContent(article=Article(slug=slug), lang=None)
        form = NewArticleForm(instance=articleContent)

    return render(request, "edit.html", {"mathjax": True, "form": form, "title": "Create compendium"})
Exemplo n.º 4
0
def new(request, slug=None):
    if request.POST:
        form = NewArticleForm(request.POST)
        if form.is_valid():
            slug = request.POST.get('slug')
            article = Article(slug=slug)
            article.save()

            article_content = form.save(commit=False)
            article_content.article = article
            article_content.edited_by = request.user
            article_content.save()
            return HttpResponseRedirect(article_content.get_absolute_url())
    else:
        article_content = None
        if slug:
            slug = slug.upper()
            article_content = ArticleContent(article=Article(slug=slug),
                                             lang=None)
        form = NewArticleForm(instance=article_content)

    return render(request, 'edit.html', {
        'mathjax': True,
        'form': form,
        'title': 'Create compendium',
    })
Exemplo n.º 5
0
def new(request):
    if request.POST:
        form = NewArticleForm(request.POST)
        if form.is_valid():
            slug = request.POST.get('slug')
            article = Article(slug=slug)
            article.save()

            articleContent = form.save(commit=False)
            articleContent.article = article
            articleContent.edited_by = request.user
            articleContent.save()
            return HttpResponseRedirect(articleContent.get_absolute_url())
    else:
        form = NewArticleForm()

    return render(request, 'edit.html', {
        "mathjax": True,
        "form": form,
        "title": "Create article",
    })