fix send_tnps bug
This commit is contained in:
parent
a29b3b1a1c
commit
352a445198
|
@ -1748,8 +1748,8 @@ def news_management_create(request):
|
|||
for p in profiles:
|
||||
phones.append(p.user.username)
|
||||
Notice.create_news_notice(p.user_id, content, news.id)
|
||||
send_tnps(phones, content)
|
||||
messages.success(request, '添加成功!!!')
|
||||
send_tnps(phones, '通知', content)
|
||||
messages.success(request, '添加成功!')
|
||||
return HttpResponseRedirect('/management/news/management/create/')
|
||||
type = News.NEWMEDIA_NEWS_CHOICES
|
||||
results = []
|
||||
|
|
|
@ -14,7 +14,7 @@ import json
|
|||
from aliyunsdkcore.profile import region_provider
|
||||
|
||||
|
||||
def send_tnps(phones, content):
|
||||
def send_tnps(phones, title, content):
|
||||
url = 'https://api.tpns.tencent.com/v3/push/app'
|
||||
r = requests.post(url,
|
||||
auth=HTTPBasicAuth(
|
||||
|
@ -23,8 +23,8 @@ def send_tnps(phones, content):
|
|||
"audience_type": "account_list",
|
||||
"account_list": phones,
|
||||
"message": {
|
||||
"title": content,
|
||||
"content": ''
|
||||
"title": title,
|
||||
"content": content
|
||||
},
|
||||
"message_type": "notify",
|
||||
"account_push_type": 1
|
||||
|
@ -174,5 +174,5 @@ if __name__ == '__main__':
|
|||
|
||||
# print(og_title, og_description, og_url, og_image)
|
||||
# print(send_voice_notify('13993199566'))
|
||||
r = send_tnps(['13609346975'], 'contenteeeent!!!!')
|
||||
r = send_tnps(['13609346975'], 'title with content', 'content 通知')
|
||||
print(r.status_code, r.text)
|
||||
|
|
|
@ -87,7 +87,7 @@ def create_media(request):
|
|||
phones.append(a.user.username)
|
||||
Notice.create_reply_notice(
|
||||
a.user.id, content, 'dashboard', model_name, 'status', instance.id, '3', '0')
|
||||
send_tnps(phones, content)
|
||||
send_tnps(phones, '审核', content)
|
||||
else:
|
||||
admins = Userprofile.level2_admin(instance.organization.cities)
|
||||
content = '%s创建了新媒体,请审核' % (profile,)
|
||||
|
@ -96,7 +96,7 @@ def create_media(request):
|
|||
phones.append(a.user.username)
|
||||
Notice.create_reply_notice(
|
||||
a.user.id, content, 'dashboard', model_name, 'status', instance.id, '2', '0')
|
||||
send_tnps(phones, content)
|
||||
send_tnps(phones, '审核', content)
|
||||
return JsonResponse({'status': 'success'})
|
||||
|
||||
|
||||
|
@ -240,7 +240,7 @@ def delete_media(request):
|
|||
phones.append(a.user.username)
|
||||
Notice.create_reply_notice(
|
||||
a.user.id, content, 'dashboard', model_name, 'status', instance.id, '0', '3')
|
||||
send_tnps(phones, content)
|
||||
send_tnps(phones, '审核', content)
|
||||
else:
|
||||
instance.status = 4
|
||||
instance.save()
|
||||
|
@ -251,7 +251,7 @@ def delete_media(request):
|
|||
phones.append(a.user.username)
|
||||
Notice.create_reply_notice(
|
||||
a.user.id, content, 'dashboard', model_name, 'status', instance.id, '5', '3')
|
||||
send_tnps(phones, content)
|
||||
send_tnps(phones, '审核', content)
|
||||
admins = []
|
||||
for admin in instance.organization.userprofile_set.all():
|
||||
u = dict()
|
||||
|
@ -309,7 +309,7 @@ def media_admin_change(request):
|
|||
phones.append(a.user.username)
|
||||
Notice.create_reply_notice(
|
||||
a.user.id, content, 'dashboard', 'Userprofile', 'admin_status', o.id, '3', '0')
|
||||
send_tnps(phones, content)
|
||||
send_tnps(phones, '审核', content)
|
||||
return JsonResponse({'status': 'success', 'message': '变更申请发送成功'})
|
||||
else:
|
||||
obj, created = UserModel.objects.get_or_create(
|
||||
|
@ -329,5 +329,5 @@ def media_admin_change(request):
|
|||
phones.append(a.user.username)
|
||||
Notice.create_reply_notice(
|
||||
a.user.id, content, 'dashboard', 'Userprofile', 'admin_status', o.id, '2', '0')
|
||||
send_tnps(phones, content)
|
||||
send_tnps(phones, '审核', content)
|
||||
return JsonResponse({'status': 'success', 'message': '变更申请发送成功'})
|
||||
|
|
|
@ -158,7 +158,7 @@ def pass_notice(request):
|
|||
phones.append(a.user.username)
|
||||
Notice.create_reply_notice(
|
||||
a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '3', '0')
|
||||
send_tnps(phones, notice.content)
|
||||
send_tnps(phones,'审核', notice.content)
|
||||
else: # 省级提交
|
||||
for p in profiles:
|
||||
if p.admin_status == 5:
|
||||
|
@ -190,7 +190,7 @@ def pass_notice(request):
|
|||
phones.append(a.user.username)
|
||||
Notice.create_reply_notice(
|
||||
a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '3', '0')
|
||||
send_tnps(phones, notice.content)
|
||||
send_tnps(phones, '审核', notice.content)
|
||||
if pass_value == '5':
|
||||
admins = Userprofile.level1_admin()
|
||||
phones = []
|
||||
|
@ -198,7 +198,7 @@ def pass_notice(request):
|
|||
phones.append(a.user.username)
|
||||
Notice.create_reply_notice(
|
||||
a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '0', '3')
|
||||
send_tnps(phones, notice.content)
|
||||
send_tnps(phones, '审核', notice.content)
|
||||
return JsonResponse({'status': 'success', 'message': '申请已同意'})
|
||||
except ObjectDoesNotExist:
|
||||
return JsonResponse({'status': 'error', 'message': '通知ID错误'})
|
||||
|
|
|
@ -71,7 +71,8 @@ def create_task(request):
|
|||
if profile and profile.status == 1:
|
||||
content = '%s在群组“%s”发布了任务,请查收消息' % (creater_profile, g.name)
|
||||
Notice.create_normal_notice(u.user_id, content, group)
|
||||
send_tnps([u.username], content)
|
||||
phones = [u.username for u in users]
|
||||
send_tnps(phones, '任务', content)
|
||||
return JsonResponse({'status': 'success'})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue