def send(): form = request.form.to_dict() form['receiver_id'] = int(request.args['id']) u = current_user() form['sender_id'] = u.id Messages.new(form) return redirect(url_for('.index'))
def send_like(sender, receiver, reply_link, reply_content): form = dict(title=reply_link, content=reply_content, sender_id=sender.id, receiver_id=receiver.id, type='like') 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 send_mails(sender, receivers, reply_link, reply_content): print('send_mail', sender, receivers, reply_content) content = '链接:{}\n内容:{}'.format(reply_link, reply_content) for r in receivers: form = dict(title='你被 {} @ 了'.format(sender.username), content=content, sender_id=sender.id, receiver_id=r.id) Messages.new(form)
def send_mails(sender, receivers, reply_link, reply_content): for r in receivers: form = dict( title=reply_link, content=reply_content, sender_id=sender.id, receiver_id=r.id, type='at' ) Messages.new(form)
def send_collect(sender, receiver, reply_link, reply_content): # 更新message信息表 form = dict( title=reply_link, content=reply_content, sender_id=sender.id, receiver_id=receiver.id, type='collect' ) Messages.new(form)
def delete_topic(): topic_title = request.form['title'] t = Topic.one(title=topic_title) topic_id = t.id user_id = t.user_id content = '您的帖子《{}》已被管理员删除'.format(t.title) form = dict(receiver_id=user_id, sender_id=current_user().id, content=content) Messages.new(form) Topic.delete(id=topic_id) Reply.delete(topic_id=topic_id) return redirect(url_for('.index'))
def add(u): form = request.form.to_dict() form['receiver_id'] = int(form['receiver_id']) form['sender_id'] = u.id # 发邮件 r = User.one(id=form['receiver_id']) m = flask_mail.Message(subject=form['title'], body=form['content'], sender=admin_mail, recipients=[r.email]) mail.send(m) Messages.new(form) return redirect(url_for('.index'))
def add(): form = request.form.to_dict() u = current_user() form['sender_id'] = u.id r = User.one(username=form['receiver_name']) form['receiver_id'] = r.id m = Message(subject=form['title'], body=form['content'], sender=admin_mail, recipients=[r.email]) mail.send(m) Messages.new(form) return redirect(url_for('.index'))
def add(): form = request.form.to_dict() receiver = User.one(username=form['receiver']) receiver_id = receiver.id form['receiver_id'] = receiver_id u = current_user() form['sender_id'] = u.id m = Messages.new(form) return redirect(url_for('.index'))
def add(): form = request.form.to_dict() receiver = User.one(username=form['receiver']) form['receiver_id'] = 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) Messages.new(form) return redirect(url_for('.index'))
def add(): form = request.form.to_dict() user = User.one(username=form["username"]) if user is not None: form['receiver_id'] = user.id else: abort(404) u = current_user() form['sender_id'] = u.id # 发邮件 # r = User.one(id=form['receiver_id']) # m = flask_mail.Message( # subject=form['title'], # body=form['content'], # sender=admin_mail, # recipients=[r.email] # ) # mail.send(m) Messages.new(form) return redirect(url_for('.index'))