Merge remote-tracking branch 'origin/master'

This commit is contained in:
Bob 2020-10-09 09:42:20 +08:00
commit de6670e3ab
15 changed files with 197 additions and 51 deletions

View File

@ -38,13 +38,14 @@ class Group(models.Model):
type = models.ForeignKey( type = models.ForeignKey(
Group_type, on_delete=models.CASCADE, null=True, blank=True) Group_type, on_delete=models.CASCADE, null=True, blank=True)
status = models.IntegerField( status = models.IntegerField(
'状态', null=True, blank=True,default=0) '状态', null=True, blank=True, default=0)
province = models.CharField('', max_length=256, null=True, blank=True) province = models.CharField('', max_length=256, null=True, blank=True)
cities = models.CharField('', max_length=256, null=True, blank=True) cities = models.CharField('', max_length=256, null=True, blank=True)
district = models.CharField('', max_length=256, null=True, blank=True) district = models.CharField('', max_length=256, null=True, blank=True)
town = models.CharField('', max_length=256, null=True, blank=True) town = models.CharField('', max_length=256, null=True, blank=True)
village = models.CharField('', max_length=256, null=True, blank=True) village = models.CharField('', max_length=256, null=True, blank=True)
classify = models.CharField('分类',max_length=256,null=True,blank=True,choices=GROUP_CLASSIFY_CHOICES) classify = models.CharField(
'分类', max_length=256, null=True, blank=True, choices=GROUP_CLASSIFY_CHOICES)
user = models.ForeignKey( user = models.ForeignKey(
User, on_delete=models.CASCADE, blank=True, null=True) User, on_delete=models.CASCADE, blank=True, null=True)
@ -112,7 +113,7 @@ class Organization(models.Model):
level = models.ForeignKey( level = models.ForeignKey(
Level, on_delete=models.CASCADE, null=True, blank=True) Level, on_delete=models.CASCADE, null=True, blank=True)
directly = models.CharField('单位类型', max_length=256, null=True, blank=True) directly = models.CharField('单位类型', max_length=256, null=True, blank=True)
status = models.CharField('状态',max_length=256,null=True,blank=True) status = models.CharField('状态', max_length=256, null=True, blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True) created = models.DateTimeField('创建时间', auto_now_add=True)
updated = models.DateTimeField('更新时间', auto_now=True) updated = models.DateTimeField('更新时间', auto_now=True)
@ -148,6 +149,15 @@ class Userprofile(models.Model):
def is_level2(self): def is_level2(self):
return self.organization.level.level == 2 return self.organization.level.level == 2
@classmethod
def level2_admin(cls, cities):
return Userprofile.objects.filter(organization__level__level=2, organization__cities=cities)
@classmethod
def level1_admin(cls):
return Userprofile.objects.filter(organization__level__level=1)
def __str__(self): def __str__(self):
return self.user.username+":"+self.name return self.user.username+":"+self.name
@ -169,7 +179,7 @@ class NewMedia(models.Model):
organization = models.ForeignKey( organization = models.ForeignKey(
Organization, on_delete=models.CASCADE, null=True, blank=True) Organization, on_delete=models.CASCADE, null=True, blank=True)
status = models.IntegerField( status = models.IntegerField(
'状态',null=True, blank=True,default=0) '状态', null=True, blank=True, default=0)
attention = models.CharField('关注量', null=True, blank=True, max_length=256) attention = models.CharField('关注量', null=True, blank=True, max_length=256)
remark = models.CharField('备注', null=True, blank=True, max_length=2560) remark = models.CharField('备注', null=True, blank=True, max_length=2560)
created = models.DateTimeField('创建时间', auto_now_add=True) created = models.DateTimeField('创建时间', auto_now_add=True)
@ -278,17 +288,23 @@ class NewMedia(models.Model):
@classmethod @classmethod
def media_list(cls, organization_id): def media_list(cls, organization_id):
weixin = Weixin.objects.filter(organization_id=organization_id) weixin = Weixin.objects.filter(
weibo = Weibo.objects.filter(organization_id=organization_id) organization_id=organization_id).exclude(status=0)
toutiao = Toutiao.objects.filter(organization_id=organization_id) weibo = Weibo.objects.filter(
douyin = Douyin.objects.filter(organization_id=organization_id) organization_id=organization_id).exclude(status=0)
qita = Qita.objects.filter(organization_id=organization_id) toutiao = Toutiao.objects.filter(
organization_id=organization_id).exclude(status=0)
douyin = Douyin.objects.filter(
organization_id=organization_id).exclude(status=0)
qita = Qita.objects.filter(
organization_id=organization_id).exclude(status=0)
results = [] results = []
for o in weixin: for o in weixin:
result = dict() result = dict()
result['id'] = o.id result['id'] = o.id
result['code'] = o.code result['code'] = o.code
result['alias'] = o.alias result['alias'] = o.alias
result['status'] = o.status
result['type'] = 'weixin' result['type'] = 'weixin'
results.append(result) results.append(result)
for o in weibo: for o in weibo:
@ -296,6 +312,7 @@ class NewMedia(models.Model):
result['id'] = o.id result['id'] = o.id
result['code'] = o.code result['code'] = o.code
result['alias'] = o.alias result['alias'] = o.alias
result['status'] = o.status
result['type'] = 'weibo' result['type'] = 'weibo'
results.append(result) results.append(result)
for o in toutiao: for o in toutiao:
@ -303,6 +320,7 @@ class NewMedia(models.Model):
result['id'] = o.id result['id'] = o.id
result['code'] = o.code result['code'] = o.code
result['alias'] = o.alias result['alias'] = o.alias
result['status'] = o.status
result['type'] = 'toutiao' result['type'] = 'toutiao'
results.append(result) results.append(result)
for o in douyin: for o in douyin:
@ -310,6 +328,7 @@ class NewMedia(models.Model):
result['id'] = o.id result['id'] = o.id
result['code'] = o.code result['code'] = o.code
result['alias'] = o.alias result['alias'] = o.alias
result['status'] = o.status
result['type'] = 'douyin' result['type'] = 'douyin'
results.append(result) results.append(result)
for o in qita: for o in qita:
@ -317,11 +336,11 @@ class NewMedia(models.Model):
result['id'] = o.id result['id'] = o.id
result['code'] = o.code result['code'] = o.code
result['alias'] = o.alias result['alias'] = o.alias
result['status'] = o.status
result['type'] = 'qita' result['type'] = 'qita'
results.append(result) results.append(result)
return results return results
def __str__(self): def __str__(self):
return self.code + ':' + self.alias return self.code + ':' + self.alias

View File

@ -71,8 +71,8 @@ class Notice(models.Model):
return Notice.objects.create(user_id=user_id, content=content) return Notice.objects.create(user_id=user_id, content=content)
@classmethod @classmethod
def create_reply_notice(cls, user_id, content, app, model, field, record_id, record_value): def create_reply_notice(cls, user_id, content, app, model, field, record_id, record_pass_value, record_reject_value):
return Notice.objects.create(type=1, user_id=user_id, content=content, app=app, model=model, field=field, record_id=record_id, record_value=record_value) return Notice.objects.create(type=1, user_id=user_id, content=content, app=app, model=model, field=field, record_id=record_id, record_pass_value=record_pass_value, record_reject_value=record_reject_value)
def __str__(self): def __str__(self):
return self.content + ':' + self.user.username return self.content + ':' + self.user.username
@ -143,24 +143,31 @@ class Message(models.Model):
id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) id = models.UUIDField('id', primary_key=True, default=uuid.uuid4)
send_from = models.ForeignKey(User, on_delete=models.CASCADE) send_from = models.ForeignKey(User, on_delete=models.CASCADE)
send_to = models.ForeignKey(Group, on_delete=models.CASCADE) send_to = models.ForeignKey(Group, on_delete=models.CASCADE)
task = models.ForeignKey(Task, on_delete=models.CASCADE, null=True, blank=True) task = models.ForeignKey(
Task, on_delete=models.CASCADE, null=True, blank=True)
type = models.IntegerField( type = models.IntegerField(
'Type', choices=MESSAGE_TYPE_CHOICES, default=1) 'Type', choices=MESSAGE_TYPE_CHOICES, default=1)
#text # text
content = models.TextField('内容', null=True, blank=True) content = models.TextField('内容', null=True, blank=True)
#url # url
page_title = models.CharField('page_title', max_length=256, null=True, blank=True) page_title = models.CharField(
page_description = models.CharField('page_description', max_length=512, null=True, blank=True) 'page_title', max_length=256, null=True, blank=True)
page_image = models.CharField('page_image', max_length=256, null=True, blank=True) page_description = models.CharField(
'page_description', max_length=512, null=True, blank=True)
page_image = models.CharField(
'page_image', max_length=256, null=True, blank=True)
url = models.CharField('url', max_length=256, null=True, blank=True) url = models.CharField('url', max_length=256, null=True, blank=True)
#file # file
file_title = models.CharField('file_title', max_length=256, null=True, blank=True) file_title = models.CharField(
'file_title', max_length=256, null=True, blank=True)
file = models.CharField('file', max_length=256, null=True, blank=True) file = models.CharField('file', max_length=256, null=True, blank=True)
#image # image
image_title = models.CharField('image_title', max_length=256, null=True, blank=True) image_title = models.CharField(
picture = models.CharField('picture', max_length=256, null=True, blank=True) 'image_title', max_length=256, null=True, blank=True)
picture = models.CharField(
'picture', max_length=256, null=True, blank=True)
added = models.DateTimeField(auto_now_add=True) added = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True) updated = models.DateTimeField(auto_now=True)

