def generate_fake_data(): u = User.new(username='******', password='******') b = Board.new(title='demo') Board.new(title='demo2') with open('markdown_demo.md', encoding='utf8') as f: content = f.read() form = dict(title='markdown demo', content=content, board_id=b.id) Topic.new(form, u.id) form = dict(title='板块测试 demo2', content='**biu biu biu**', board_id='2') Topic.new(form, u.id) form = dict( topic_id=1, content='**hello world**', ) u = User.new( username='******', password='******', ) Reply.new(form, u.id) form = dict( topic_id=2, content='**hello world2**', ) Reply.new(form, u.id) form = dict(title='hey', content='happy', sender_id=1, receiver_id=2) Messages.new(**form)
def send_mails(sender, receivers, content): print('send_mail', sender, receivers, content) for r in receivers: form = dict(title='你被 {} AT 了'.format(sender.username), content=content, sender_id=sender.id, receiver_id=r.id) Messages.new(**form)
def add(): form = request.form.to_dict() form['receiver_id'] = int(form['receiver_id']) u = current_user() form['sender_id'] = u.id r = User.one(id=form['receiver_id']) m = Message( subject=form['title'], body=form['content'], sender=admin_mail, recipients=[r.email] ) # mail.send(m) m = Messages.new(**form) return redirect(url_for('.index'))