add message

This commit is contained in:
baoliang 2020-09-26 16:19:27 +08:00
parent 6f86ec55c8
commit 252d171a2c
4 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -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'})