Exemplo n.º 1
0
def inbox(request):
    """
       Display character's private messages.
   """
    requester = request.user.get_profile().db.avatar
    messages = [
        Mail(message, requester) for message in get_messages(requester)
    ]
    status = request.session.get('mail_status', '')
    try:
        del request.session['mail_status']
    except:
        pass
    return render_to_response('mail/inbox.html', {
        'user': request.user,
        'message_list': messages,
        'status': status,
    }, RequestContext(request))
Exemplo n.º 2
0
def view_message(request, msg_id):
    READ = 2
    requester = request.user.get_profile().db.avatar
    try:
        msg_id = int(msg_id)
        messages = get_messages(requester)
        message = [
            message for message in messages if message[MESSAGE].id == msg_id
        ]
        message = message[0]
    except IndexError as e:
        raise Http404
    page = render_to_response('mail/view.html', {
        'user': request.user,
        'message': Mail(message, requester),
    }, RequestContext(request))
    message[READ] = True
    requester.db.mail = messages
    return page
Exemplo n.º 3
0
def inbox(request):
   """
       Display character's private messages.
   """
   requester = request.user.db.avatar
   messages = [ Mail(message, requester) for message in get_messages(requester) ]
   status = request.session.get('mail_status', '')
   try:
        del request.session['mail_status']
   except:
        pass
   return render_to_response(
        'mail/inbox.html',
        {  
            'user' : request.user,
            'message_list' : messages,
            'status' : status,
        },
        RequestContext(request)
    )
Exemplo n.º 4
0
def delete_message(request):
    """
        Delete a mail message.
    """
    requester = request.user.db.avatar
    post = dict(request.POST)
    if not 'msg_id' in post:
        return HttpResponseBadRequest()
    else:
        try:
            msg_id = int(post['msg_id'][0])
        except:
            return HttpResponseBadRequest()
    try:
        messages = [ message for message in get_messages(requester) if message[MESSAGE].id == msg_id ]
        message = messages[0]
    except IndexError:
        raise Http404
    Mail(message, requester).delete(requester)
    request.session['mail_status'] = 'Message deleted.'
    return HttpResponseRedirect(reverse('mail:inbox'))
Exemplo n.º 5
0
def view_message(request, msg_id):
    READ = 2
    requester = request.user.db.avatar
    try:
        msg_id = int(msg_id)
        messages = get_messages(requester)
        message = [ message for message in messages if message[MESSAGE].id == msg_id ]
        message = message[0]
    except IndexError as e:
        raise Http404
    page = render_to_response(
        'mail/view.html',
        {
            'user' : request.user,
            'message' : Mail(message, requester),
        },
        RequestContext(request)
    )
    message[READ] = True
    requester.db.mail = messages
    return page
Exemplo n.º 6
0
def delete_message(request):
    """
        Delete a mail message.
    """
    requester = request.user.get_profile().db.avatar
    post = dict(request.POST)
    if not 'msg_id' in post:
        return HttpResponseBadRequest()
    else:
        try:
            msg_id = int(post['msg_id'][0])
        except:
            return HttpResponseBadRequest()
    try:
        messages = [
            message for message in get_messages(requester)
            if message[MESSAGE].id == msg_id
        ]
        message = messages[0]
    except IndexError:
        raise Http404
    Mail(message, requester).delete(requester)
    request.session['mail_status'] = 'Message deleted.'
    return HttpResponseRedirect(reverse('mail:inbox'))
Exemplo n.º 7
0
 def unread_messages(character):
     READ = 2
     mail = get_messages(character)
     return [message for message in mail if not message[READ]]
Exemplo n.º 8
0
 def unread_messages(character):
     READ = 2
     mail = get_messages(character)
     return [message for message in mail if not message[READ]]