Exemplo n.º 1
0
    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
Exemplo n.º 2
0
def db():
    try:
        User.create_table()
        Message.create_table()
    except Exception:
        pass
Exemplo n.º 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()
Exemplo n.º 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)
Exemplo n.º 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)