The manual's "Overview" chapter discusses a similar application.

Here is a link to the English version:
http://web2py.com/books/default/chapter/29/3#An-image-blog

And Spanish:
http://www.latinuxpress.com/books/drafts/web2py/caps/cap3.html#un-blog-image

On Mar 6, 6:34 am, Ale <alessandro.agu...@gmail.com> wrote:
> Good morning everyone. I am making a simple application, but I'm running
> into some doubt. I wanted to do something like thefacebook posts .. Where I
> have a site that I put a post, listed below are all posts with the option to
>  comment on them. So far so good .. But how to write the data's comment in a
>  post post correct? Attached I am sending the screen of my application, I
> think it is easier to visualize what I wanted. Transmission also Model /
> View / Controller. If you can help me will be grateful.
>
> I'd have to get the id of the post via ajax?
>
> My model:
>
> Post = db.define_table('post',
>     Field('title'),
>     Field('post'),
>     format="%(title)s"
>     )
>
> Comment = db.define_table('comment',
>     Field('post', 'reference post'),
>     Field('comment')
>     )
>
> My Controller
>
> def index():
>     form = SQLFORM(Post,
>                     formstyle="divs",
>                     submit_button="Postar").process()
>
>     form2 = SQLFORM.factory(
>                     Field('comment', requires=IS_NOT_EMPTY()),
>                     formstyle="divs",
>                     submit_button="Comentar")
>     if form2.process().accepted:
>         print request.vars
>         print request.args
>         response.flash = 'form accepted'
>     elif form2.errors:
>         response.flash = 'form has errors'
>     else:
>         response.flash = 'please fill out the form'
>
>     posts = db().select(Post.ALL)
>     return dict(form=form, form2=form2, posts=posts)
>
> my view:
>
> <div class="post">
>     {{=form.custom.begin}}
>         <p>Title</p>
>         {{=form.custom.widget.title}}
>         <p>Post</p>
>         {{=form.custom.widget.post}}
>         {{=form.custom.submit}}
>     {{=form.custom.end}}
> </div>
> <div class="posts">
>     {{for post in posts:}}
>         <li class="posts" id=post_{{=post.id}}>
>             <p>{{=post.post}}</p>
>             <p>{{=post.id}}
>             <div class="comment">
>                 {{=form2.custom.begin}}
>                     {{=form2.custom.widget.comment}}
>                     {{=form2.custom.submit}}
>                 {{=form2.custom.end}}
>             </div>
>         </li>
>     {{pass}}
> </div>
>
>  Captura de tela em 2012-03-05 17:08:30.png
> 208KViewDownload

Reply via email to