diff --git a/polls/views/__pycache__/message.cpython-38.pyc b/polls/views/__pycache__/message.cpython-38.pyc index 96b8b0e..21e2667 100644 Binary files a/polls/views/__pycache__/message.cpython-38.pyc and b/polls/views/__pycache__/message.cpython-38.pyc differ diff --git a/polls/views/__pycache__/task.cpython-38.pyc b/polls/views/__pycache__/task.cpython-38.pyc index 596b7fc..1293b6d 100644 Binary files a/polls/views/__pycache__/task.cpython-38.pyc and b/polls/views/__pycache__/task.cpython-38.pyc differ diff --git a/polls/views/message.py b/polls/views/message.py index ee19ee2..b63d6df 100644 --- a/polls/views/message.py +++ b/polls/views/message.py @@ -6,6 +6,7 @@ import datetime from polls.decorators import polls_login_required from django.core.exceptions import ObjectDoesNotExist from polls.models import Message +from dashboard.models import Userprofile @csrf_exempt @@ -21,16 +22,19 @@ def last_messages(request): result = dict() result['id'] = str(o.id) result['type'] = o.type - result['user_name'] = o.send_from.username + profile = Userprofile.objects.filter(user_id=o.send_from_id).first() + result['user_name'] = profile.name result['content'] = o.content result['page_title'] = o.page_title result['page_description'] = o.page_description result['page_image'] = o.page_image result['url'] = o.url result['file_title'] = o.file_title - result['file'] = request.build_absolute_uri(o.file.uri) if o.file else '' + result['file'] = request.build_absolute_uri( + o.file.uri) if o.file else '' result['image_title'] = o.image_title - result['picture'] = request.build_absolute_uri(o.picture.uri) if o.picture else '' + result['picture'] = request.build_absolute_uri( + o.picture.uri) if o.picture else '' result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S") results.append(result) return JsonResponse({'status': 'success', 'message': results}, safe=False) diff --git a/polls/views/task.py b/polls/views/task.py index 15fd64f..87e8964 100644 --- a/polls/views/task.py +++ b/polls/views/task.py @@ -65,7 +65,7 @@ def create_task(request): normalMessage = Message.objects.create( type=4, send_from_id=user.id, send_to_id=group, task=task, content=content) content = '用户%s发布了任务,请查收消息' % (profile.name,) - Notice.create_normal_notice(user.id, content, 'dashboard') + Notice.create_normal_notice(user.id, content) return JsonResponse({'status': 'success'})