Example #1
0
def populate_db(app):
    with app.app_context():

        if len(User.query.all()) > 0:
            return

        admin = User(username='******',
                     is_admin=True,
                     reset_q='The place I put that thing one time.',
                     reset_a=randstr(64))

        admin.set_password(randstr(64))

        guest = User(username='******',
                     reset_q='My favourite place of learning!',
                     reset_a='unsw')
        guest.set_password('guest')

        azured = User(username='******',
                      reset_q='All I see is...',
                      reset_a='*******')
        azured.set_password('hunter2')

        mail = Email(subject='Welcome to LMail',
                     body='Email we send to you will appear in this inbox!')

        db.session.add(admin)
        db.session.add(guest)
        db.session.add(azured)
        db.session.add(mail)
        db.session.commit()
Example #2
0
def sendmail(subject, body):
    e = Email(subject=subject, body=body)
    db.session.add(e)
    db.session.commit()