[web2py] Re: Allow users to comment only for certain period of time

2015-06-05 Thread Ron Chatterjee
One thing you can do...

Let's say,

Table1 is post
Table2 is comment

When you render the comment form

form = SQLFORM(db.comment).process()

I am assuming you want to comment after the post is processed which make 
sense.

Here you can invoke a conditional statement like this.

post_time = db.post.created_on;
comment_time = db.comment.created_on;

if (comment_time > post_time +" whatever time you want to allow user")
response.flash('you have passed the time I allocated to comment on my post')

else
   If process.accpted():
go through the rest. 

Just some thoughts. You need to work through the syntax.





On Friday, June 5, 2015 at 9:32:39 AM UTC-4, 黄祥 wrote:
>
> it's so difficult without seeing any code, but you can use timedelta for it
> e.g. not tested
> duedate = blog.created_by + datetime.timedelta(7)
> editable = True if request.now < duedate else False
>
> best regards,
> stifan
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Allow users to comment only for certain period of time

2015-06-05 Thread Dave S


On Friday, June 5, 2015 at 6:32:39 AM UTC-7, 黄祥 wrote:
>
> it's so difficult without seeing any code, but you can use timedelta for it
> e.g. not tested
> duedate = blog.created_by + datetime.timedelta(7)
> editable = True if request.now < duedate else False
>
>
Note that datetime.timedelta is a Python feature, 
https://docs.python.org/2/library/datetime.html#timedelta-objects>

but web2py also supports time in queries.
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#year--month--day--hour--minutes--seconds>


Here's a couple of posts I've made in the past about dates:

https://groups.google.com/d/msg/web2py/-VPp4OaSskI/SvAfYL6yoqEJ>
(does a timedelta calculation on two rows from a query), and also shows an 
db.executesql() with an "older than" clause)

and 
https://groups.google.com/d/msg/web2py/MNzcV1dsgMk/1nFl__MDrMoJ>
where I have a db(db.table matches month).select() that orders by the month.


Hope this helps ... a lot of reading when you're starting out, eh?

/dps

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Allow users to comment only for certain period of time

2015-06-05 Thread 黄祥
it's so difficult without seeing any code, but you can use timedelta for it
e.g. not tested
duedate = blog.created_by + datetime.timedelta(7)
editable = True if request.now < duedate else False

best regards,
stifan

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.