def get_context_data(self, **kwargs):
        ctx = super(ChatRoomView, self).get_context_data(**kwargs)

        label = self.kwargs.get('label')
        print 'label:', label
        room = Room.objects.get(label=label)
        ctx['room'] = room
        ctx['messages'] = Message.top_messages(room)

        return ctx
Example #2
0
def db():
    try:
        User.create_table()
        Message.create_table()
    except Exception:
        pass
Example #3
0
import datetime
from example.models import Message, Sender

sender = Sender(name="Me Myself", email="*****@*****.**", imageUrl="")
sender.save()
recipient = Sender(name="You Yourseld", email="*****@*****.**", imageUrl="")
recipient.save()
message = Message(sender=sender,
                  recipient=recipient,
                  message="Hello! How are you?",
                  timestamp=datetime.datetime.now())
message.save()
Example #4
0
def bulk_delete(handler, request):
    """Bulk delete items"""
    ids = request.GET.getall('ids')
    Message.delete().where(Message.id << ids).execute()
    raise muffin.HTTPFound(handler.url)
Example #5
0
def bulk_delete(handler, request):
    """Bulk delete items"""
    ids = request.GET.getall('ids')
    Message.delete().where(Message.id << ids).execute()
    raise muffin.HTTPFound(handler.url)