def make(): if db(db.auth_user).count() == 1: populate(db.auth_user, 10, contents={"is_active": True}) populate(db.feed_item, 100, contents={"is_active": True, "parent_id": 0}) # populate(db.item_like, 1000, contents={"is_active": True}) ids = [r.id for r in db(db.auth_user).select() if r.id > 1] for k in ids[:3]: db.friend_request.insert(to_user=1, from_user=k, status="accepted") db.friend_request.insert(to_user=k, from_user=1, status="accepted") for k in ids[3:6]: db.friend_request.insert(to_user=1, from_user=k, status="pending") for k in ids[6:9]: db.friend_request.insert(to_user=1, from_user=k, status="rejected")
from py4web.utils.populate import populate #with python cli #import pydal #from py4web import * #from apps.vuenotus.models import db my_app_name = "vuenotus" if not db(db.auth_user).count(): body = { "username": "******", "email": "*****@*****.**", "password": str(CRYPT()("xyz12345")[0]), #"password": str(pydal.validators.CRYPT()("xyz12345")[0]), "first_name": "MainUser", "last_name": "MainUserLast", } db.auth_user.insert(**body) db.commit() db.define_table( 'test_table', Field('f0', 'string', label='l0'), Field('f1', 'string', label='l1'), Field('f2', 'string', label='l2'), ) if not db(db.test_table).count(): populate(db.test_table, n=10) db.commit()
db.tag.insert(superhero=2, superpower=4, strength=10) db.tag.insert(superhero=3, superpower=2, strength=80) db.tag.insert(superhero=3, superpower=3, strength=20) db.tag.insert(superhero=3, superpower=4, strength=70) # Used for examples of forms. def get_user_email(): return None if auth.current_user is None else auth.current_user.get( "email") def get_time(): return datetime.datetime.utcnow() db.define_table( "thing", Field("name", required=True), Field("color", options=("red", "green", "blue")), Field("is_ready", "boolean"), Field("time_created", "time"), Field("date_created", "date"), Field("timetime_created", "datetime"), ) if db(db.thing).isempty(): populate(db.thing, 100) db.commit()