Replying to my own post. I just looked up Massimos previous answer. And the
correct return policy is:
query1 = (db.auth_user.id == db.liked.liked_by);
all_like = db(query1).select(db.auth_user.first_name);
items = [dict(name = row.first_name) for row in all_like]
db(db.post.id==id).update(reported=False, like_it=True,banned=False)
response.js = "$('#post-%d >
div:first-child').addClass('like_it')"%id
#like_message = 'Liked'
return dict(like_message = 'liked', items = [dict(name =
row.first_name) for row in all_like])
On Wednesday, November 11, 2015 at 9:01:46 AM UTC-5, Ron Chatterjee wrote:
>
> I am looking at Massimo's my_forum app. in function definition I have:
>
>
> def do():
>
> id, method = request.args(0,cast=int), request.args(1)
>
> if method == 'report':
>
> db(db.post.id==id).update(reported=True)
>
> return 'reported'
>
> if method == 'like_it' and (DEBUG or
> auth.has_membership('moderators')):
>
> like = db.liked.insert(liked_by=auth.user.id)
>
> query1 = (db.auth_user.id == db.liked.liked_by);
>
> all_likes = db(query1).select(db.auth_user.first_name);
>
> db(db.post.id==id).update(reported=False,
> like_it=True,banned=False)
>
> return 'liked'
>
>
> Basically, its a facebook like "like" that I want to replicate.
>
>
> Question.
>
>
> How to return the pydal field object from controller along with the string
> 'liked'.
>
>
> all likes is : <pydal.objects.Field object at 0x0000000009D8E438>
>
>
> My model file is:
>
> db.define_table('liked',
> Field('thread', 'reference thread'),
> Field('liked_on', 'datetime', default=request.now,
> readable=False, writable=False),
> Field('liked_by', 'reference auth_user', readable=False,
> writable=False))
>
>
>
>
>
>
--
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.