add icons and chatbox
This commit is contained in:
parent
9e95fd21a7
commit
cb8eb2689c
43 changed files with 254 additions and 46 deletions
|
@ -1,11 +1,31 @@
|
|||
from django.shortcuts import render
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.generic import ListView
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
from .models import Message
|
||||
|
||||
|
||||
class ChatView(ListView):
|
||||
model = Message
|
||||
title = _('Chat Box')
|
||||
context_object_name = 'messages'
|
||||
template_name = 'chat/chat.html'
|
||||
title = _('Chat Box')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ChatView, self).get_context_data(**kwargs)
|
||||
context['title'] = self.title
|
||||
return context
|
||||
|
||||
def get_queryset(self):
|
||||
return None
|
||||
|
||||
|
||||
def send(request):
|
||||
new_message = Message(body=request.POST['message'],
|
||||
author=request.profile,
|
||||
time=timezone.now())
|
||||
new_message.save()
|
||||
return HttpResponseRedirect(reverse('chat'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue