Ejemplo n.º 1
0
def import_post(user, import_item):
    title = import_item.title
    if not title:
        title = "(Noname)"
    post = Post(author=user, title=title, tease=import_item.description,
        body=import_item.text, rating=create_rating())
    post.save()
    return 'http://url'
Ejemplo n.º 2
0
def post_add(request, form_class=PostForm, template_name="blog/post_add.html"):
    post_form = form_class(request)
    if request.method == "POST" and post_form.is_valid():
        post = post_form.save(commit=False)
        post.author = request.user
        post.rating = create_rating()
        creator_ip = request.META.get('HTTP_X_FORWARDED_FOR', None)
        if not creator_ip:
            creator_ip = request.META.get('REMOTE_ADDR', None)
        post.creator_ip = creator_ip
        post.save()
        messages.success(request, _("Successfully created post '%s'") % post.title)
        return redirect("blog_user_post_detail", username=request.user.username, slug=post.slug)
    return TemplateResponse(request, template_name, {'post_form': post_form, 'current_user': request.user})
Ejemplo n.º 3
0
def post_add(request, form_class=PostForm, template_name="socialblog/post_add.html"):
    post_form = form_class(request)
    if request.method == "POST" and post_form.is_valid():
        post = post_form.save(commit=False)
        post.author = request.user
        post.rating = create_rating()
        post.creator_ip = get_client_ip(request)
        post.save()
        messages.success(request, _(u"Successfully created post '%s'") % post.title)

        return redirect(post.get_absolute_url())

    return TemplateResponse(request, template_name, \
        {'post_form': post_form, 'current_user': request.user})
Ejemplo n.º 4
0
def import_post(user, import_item):
    title = import_item.title
    if not title:
        title = "(Noname)"
    kwargs = {
        'author': user,
        'title': title,
        'tease': import_item.description,
        'body': import_item.text
    }
    if 'voter' in settings.INSTALLED_APPS:
        kwargs['rating'] = create_rating()
    post = Post(**kwargs)
    post.save()
    return 'http://url'
Ejemplo n.º 5
0
def import_post(user, import_item):
    title = import_item.title
    if not title:
        title = "(Noname)"
    kwargs = {
        'author': user, 
        'title': title, 
        'tease': import_item.description,
        'body': import_item.text
    }
    if 'voter' in settings.INSTALLED_APPS:
        kwargs['rating'] = create_rating()
    post = Post(**kwargs)
    post.save()
    return 'http://url'
Ejemplo n.º 6
0
def post_add(request, form_class=PostForm, template_name="blog/post_add.html"):
    post_form = form_class(request)
    if request.method == "POST" and post_form.is_valid():
        post = post_form.save(commit=False)
        post.author = request.user
        if 'voter' in settings.INSTALLED_APPS:
            post.rating = create_rating()
        creator_ip = request.META.get('HTTP_X_FORWARDED_FOR', None)
        if not creator_ip:
            creator_ip = request.META.get('REMOTE_ADDR', None)
        post.creator_ip = creator_ip
        post.save()
        messages.success(request,
                         _("Successfully created post '%s'") % post.title)
        return redirect("blog_user_post_detail",
                        username=request.user.username,
                        slug=post.slug)
    return TemplateResponse(request, template_name, {
        'post_form': post_form,
        'current_user': request.user
    })