add message
This commit is contained in:
parent
79c454d7b5
commit
694ecd5a48
|
@ -28,6 +28,7 @@ urlpatterns = [
|
||||||
path('medias/update/', views.update_media, name='polls_update_media'),
|
path('medias/update/', views.update_media, name='polls_update_media'),
|
||||||
path('medias/list/', views.medias, name='polls_medias'),
|
path('medias/list/', views.medias, name='polls_medias'),
|
||||||
path('medias/my/', views.my_medias, name='polls_my_medias'),
|
path('medias/my/', views.my_medias, name='polls_my_medias'),
|
||||||
|
path('medias/admin/change/', views.media_admin_change, name='polls_media_admin_change'),
|
||||||
path('medias/<str:type>/<str:media_id>/',
|
path('medias/<str:type>/<str:media_id>/',
|
||||||
views.media_detail, name='polls_media_detail'),
|
views.media_detail, name='polls_media_detail'),
|
||||||
path('medias/delete/', views.delete_media, name='polls_delete_media'),
|
path('medias/delete/', views.delete_media, name='polls_delete_media'),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from .user import index, status_500, status_401, polls_login, send_code, register_step_one, register_step_two, password_recover_step_one, password_recover_step_two, reset_password
|
from .user import index, status_500, status_401, polls_login, send_code, register_step_one, register_step_two, password_recover_step_one, password_recover_step_two, reset_password
|
||||||
from .notice import notices, notice_top, read_notice, pass_notice, reject_notice, detail_notice, unread_notice_count
|
from .notice import notices, notice_top, read_notice, pass_notice, reject_notice, detail_notice, unread_notice_count
|
||||||
from .media import medias, my_medias, create_media, update_media, media_detail, delete_media
|
from .media import medias, my_medias, create_media, update_media, media_detail, delete_media, media_admin_change
|
||||||
from .news import news_list, news_top, news_detail
|
from .news import news_list, news_top, news_detail
|
||||||
from .monitor import monitor_statistics, monitor_result, media_statistics, city_ranking
|
from .monitor import monitor_statistics, monitor_result, media_statistics, city_ranking
|
||||||
from .task import tasks, create_task, create_test_task, get_task
|
from .task import tasks, create_task, create_test_task, get_task
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,7 @@
|
||||||
from django.http import HttpResponse, JsonResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from dashboard.models import Douyin, NewMedia, Qita, Toutiao, Userprofile, Weibo, Weixin
|
from dashboard.models import Douyin, NewMedia, Qita, Toutiao, Userprofile, Weibo, Weixin
|
||||||
from polls.decorators import polls_login_required
|
from polls.decorators import polls_login_required
|
||||||
|
@ -169,11 +170,12 @@ def media_detail(request, type, media_id):
|
||||||
result['media_id'] = media.qitaid
|
result['media_id'] = media.qitaid
|
||||||
|
|
||||||
admins = []
|
admins = []
|
||||||
for admin in media.organization.userprofile_set.all():
|
for admin in media.organization.userprofile_set.exclude(admin_status=0):
|
||||||
u = dict()
|
u = dict()
|
||||||
u['id'] = admin.user.id
|
u['id'] = admin.user.id
|
||||||
u['name'] = admin.name
|
u['name'] = admin.name
|
||||||
u['phone'] = admin.user.username
|
u['phone'] = admin.user.username
|
||||||
|
u['adminStatus'] = admin.admin_status
|
||||||
admins.append(u)
|
admins.append(u)
|
||||||
|
|
||||||
result['id'] = media.id
|
result['id'] = media.id
|
||||||
|
@ -280,9 +282,11 @@ def media_admin_change(request):
|
||||||
UserModel = get_user_model()
|
UserModel = get_user_model()
|
||||||
|
|
||||||
if o.is_direct(): # 如果是省直
|
if o.is_direct(): # 如果是省直
|
||||||
obj, created = UserModel.objects.get_or_create(username=phone)
|
obj, created = UserModel.objects.get_or_create(
|
||||||
|
username=phone, last_login=datetime.now())
|
||||||
if created:
|
if created:
|
||||||
p = Userprofile.objects.create(obj, organization=o, admin_status=2)
|
p = Userprofile.objects.create(
|
||||||
|
user=obj, name=name, organization=o, admin_status=2)
|
||||||
else:
|
else:
|
||||||
obj.admin_status = 2
|
obj.admin_status = 2
|
||||||
obj.save()
|
obj.save()
|
||||||
|
@ -292,11 +296,14 @@ def media_admin_change(request):
|
||||||
for a in managers:
|
for a in managers:
|
||||||
content = '%s申请变更管理员,请审核' % (operator,)
|
content = '%s申请变更管理员,请审核' % (operator,)
|
||||||
Notice.create_reply_notice(
|
Notice.create_reply_notice(
|
||||||
a.user.id, content, 'dashboard', 'Userprofile', 'admin_status', o.id, '0', '3')
|
a.user.id, content, 'dashboard', 'Userprofile', 'admin_status', o.id, '3', '0')
|
||||||
|
return JsonResponse({'status': 'success', 'message': '变更申请发送成功'})
|
||||||
else:
|
else:
|
||||||
obj, created = UserModel.objects.get_or_create(username=phone)
|
obj, created = UserModel.objects.get_or_create(
|
||||||
|
username=phone, last_login=datetime.now())
|
||||||
if created:
|
if created:
|
||||||
p = Userprofile.objects.create(obj, organization=o, admin_status=1)
|
p = Userprofile.objects.create(
|
||||||
|
user=obj, name=name, organization=o, admin_status=1)
|
||||||
else:
|
else:
|
||||||
obj.admin_status = 1
|
obj.admin_status = 1
|
||||||
obj.save()
|
obj.save()
|
||||||
|
@ -306,5 +313,5 @@ def media_admin_change(request):
|
||||||
for a in managers:
|
for a in managers:
|
||||||
content = '%s申请变更管理员,请审核' % (operator,)
|
content = '%s申请变更管理员,请审核' % (operator,)
|
||||||
Notice.create_reply_notice(
|
Notice.create_reply_notice(
|
||||||
a.user.id, content, 'dashboard', 'Userprofile', 'admin_status', o.id, '0', '2')
|
a.user.id, content, 'dashboard', 'Userprofile', 'admin_status', o.id, '2', '0')
|
||||||
|
return JsonResponse({'status': 'success', 'message': '变更申请发送成功'})
|
||||||
|
|
|
@ -71,7 +71,6 @@ def read_notice(request):
|
||||||
def detail_notice(request, notice_id):
|
def detail_notice(request, notice_id):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
return HttpResponse(status=405)
|
return HttpResponse(status=405)
|
||||||
print(notice_id, (not notice_id))
|
|
||||||
if not notice_id:
|
if not notice_id:
|
||||||
return JsonResponse({'status': 'error', 'message': '通知ID错误'})
|
return JsonResponse({'status': 'error', 'message': '通知ID错误'})
|
||||||
try:
|
try:
|
||||||
|
@ -82,22 +81,34 @@ def detail_notice(request, notice_id):
|
||||||
results['content'] = notice.content
|
results['content'] = notice.content
|
||||||
if notice.type == 1:
|
if notice.type == 1:
|
||||||
ReplyModel = apps.get_model(notice.app, notice.model)
|
ReplyModel = apps.get_model(notice.app, notice.model)
|
||||||
m = ReplyModel.objects.get(pk=notice.record_id)
|
if notice.model == 'Userprofile':
|
||||||
detail = dict()
|
profiles = ReplyModel.objects.filter(organization_id=notice.record_id).exclude(
|
||||||
detail['id'] = m.id
|
admin_status__in=[0, 3])
|
||||||
detail['code'] = m.code
|
m = []
|
||||||
if notice.model == 'Weixin':
|
for p in profiles:
|
||||||
detail['type'] = 'weixin'
|
n = dict()
|
||||||
elif notice.model == 'Weibo':
|
n['id'] = p.user_id
|
||||||
detail['type'] = 'weibo'
|
n['name'] = p.name
|
||||||
elif notice.model == 'Toutiao':
|
n['adminStatus'] = p.admin_status
|
||||||
detail['type'] = 'Toutiao'
|
m.append(n)
|
||||||
elif notice.model == 'Douyin':
|
results['profiles'] = m
|
||||||
detail['type'] = 'douyin'
|
|
||||||
else:
|
else:
|
||||||
detail['type'] = 'qita'
|
m = ReplyModel.objects.get(pk=notice.record_id)
|
||||||
detail['status'] = m.status
|
detail = dict()
|
||||||
results['media'] = detail
|
detail['id'] = m.id
|
||||||
|
detail['code'] = m.code
|
||||||
|
if notice.model == 'Weixin':
|
||||||
|
detail['type'] = 'weixin'
|
||||||
|
elif notice.model == 'Weibo':
|
||||||
|
detail['type'] = 'weibo'
|
||||||
|
elif notice.model == 'Toutiao':
|
||||||
|
detail['type'] = 'Toutiao'
|
||||||
|
elif notice.model == 'Douyin':
|
||||||
|
detail['type'] = 'douyin'
|
||||||
|
else:
|
||||||
|
detail['type'] = 'qita'
|
||||||
|
detail['status'] = m.status
|
||||||
|
results['media'] = detail
|
||||||
else:
|
else:
|
||||||
results['groupId'] = notice.group_id
|
results['groupId'] = notice.group_id
|
||||||
results['added'] = notice.added.strftime("%Y-%m-%d %H:%M:%S")
|
results['added'] = notice.added.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
@ -123,8 +134,9 @@ def pass_notice(request):
|
||||||
ReplyModel = apps.get_model(notice.app, notice.model)
|
ReplyModel = apps.get_model(notice.app, notice.model)
|
||||||
if notice.model == 'Userprofile':
|
if notice.model == 'Userprofile':
|
||||||
pass_value = notice.record_pass_value
|
pass_value = notice.record_pass_value
|
||||||
profiles = ReplyModel.objects.filter(organization_id=notice.record_id)
|
profiles = ReplyModel.objects.filter(
|
||||||
if pass_value == '2': #市级提交,1->2, 4->5
|
organization_id=notice.record_id)
|
||||||
|
if pass_value == '2': # 市级提交,1->2, 4->5
|
||||||
for p in profiles:
|
for p in profiles:
|
||||||
if p.admin_status == 1:
|
if p.admin_status == 1:
|
||||||
p.admin_status = 2
|
p.admin_status = 2
|
||||||
|
@ -134,9 +146,9 @@ def pass_notice(request):
|
||||||
p.save()
|
p.save()
|
||||||
admins = Userprofile.level1_admin()
|
admins = Userprofile.level1_admin()
|
||||||
for a in admins:
|
for a in admins:
|
||||||
Notice.create_reply_notice(a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '3', '0')
|
Notice.create_reply_notice(
|
||||||
return JsonResponse({'status': 'success', 'message': '申请已同意'})
|
a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '3', '0')
|
||||||
else: #省级提交
|
else: # 省级提交
|
||||||
for p in profiles:
|
for p in profiles:
|
||||||
if p.admin_status == 5:
|
if p.admin_status == 5:
|
||||||
p.admin_status = 0
|
p.admin_status = 0
|
||||||
|
@ -144,6 +156,7 @@ def pass_notice(request):
|
||||||
if p.admin_status == 2:
|
if p.admin_status == 2:
|
||||||
p.admin_status = 3
|
p.admin_status = 3
|
||||||
p.save()
|
p.save()
|
||||||
|
return JsonResponse({'status': 'success', 'message': '申请已同意'})
|
||||||
else:
|
else:
|
||||||
m = ReplyModel.objects.get(pk=notice.record_id)
|
m = ReplyModel.objects.get(pk=notice.record_id)
|
||||||
setattr(m, notice.field, notice.record_pass_value)
|
setattr(m, notice.field, notice.record_pass_value)
|
||||||
|
@ -154,11 +167,13 @@ def pass_notice(request):
|
||||||
if pass_value == '2':
|
if pass_value == '2':
|
||||||
admins = Userprofile.level1_admin()
|
admins = Userprofile.level1_admin()
|
||||||
for a in admins:
|
for a in admins:
|
||||||
Notice.create_reply_notice(a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '3', '0')
|
Notice.create_reply_notice(
|
||||||
|
a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '3', '0')
|
||||||
if pass_value == '5':
|
if pass_value == '5':
|
||||||
admins = Userprofile.level1_admin()
|
admins = Userprofile.level1_admin()
|
||||||
for a in admins:
|
for a in admins:
|
||||||
Notice.create_reply_notice(a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '0', '3')
|
Notice.create_reply_notice(
|
||||||
|
a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '0', '3')
|
||||||
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错误'})
|
||||||
|
@ -178,7 +193,8 @@ def reject_notice(request):
|
||||||
ReplyModel = apps.get_model(notice.app, notice.model)
|
ReplyModel = apps.get_model(notice.app, notice.model)
|
||||||
if notice.model == 'Userprofile':
|
if notice.model == 'Userprofile':
|
||||||
reject_value = notice.record_reject_value
|
reject_value = notice.record_reject_value
|
||||||
profiles = ReplyModel.objects.filter(organization_id=notice.record_id)
|
profiles = ReplyModel.objects.filter(
|
||||||
|
organization_id=notice.record_id)
|
||||||
for p in profiles:
|
for p in profiles:
|
||||||
if p.admin_status == 1 or p.admin_status == 2:
|
if p.admin_status == 1 or p.admin_status == 2:
|
||||||
p.admin_status = 0
|
p.admin_status = 0
|
||||||
|
@ -206,5 +222,3 @@ def unread_notice_count(request):
|
||||||
user_id = request.user.id
|
user_id = request.user.id
|
||||||
count = Notice.objects.filter(user_id=user_id, is_read=False).count()
|
count = Notice.objects.filter(user_id=user_id, is_read=False).count()
|
||||||
return JsonResponse({'status': 'success', 'message': count})
|
return JsonResponse({'status': 'success', 'message': count})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue