Beispiel #1
0
def message_reply(message_id):
    user = current_user()

    if len(message_id) > Model.TEXT_MAX_LEN:
        flash('Bad message ID', 'alert-danger')
        return redirect('/inbox')

    message = Message.select(message_id)
    if not message:
        flash("Message doesn't exist", 'alert-danger')
        return redirect('/inbox')
    elif message.recipient_name != user.username:
        flash("Can't view messages from other users", 'alert-danger')
        return redirect('/inbox')

    return redirect('/compose?title={}&recipient={}'.format(
        'Re: {}'.format(message.title), message.sender_name))
Beispiel #2
0
def message_delete(message_id):
    user = current_user()

    if len(message_id) > Model.TEXT_MAX_LEN:
        flash('Bad message ID', 'alert-danger')
        return redirect('/inbox')

    message = Message.select(message_id)
    if not message:
        flash("Message doesn't exist", 'alert-danger')
    elif message.recipient_name != user.username:
        flash("Can't delete messages from other users", 'alert-danger')
    else:
        Message.delete(message.id)
        flash('Message successfully deleted', 'alert-success')

    return redirect('/inbox')
Beispiel #3
0
def message_id(message_id):
    user = current_user()

    if len(message_id) > Model.TEXT_MAX_LEN:
        flash('Bad message ID', 'alert-danger')
        return redirect('/inbox')

    message = Message.select(message_id)
    if not message:
        flash("Message doesn't exist", 'alert-danger')
        return redirect('/inbox')
    elif message.recipient_name != user.username:
        flash("Can't view messages from other users", 'alert-danger')
        return redirect('/inbox')

    sender = '{}'.format(User.select(message.sender_name))

    return render_template('message_id.html',
                           title=message.title,
                           user=user,
                           message=message,
                           sender=sender)