Ejemplo n.º 1
0
def publish(request):
    login_value = get_login_value(request)
    if login_value['state'] == 2:
        return HttpResponseRedirect("../home")
    if request.method == 'POST':
        article = Article()
        article.title = request.POST['title']
        article.category = request.POST['category']
        article.introduction = request.POST['description']
        html = request.POST['markdown'].replace('&nbsp;', ' ').replace('\\n', '\n').replace('&lt;', '<').replace('&gt;',
                                                                                                                 '>')
        html = append_script(html)
        article.content = html
        article.save()
        return HttpResponseRedirect("../user")
    else:
        return HttpResponseRedirect("../home")
Ejemplo n.º 2
0
def publish(request):
    logging_status = get_logging_status(request)
    if logging_status['login_state'] == BLOGSETTING.UNLOGGED:
        return HttpResponseRedirect("../home")
    if request.method == 'POST':
        article = Article()
        article.title = request.POST['title']
        article.category = request.POST['category']
        article.introduction = request.POST['description']
        html = request.POST['html'].replace('&nbsp;', ' ').replace('\\n', '\n') \
            .replace('&lt;', '<').replace('&gt;', '>')
        html = append_script(html)

        markdown = request.POST['markdown'].replace('&nbsp;', ' ').replace('\\n', '\n') \
            .replace('&lt;', '<').replace('&gt;', '>')
        article.markdown = markdown
        article.content = html
        article.save()
        return HttpResponseRedirect("../user")
    else:
        return HttpResponseRedirect("../home")