(request)
return ajax_success(msg="success", inplace_form=form)
Used to render inplace forms for editing posts.
Used to render inplace forms for editing posts.
Used to render inplace forms for editing posts .
def inplace_form(request):
    """
    Used to render inplace forms for editing posts.
    """
    MIN_LINES = 10
    user = request.user
    if user.is_anonymous:
        return ajax_error(msg="You need to be logged in to edit or create posts.")

    # Get the current post uid we are editing
    uid = request.GET.get('uid', '')
    post = Post.objects.filter(uid=uid).first()
    if not post:
        return ajax_error(msg="Post does not exist.")

    add_comment = request.GET.get('add_comment', False)

    html = "" if add_comment else post.html

    # Load the content and form template
    template = "forms/form_inplace.html"
    tmpl = loader.get_template(template_name=template)

    nlines = post.num_lines(offset=3)
    rows = nlines if nlines >= MIN_LINES else MIN_LINES
    initial = dict(tag_val=post.tag_val)
    form = forms.PostLongForm(user=request.user, initial=initial)

    content = '' if add_comment else post.content
    context = dict(user=user, post=post, new=add_comment, html=html,
                   captcha_key=settings.RECAPTCHA_PUBLIC_KEY, rows=rows, form=form,
                   content=content)

    form = tmpl.render(context)

    return ajax_success(msg="success", inplace_form=form)
def inplace_form ( request ) : MIN_LINES = 10 user = request . user if user . is_anonymous : return ajax_error ( msg = "You need to be logged in to edit or create posts." ) # Get the current post uid we are editing uid = request . GET . get ( 'uid' , '' ) post = Post . objects . filter ( uid = uid ) . first ( ) if not post : return ajax_error ( msg = "Post does not exist." ) add_comment = request . GET . get ( 'add_comment' , False ) html = "" if add_comment else post . html # Load the content and form template template = "forms/form_inplace.html" tmpl = loader . get_template ( template_name = template ) nlines = post . num_lines ( offset = 3 ) rows = nlines if nlines >= MIN_LINES else MIN_LINES initial = dict ( tag_val = post . tag_val ) form = forms . PostLongForm ( user = request . user , initial = initial ) content = '' if add_comment else post . content context = dict ( user = user , post = post , new = add_comment , html = html , captcha_key = settings . RECAPTCHA_PUBLIC_KEY , rows = rows , form = form , content = content ) form = tmpl . render ( context ) return ajax_success ( msg = "success" , inplace_form = form )