From 252d171a2c4be96ad6bb6873f95d8cdc2dafb728 Mon Sep 17 00:00:00 2001 From: baoliang Date: Sat, 26 Sep 2020 16:19:27 +0800 Subject: [PATCH] add message --- .../views/__pycache__/message.cpython-38.pyc | Bin 1914 -> 2028 bytes polls/views/__pycache__/task.cpython-38.pyc | Bin 2709 -> 2696 bytes polls/views/message.py | 10 +++++++--- polls/views/task.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/polls/views/__pycache__/message.cpython-38.pyc b/polls/views/__pycache__/message.cpython-38.pyc index 96b8b0ed29d2bb82710c251630ad9d0e140399c0..21e266755cf24f24066f0c3f6b5e8da02033b0db 100644 GIT binary patch delta 958 zcmY*Yzi-n(6!tle<2bhSt3T7Gg;J2x3M$IbRw^9;u@weXDs><@y$em0#Pr!g3_+D> z*HTr6p%O?56HMjrU|>cb*gzmLA_kW7-Zc`%r~B@E?|t{|d++?m`I&asY}-`uS^wQC zKQIoRakh6jyFSkqZZw=`dLzvgp^GF>a&u4FWxH%6BkdHo`gWFU_mq--`0mL}iAAY3 zU%+GVsjz) z$z=uo8DyqpS!5~6a>y*n^2lt-29Payb;tQYkD+)FZLM4E=sm`i?Ui7H4|Oy?{95HBd~{#MDip%|>S7AZ zkZ5BW$~7LoP{YeM9yv-hh3~tM#BGdfzFQTg$w+UCV9VnWBY{R+AQRq+%}r;~0ZH;& zzG(4s6}%>9i{jN9_(7z#+@=V-vB7J@Bpe|qkUCds*BZR+R(!9~4n(;PwJ3%FVbRP0 z0Oy&ZY9~6=Pc){U=&JdjmBF2`6n@m+%umw`Qv{S99E2#2NB5vjj;{yLzrFhK%#fXyP6DbdOdym@m?BPXLB89WECxLhxl>1Gc4IkW4Y C4Ba3A delta 802 zcmYk4&ubGw6vub=S2mmdnP1%`8)&MuEQ%g#!D{J65JY+s5xj)hnHEEnkl92E26~8i z^AP6XMIrH|cQ1nH{t1G6?5T(T1M0>1##EhUzw?>*-aO{LnG64?=RI~^TY>TMqTl|O zn|U!go?Uyg&PresQk!gB3X{gIM5v(GQ$eS+JUBL}k%|2_EAh=_+q zT@1(uITdfo>dD0DI$d{SQfo&6_JHz|d>~s=0923^0y&b3K(3?`kSD3kzfP2S1+tX8 z)dlIR6mta9w*nMOiul*^%hP6I#Ow0u#%5ZlS)5=7r)psgg zq0t)^Dy@mBdRv^TB66UzEZ1Xc+BszR6O!p^=YSL13u_w z);MLn-{~x8p14PkmViSuv#3MS)Cd@Xh(0cjBKrsox%D2RI<9)D(8S(x(=7HSbjo54= zhT@m8b|Oo0{+7~yPPr$&DA)=fgCsUzMb=PSD0!4CDEJzn@nGxs^`jF>DXF*qLl z&kh#}`;)o-0q=E=_MpY<&||)d9x1ob9m>;;*zu^nyoC+%#Z1gQ;7kH>Zhm;cw{Qy@ j{@eU7gSFEe(D4!5#h05#Adc*br8>|VM^lMPoI2`n3xTEm diff --git a/polls/views/__pycache__/task.cpython-38.pyc b/polls/views/__pycache__/task.cpython-38.pyc index 596b7fc7677396c4b49eeb45ee10d012f1d85054..1293b6d8b01495926c2b5810bb30eac28885c308 100644 GIT binary patch delta 91 zcmbO#+9Apt%FD~e00gO@^5T0o^2)I=s%+L_5oZ)y$i&D{!k!|QBA&_E%oxm|DX}@6 tRfchM9otk!7CxpTkICX3^BHX>Z|A6H^xSOB$;Zg%0W_z`bFw>^9{{rw6w3er delta 105 zcmeAWohr&3%FD~e00itG^5SQ1BF-q1BDRp3k)eb=MLb0!ld+jGm_bu= zb116}Blj)Nl*HnUr2NF9l+A@~QyEzVn2J0nb8*aPw4J<)qngocvl=HKBbz7C)FQ9R HR$P7n6^$8G 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'})