Ejemplo n.º 1
0
def group_article_create_body(request, pk):
    if request.user.is_authenticated:
        try:
            gid = request.session['gid']
        except:
            return redirect('home')
        try:
            status = request.session['status']
        except:
            return redirect('home')
        article = Articles.objects.get(pk=pk)
        group = Group.objects.get(pk=gid)
        if request.method == 'POST':
            if article.creation_complete:
                article.body = getHTML(article)
                article.save()
                del request.session['gid']
                del request.session['status']
                return redirect('article_view', article.pk)
            else:
                return redirect('group_article_create_body', article.pk)
        else:
            article.creation_complete = True
            article.save()
            return render(
                request, 'new_article_body.html', {
                    'article': article,
                    'group': group,
                    'status': int(status),
                    'url': settings.SERVERURL,
                    'articleof': 'group'
                })

    else:
        return redirect('login')
def community_article_create_body(request, article, community):
    if request.user.is_authenticated:
        if request.method == 'POST':
            article.body = getHTML(article)
            article.save()
            data = {'article_id': article.pk, 'body': article.body}
            return JsonResponse(data)
            # return redirect('article_view', article.pk)
            # else:
            # 	article.creation_complete = True
            # 	article.save()
            # 	return render(request, 'new_article_body.html', {'article':article,'community':community, 'status':2, 'url':settings.SERVERURL, 'articleof':'community'})
        else:
            return redirect('home')
    else:
        return redirect('login')