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