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/list/', views.medias, name='polls_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>/',
|
||||
views.media_detail, name='polls_media_detail'),
|
||||
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 .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 .monitor import monitor_statistics, monitor_result, media_statistics, city_ranking
|
||||
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.views.decorators.csrf import csrf_exempt
|
||||
from django.core.paginator import Paginator
|
||||
from datetime import datetime
|
||||
|
||||
from dashboard.models import Douyin, NewMedia, Qita, Toutiao, Userprofile, Weibo, Weixin
|
||||
from polls.decorators import polls_login_required
|
||||
|
@ -169,11 +170,12 @@ def media_detail(request, type, media_id):
|
|||
result['media_id'] = media.qitaid
|
||||
|
||||
admins = []
|
||||
for admin in media.organization.userprofile_set.all():
|
||||
for admin in media.organization.userprofile_set.exclude(admin_status=0):
|
||||
u = dict()
|
||||
u['id'] = admin.user.id
|
||||
u['name'] = admin.name
|
||||
u['phone'] = admin.user.username
|
||||
u['adminStatus'] = admin.admin_status
|
||||
admins.append(u)
|
||||
|
||||
result['id'] = media.id
|
||||
|
@ -280,9 +282,11 @@ def media_admin_change(request):
|
|||
UserModel = get_user_model()
|
||||
|
||||
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:
|
||||
p = Userprofile.objects.create(obj, organization=o, admin_status=2)
|
||||
p = Userprofile.objects.create(
|
||||
user=obj, name=name, organization=o, admin_status=2)
|
||||
else:
|
||||
obj.admin_status = 2
|
||||
obj.save()
|
||||
|
@ -292,11 +296,14 @@ def media_admin_change(request):
|
|||
for a in managers:
|
||||
content = '%s申请变更管理员,请审核' % (operator,)
|
||||
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:
|
||||
obj, created = UserModel.objects.get_or_create(username=phone)
|
||||
obj, created = UserModel.objects.get_or_create(
|
||||
username=phone, last_login=datetime.now())
|
||||
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:
|
||||
obj.admin_status = 1
|
||||
obj.save()
|
||||
|
@ -306,5 +313,5 @@ def media_admin_change(request):
|
|||
for a in managers:
|
||||
content = '%s申请变更管理员,请审核' % (operator,)
|
||||
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):
|
||||
if request.method == 'POST':
|
||||
return HttpResponse(status=405)
|
||||
print(notice_id, (not notice_id))
|
||||
if not notice_id:
|
||||
return JsonResponse({'status': 'error', 'message': '通知ID错误'})
|
||||
try:
|
||||
|
@ -82,22 +81,34 @@ def detail_notice(request, notice_id):
|
|||
results['content'] = notice.content
|
||||
if notice.type == 1:
|
||||
ReplyModel = apps.get_model(notice.app, notice.model)
|
||||
m = ReplyModel.objects.get(pk=notice.record_id)
|
||||
detail = dict()
|
||||
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'
|
||||
if notice.model == 'Userprofile':
|
||||
profiles = ReplyModel.objects.filter(organization_id=notice.record_id).exclude(
|
||||
admin_status__in=[0, 3])
|
||||
m = []
|
||||
for p in profiles:
|
||||
n = dict()
|
||||
n['id'] = p.user_id
|
||||
n['name'] = p.name
|
||||
n['adminStatus'] = p.admin_status
|
||||
m.append(n)
|
||||
results['profiles'] = m
|
||||
else:
|
||||
detail['type'] = 'qita'
|
||||
detail['status'] = m.status
|
||||
results['media'] = detail
|
||||
m = ReplyModel.objects.get(pk=notice.record_id)
|
||||
detail = dict()
|
||||
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:
|
||||
results['groupId'] = notice.group_id
|
||||
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)
|
||||
if notice.model == 'Userprofile':
|
||||
pass_value = notice.record_pass_value
|
||||
profiles = ReplyModel.objects.filter(organization_id=notice.record_id)
|
||||
if pass_value == '2': #市级提交,1->2, 4->5
|
||||
profiles = ReplyModel.objects.filter(
|
||||
organization_id=notice.record_id)
|
||||
if pass_value == '2': # 市级提交,1->2, 4->5
|
||||
for p in profiles:
|
||||
if p.admin_status == 1:
|
||||
p.admin_status = 2
|
||||
|
@ -134,9 +146,9 @@ def pass_notice(request):
|
|||
p.save()
|
||||
admins = Userprofile.level1_admin()
|
||||
for a in admins:
|
||||
Notice.create_reply_notice(a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '3', '0')
|
||||
return JsonResponse({'status': 'success', 'message': '申请已同意'})
|
||||
else: #省级提交
|
||||
Notice.create_reply_notice(
|
||||
a.user.id, notice.content, notice.app, notice.model, notice.field, notice.record_id, '3', '0')
|
||||
else: # 省级提交
|
||||
for p in profiles:
|
||||
if p.admin_status == 5:
|
||||
p.admin_status = 0
|
||||
|
@ -144,6 +156,7 @@ def pass_notice(request):
|
|||
if p.admin_status == 2:
|
||||
p.admin_status = 3
|
||||
p.save()
|
||||
return JsonResponse({'status': 'success', 'message': '申请已同意'})
|
||||
else:
|
||||
m = ReplyModel.objects.get(pk=notice.record_id)
|
||||
setattr(m, notice.field, notice.record_pass_value)
|
||||
|
@ -154,11 +167,13 @@ def pass_notice(request):
|
|||
if pass_value == '2':
|
||||
admins = Userprofile.level1_admin()
|
||||
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':
|
||||
admins = Userprofile.level1_admin()
|
||||
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': '申请已同意'})
|
||||
except ObjectDoesNotExist:
|
||||
return JsonResponse({'status': 'error', 'message': '通知ID错误'})
|
||||
|
@ -178,7 +193,8 @@ def reject_notice(request):
|
|||
ReplyModel = apps.get_model(notice.app, notice.model)
|
||||
if notice.model == 'Userprofile':
|
||||
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:
|
||||
if p.admin_status == 1 or p.admin_status == 2:
|
||||
p.admin_status = 0
|
||||
|
@ -206,5 +222,3 @@ def unread_notice_count(request):
|
|||
user_id = request.user.id
|
||||
count = Notice.objects.filter(user_id=user_id, is_read=False).count()
|
||||
return JsonResponse({'status': 'success', 'message': count})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue