hi everyone,

So i have two components on my page. I can insert comments on my components 
just fine.
However i am trying to allow my users to delete a comment they have 
inserted.
I am not sure how to go about it. Somebody please help it will be 
appreciated.
This is what i have.


*In comments.py #i declare controllers to the two components and declare a 
delete function *
@auth.requires_login()
def post():
    return dict(form = SQLFORM(db.comment_post).process(), 
comments=db(db.comment_post).select())

@auth.requires_login()
def post2():
    return dict(form = SQLFORM(db.comment_post2).process(), 
comments=db(db.comment_post2).select())


@auth.requires_login()
def delete_comment():
    form = SQLFORM(db.comment_post).process()
    db(db.comment_post.id == request.vars.id).delete()
    return locals()


*In comments_db.py, i declare my tables*

db.define_table('comment_post',
   Field('body','text'),
   auth.signature)

db.define_table('comment_post2',
   Field('body','text'),
   auth.signature)


*In both post.load and post2.load, i insert the delete link which is in 
bold below*

{{for post in comments:}}
<div class="post">
  On {{=post.created_on}} {{=post.created_by.first_name}}
  says <blockquote class="post_body">{{=post.body}}</blockquote>
    *{{=A('Remove', _href=URL('default', 'delete_comment', args=['delete', 
post.id]), cid=request.cid, ajax=True,user_signature=True)}}*
</div>
{{pass}}
{{=form}}

*In both post.html and post2,html*
{{extend 'layout.html'}}
{{for post in comments:}}
<div class="post">
  On {{=post.created_on}} {{=post.created_by.first_name}}
  says <span class="post_body">{{=post.body}}</span>

</div>
{{pass}}
{{=form}}


*In my htmls where i put my components*


*{{=LOAD('comments', 'post.load', ajax=True)}}*

*{{=LOAD('comments', 'post2.load', ajax=True)}}*

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to