def _send_message(): _message = ModalMessage() if request.method == 'POST': if _message.validate_on_submit(): send_message(sender=current_user.id, recipient=_message.recipient.data, subject=_message.subject.data, body=_message.body.data) else: flash_errors(_message) return redirect(url_for('message.new'))
def new(): _embedded = EmbeddedMessage() if request.method == 'POST': if _embedded.validate_on_submit(): send_message(sender=current_user.id, recipient=_embedded.recipient.data, subject=_embedded.subject.data, body=_embedded.body.data) return redirect(url_for('message.sent')) else: flash_errors(_embedded) return render_template("message/new.html", _embedded=_embedded)
def _send_draft(msg): if request.method == 'GET': _message = Messages.query.filter(Messages.id == msg, Messages.user_for_id == current_user.id, Messages.draft == 1).first_or_404() if _message is None: return redirect(url_for('message.draft')) else: send_message() flash('Message has been permanently deleted.', 'info') return redirect(url_for('message.draft')) else: return redirect(url_for('message.draft'))