View File

@ -17,13 +17,16 @@ urlpatterns = [
path('notices/list/', views.notices, name='polls_notices'), path('notices/list/', views.notices, name='polls_notices'),
path('notices/top/', views.notice_top, name='polls_notice_top'), path('notices/top/', views.notice_top, name='polls_notice_top'),
path('notices/read/', views.read_notice, name='polls_read_notice'), path('notices/read/', views.read_notice, name='polls_read_notice'),
path('notices/reply/', views.reply_notice, name='polls_reply_notice'), path('notices/pass/', views.pass_notice, name='polls_pass_notice'),
path('notices/reject/', views.reject_notice, name='polls_reject_notice'),
path('notices/detail/<str:notice_id>/', views.detail_notice, name='polls_detail_notice'),
path('medias/create/', views.create_media, name='polls_add_media'), path('medias/create/', views.create_media, name='polls_add_media'),
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/<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('news/list/', views.news_list, name='polls_news'), path('news/list/', views.news_list, name='polls_news'),
path('news/top/', views.news_top, name='polls_news_top'), path('news/top/', views.news_top, name='polls_news_top'),
path('news/detail/<str:news_id>/', path('news/detail/<str:news_id>/',

View File

@ -1,10 +1,10 @@
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 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
from .notice import notices, notice_top, read_notice, reply_notice from .notice import notices, notice_top, read_notice, pass_notice, reject_notice, detail_notice
from .media import medias, my_medias, create_media, update_media, media_detail from .media import medias, my_medias, create_media, update_media, media_detail, delete_media
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 from .monitor import monitor_statistics, monitor_result
from .task import tasks, create_task, create_test_task from .task import tasks, create_task, create_test_task
from .group import groups, room from .group import groups, room
from .compartment import compartments from .compartment import compartments
from .organizations import organizations, organization_level from .organizations import organizations, organization_level
from .message import last_messages, send_text_message from .message import last_messages, send_text_message

View File

@ -9,8 +9,12 @@ from polls.decorators import polls_login_required
@csrf_exempt @csrf_exempt
@polls_login_required @polls_login_required
def compartments(request): def compartments(request):
level = request.GET.get('level')
parent_code = request.GET.get('code', '620000000000') parent_code = request.GET.get('code', '620000000000')
compartments = Area_code_2020.objects.filter(pcode=parent_code) if level == '2':
compartments = Area_code_2020.objects.filter(code=parent_code)
else:
compartments = Area_code_2020.objects.filter(pcode=parent_code)
results = [] results = []
for o in compartments: for o in compartments:
result = dict() result = dict()

View File

@ -18,7 +18,11 @@ def groups(request):
if request.method == 'POST': if request.method == 'POST':
return HttpResponse(status=405) return HttpResponse(status=405)
id = request.user.id id = request.user.id
groups = Group.objects.filter(status='1') category = request.GET.get('category', '0')
if not category:
return JsonResponse({'status': 'error', 'message': '参数错误'})
groups = Group.objects.filter(status='1',classify=category)
results = [] results = []
for o in groups: for o in groups:
result = dict() result = dict()

View File

@ -55,29 +55,30 @@ def create_media(request):
if category == 'weixin': if category == 'weixin':
model_name = 'Weixin' model_name = 'Weixin'
instance = Weixin(code=code, weixinid=media_id, alias=alias, instance = Weixin(code=code, weixinid=media_id, alias=alias,
image=f, status=0, organization=o, attention=attention, remark=remark) image=f, status=1, organization=o, attention=attention, remark=remark)
elif category == 'weibo': elif category == 'weibo':
model_name = 'Weibo' model_name = 'Weibo'
instance = Weibo(code=code, weiboid=media_id, alias=alias, instance = Weibo(code=code, weiboid=media_id, alias=alias,
image=f, status=0, organization=o, attention=attention, remark=remark) image=f, status=1, organization=o, attention=attention, remark=remark)
elif category == 'toutiao': elif category == 'toutiao':
model_name = 'Toutiao' model_name = 'Toutiao'
instance = Toutiao(code=code, toutiaoid=media_id, alias=alias, instance = Toutiao(code=code, toutiaoid=media_id, alias=alias,
image=f, status=0, organization=o, attention=attention, remark=remark) image=f, status=1, organization=o, attention=attention, remark=remark)
elif category == 'douyin': elif category == 'douyin':
model_name = 'Douyin' model_name = 'Douyin'
instance = Douyin(code=code, douyinid=media_id, alias=alias, instance = Douyin(code=code, douyinid=media_id, alias=alias,
image=f, status=0, organization=o, attention=attention, remark=remark) image=f, status=1, organization=o, attention=attention, remark=remark)
else: else:
model_name = 'Qita' model_name = 'Qita'
type = request.POST.get('type') type = request.POST.get('type')
instance = Qita(code=code, qitaid=media_id, alias=alias, instance = Qita(code=code, qitaid=media_id, alias=alias,
image=f, status=0, organization=o, attention=attention, remark=remark) image=f, status=1, organization=o, attention=attention, remark=remark)
instance.save() instance.save()
admins = Userprofile.objects.filter(organization__level__level=1) admins = Userprofile.level2_admin(instance.organization.cities)
for a in admins: for a in admins:
content = '用户%s创建了新媒体,请审核' % (profile.name,) content = '用户%s创建了新媒体,请审核' % (profile.name,)
Notice.create_reply_notice(a.user.id, content, 'dashboard', model_name, 'status', instance.id, '1') Notice.create_reply_notice(
a.user.id, content, 'dashboard', model_name, 'status', instance.id, '2', '0')
return JsonResponse({'status': 'success'}) return JsonResponse({'status': 'success'})
@ -97,7 +98,7 @@ def update_media(request):
if not name: if not name:
return JsonResponse({'status': 'error', 'message': '名称不能为空'}) return JsonResponse({'status': 'error', 'message': '名称不能为空'})
value = request.POST.get('value') value = request.POST.get('value')
if not name: if not value:
return JsonResponse({'status': 'error', 'message': '值不能为空'}) return JsonResponse({'status': 'error', 'message': '值不能为空'})
result = dict() result = dict()
if category == 'weixin': if category == 'weixin':
@ -156,7 +157,7 @@ def media_detail(request, type, media_id):
else: else:
media = Qita.objects.get(pk=media_id) media = Qita.objects.get(pk=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.all():
u = dict() u = dict()
@ -174,3 +175,65 @@ def media_detail(request, type, media_id):
result['organization'] = media.organization.name result['organization'] = media.organization.name
result['admin'] = admins result['admin'] = admins
return JsonResponse({'status': 'success', 'message': result}, safe=False) return JsonResponse({'status': 'success', 'message': result}, safe=False)
@csrf_exempt
@polls_login_required
def delete_media(request):
if request.method == 'GET':
return HttpResponse(status=405)
profile = request.user.userprofile_set.first()
o = profile.organization
category = request.POST.get('category')
if not category:
return JsonResponse({'status': 'error', 'message': '参数错误'})
media_id = request.POST.get('media_id')
if not media_id:
return JsonResponse({'status': 'error', 'message': '参数错误'})
result = dict()
if category == 'weixin':
model_name = 'Weixin'
instance = Weixin.objects.get(pk=media_id)
result['media_id'] = instance.weixinid
elif category == 'weibo':
model_name = 'Weibo'
instance = Weibo.objects.get(pk=media_id)
result['media_id'] = instance.weiboid
elif category == 'toutiao':
model_name = 'Toutiao'
instance = Toutiao.objects.get(pk=media_id)
result['media_id'] = instance.toutiaoid
elif category == 'douyin':
model_name = 'Douyin'
instance = Douyin.objects.get(pk=media_id)
result['media_id'] = instance.douyinid
else:
model_name = 'Qita'
instance = Qita.objects.get(pk=media_id)
result['media_id'] = instance.qitaid
instance.status = 4
instance.save()
admins = Userprofile.level2_admin(instance.organization.cities)
for a in admins:
content = '用户%s申请注销新媒体,请审核' % (profile.name,)
Notice.create_reply_notice(
a.user.id, content, 'dashboard', model_name, 'status', instance.id, '5', '3')
admins = []
for admin in instance.organization.userprofile_set.all():
u = dict()
u['id'] = admin.user.id
u['name'] = admin.name
u['phone'] = admin.user.username
admins.append(u)
result['id'] = instance.id
result['code'] = instance.code
result['alias'] = instance.alias
result['status'] = instance.status
result['attention'] = instance.attention
result['remark'] = instance.remark
result['organization'] = instance.organization.name
result['admin'] = admins
return JsonResponse({'status': 'success', 'message': result})

View File

@ -7,6 +7,7 @@ import datetime
from polls.decorators import polls_login_required from polls.decorators import polls_login_required
from polls.models import Notice from polls.models import Notice
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from dashboard.models import Userprofile
@csrf_exempt @csrf_exempt
@ -22,6 +23,7 @@ def notices(request):
result['id'] = o.id result['id'] = o.id
result['type'] = o.type result['type'] = o.type
result['content'] = o.content result['content'] = o.content
result['isRead'] = o.is_read
result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S") result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S")
results.append(result) results.append(result)
return JsonResponse({'status': 'success', 'message': results}, safe=False) return JsonResponse({'status': 'success', 'message': results}, safe=False)
@ -40,6 +42,7 @@ def notice_top(request):
result['id'] = o.id result['id'] = o.id
result['type'] = o.type result['type'] = o.type
result['content'] = o.content result['content'] = o.content
result['isRead'] = o.is_read
result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S") result['added'] = o.added.strftime("%Y-%m-%d %H:%M:%S")
results.append(result) results.append(result)
return JsonResponse({'status': 'success', 'message': results}, safe=False) return JsonResponse({'status': 'success', 'message': results}, safe=False)
@ -66,9 +69,8 @@ def read_notice(request):
@csrf_exempt @csrf_exempt
@polls_login_required @polls_login_required
def detail_notice(request, notice_id): def detail_notice(request, notice_id):
if request.method == 'GET': if request.method == 'POST':
return HttpResponse(status=405) return HttpResponse(status=405)
notice_id = request.POST.get('notice')
if not notice_id: if not notice_id:
return JsonResponse({'status': 'error', 'message': '通知ID错误'}) return JsonResponse({'status': 'error', 'message': '通知ID错误'})
try: try:
@ -77,14 +79,25 @@ def detail_notice(request, notice_id):
results['id'] = notice.id results['id'] = notice.id
results['category'] = notice.type results['category'] = notice.type
results['content'] = notice.content results['content'] = notice.content
results['app'] = notice.app ReplyModel = apps.get_model(notice.app, notice.model)
results['model'] = notice.model m = ReplyModel.objects.get(pk=notice.record_id)
results['field'] = notice.field detail = dict()
results['record_id'] = notice.record_id detail['id'] = m.id
results['record_pass_value'] = notice.record_pass_value detail['code'] = m.code
results['record_reject_value'] = notice.record_reject_value 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
results['added'] = notice.added.strftime("%Y-%m-%d %H:%M:%S") results['added'] = notice.added.strftime("%Y-%m-%d %H:%M:%S")
result['updated'] = notice.updated.strftime("%Y-%m-%d %H:%M:%S") results['updated'] = notice.updated.strftime("%Y-%m-%d %H:%M:%S")
return JsonResponse({'status': 'success', 'message': results}) return JsonResponse({'status': 'success', 'message': results})
except ObjectDoesNotExist: except ObjectDoesNotExist:
return JsonResponse({'status': 'error', 'message': '通知ID错误'}) return JsonResponse({'status': 'error', 'message': '通知ID错误'})
@ -92,7 +105,7 @@ def detail_notice(request, notice_id):
@csrf_exempt @csrf_exempt
@polls_login_required @polls_login_required
def reply_notice(request): def pass_notice(request):
if request.method == 'GET': if request.method == 'GET':
return HttpResponse(status=405) return HttpResponse(status=405)
id = request.user.id id = request.user.id
@ -103,8 +116,41 @@ def reply_notice(request):
notice = Notice.objects.get(id=notice_id) notice = Notice.objects.get(id=notice_id)
ReplyModel = apps.get_model(notice.app, notice.model) ReplyModel = apps.get_model(notice.app, notice.model)
m = ReplyModel.objects.get(pk=notice.record_id) m = ReplyModel.objects.get(pk=notice.record_id)
setattr(m, notice.field, notice.record_value) setattr(m, notice.field, notice.record_pass_value)
m.save(update_fields=[notice.field]) m.save(update_fields=[notice.field])
return JsonResponse({'status': 'success'}) notice.is_read = True
notice.save()
pass_value = notice.record_pass_value
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')
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')
return JsonResponse({'status': 'success', 'message': '申请已同意'})
except ObjectDoesNotExist:
return JsonResponse({'status': 'error', 'message': '通知ID错误'})
@csrf_exempt
@polls_login_required
def reject_notice(request):
if request.method == 'GET':
return HttpResponse(status=405)
id = request.user.id
notice_id = request.POST.get('notice_id')
if not notice_id:
return JsonResponse({'status': 'error', 'message': '通知ID错误'})
try:
notice = Notice.objects.get(id=notice_id)
ReplyModel = apps.get_model(notice.app, notice.model)
m = ReplyModel.objects.get(pk=notice.record_id)
setattr(m, notice.field, notice.record_reject_value)
m.save(update_fields=[notice.field])
notice.is_read = True
notice.save()
return JsonResponse({'status': 'success', 'message': '申请已拒绝'})
except ObjectDoesNotExist: except ObjectDoesNotExist:
return JsonResponse({'status': 'error', 'message': '通知ID错误'}) return JsonResponse({'status': 'error', 'message': '通知ID错误'})

View File

@ -57,4 +57,4 @@ def organization_level(request):
level = organization.level.level level = organization.level.level
if not level: if not level:
return JsonResponse({'status': 'error', 'message': '权限错误'}) return JsonResponse({'status': 'error', 'message': '权限错误'})
return JsonResponse({'status': 'success', 'message': {'level': level, 'organization_id': organization.id}}, safe=False) return JsonResponse({'status': 'success', 'message': {'level': level, 'cities': organization.cities, 'district': organization.district}}, safe=False)