-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
32 lines (26 loc) · 741 Bytes
/
models.py
File metadata and controls
32 lines (26 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
This file defines the database models
"""
import datetime
from . common import db, Field, auth
from pydal.validators import *
### Define your table below
#
# db.define_table('thing', Field('name'))
#
## always commit your models to avoid problems later
#
# db.commit()
#
def get_user_email():
return auth.current_user.get('email') if auth.current_user else None
def get_time():
return datetime.datetime.utcnow()
db.define_table("post",
Field('email', default=get_user_email),
Field('content', 'text'),
Field('post_date', 'datetime', default=get_time),
Field('is_reply', 'reference post'),
Field('author', 'text')
)
db.commit()