Fix page unable to scroll up

This commit is contained in:
cuom1999 2020-05-23 18:13:42 -05:00
parent 3b2d5dfce0
commit ca89510799
2 changed files with 3 additions and 12 deletions

View file

@ -1,7 +1,6 @@
import json import json
from channels.generic.websocket import AsyncWebsocketConsumer from channels.generic.websocket import AsyncWebsocketConsumer
from .models import Message from .models import Message
from .views import format_time
from django.urls import reverse from django.urls import reverse
from django.http import HttpResponse, HttpResponseRedirect from django.http import HttpResponse, HttpResponseRedirect
from django.core import serializers from django.core import serializers
@ -35,7 +34,6 @@ class ChatConsumer(AsyncWebsocketConsumer):
message = text_data_json['message'] message = text_data_json['message']
message_saved = save_data_and_return(message) message_saved = save_data_and_return(message)
message['time'] = message_saved[0]['fields']['time'] message['time'] = message_saved[0]['fields']['time']
message['id'] = message_saved[0]['pk'] message['id'] = message_saved[0]['pk']

View file

@ -10,20 +10,16 @@ from .models import Message
import json import json
def format_time(time):
return time
#return time.strftime('%H:%M %p %d-%m-%Y')
def format_messages(messages): def format_messages(messages):
msg_list = [{ msg_list = [{
'time': format_time(msg.time), 'time': msg.time,
'author': str(msg.author), 'author': str(msg.author),
'body': msg.body, 'body': msg.body,
'image': gravatar(msg.author, 32), 'image': gravatar(msg.author, 32),
'id': msg.id 'id': msg.id
} for msg in messages] } for msg in messages]
return json.dumps(msg_list) return json.dumps(msg_list, default=str)
class ChatView(ListView): class ChatView(ListView):
@ -50,9 +46,6 @@ class ChatView(ListView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context['title'] = self.title context['title'] = self.title
for msg in context['message']:
msg.time = format_time(msg.time)
return context return context
def delete_message(request): def delete_message(request):
@ -69,7 +62,7 @@ def delete_message(request):
if mess.id == messid: if mess.id == messid:
mess.hidden = True mess.hidden = True
mess.save() mess.save()
new_elt = {'time': format_time(mess.time), 'content': mess.body} new_elt = {'time': mess.time, 'content': mess.body}
ret = new_elt ret = new_elt
break break