From 57723444cf707d2c8b9a6e7f4b5e1ec634d8c7b6 Mon Sep 17 00:00:00 2001 From: baoliang Date: Wed, 23 Sep 2020 17:47:05 +0800 Subject: [PATCH] add feature --- dashboard/models.py | 8 ++ polls/urls.py | 4 + polls/views/__init__.py | 7 +- .../views/__pycache__/__init__.cpython-38.pyc | Bin 850 -> 948 bytes .../__pycache__/compartment.cpython-38.pyc | Bin 895 -> 895 bytes polls/views/__pycache__/group.cpython-38.pyc | Bin 1123 -> 1146 bytes polls/views/__pycache__/media.cpython-38.pyc | Bin 3424 -> 4213 bytes polls/views/__pycache__/news.cpython-38.pyc | Bin 1189 -> 1566 bytes .../__pycache__/organizations.cpython-38.pyc | Bin 0 -> 1134 bytes polls/views/__pycache__/user.cpython-38.pyc | Bin 5362 -> 5355 bytes polls/views/compartment.py | 2 +- polls/views/group.py | 4 +- polls/views/media.py | 104 ++++++++++++------ polls/views/news.py | 18 +++ polls/views/organizations.py | 46 ++++++++ polls/views/user.py | 2 +- 16 files changed, 154 insertions(+), 41 deletions(-) create mode 100644 polls/views/__pycache__/organizations.cpython-38.pyc create mode 100644 polls/views/organizations.py diff --git a/dashboard/models.py b/dashboard/models.py index e489b0a..a8d208e 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -113,6 +113,10 @@ class Organization(models.Model): created = models.DateTimeField('创建时间', auto_now_add=True) updated = models.DateTimeField('更新时间', auto_now=True) + class Meta: + ordering = ["name"] + + def __str__(self): return self.name @@ -545,6 +549,10 @@ class Area_code_2020(models.Model): def __str__(self): return self.name + class Meta: + ordering = ["code"] + + # 新闻 diff --git a/polls/urls.py b/polls/urls.py index 7b41ac7..27e3090 100644 --- a/polls/urls.py +++ b/polls/urls.py @@ -17,7 +17,10 @@ urlpatterns = [ path('medias/create/', views.create_media, name='polls_add_media'), 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///', views.media_detail, name='polls_media_detail'), path('news/list/', views.news_list, name='polls_news'), + path('news/top/', views.news_top, name='polls_news_top'), path('news/detail//', views.news_detail, name='polls_news_detail'), path('monitor/statistics/', views.monitor_statistics, name='polls_monitor_statistics'), path('tasks/list/', views.tasks, name='polls_tasks_list'), @@ -26,4 +29,5 @@ urlpatterns = [ path('groups/list/', views.groups, name='polls_groups_list'), path('group/test-room/', views.room, name='polls_group_test_room'), path('compartments/list/', views.compartments, name='polls_compartments_list'), + path('organizations/list/', views.organizations, name='polls_organizations_list'), ] diff --git a/polls/views/__init__.py b/polls/views/__init__.py index a475e88..8c7ba9a 100644 --- a/polls/views/__init__.py +++ b/polls/views/__init__.py @@ -1,8 +1,9 @@ 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, read_notice -from .media import medias, create_media, update_media -from .news import news_list, news_detail +from .media import medias, my_medias, create_media, update_media, media_detail +from .news import news_list, news_top, news_detail from .monitor import monitor_statistics from .task import tasks, create_task, create_test_task from .group import groups, room -from .compartment import compartments \ No newline at end of file +from .compartment import compartments +from .organizations import organizations \ No newline at end of file diff --git a/polls/views/__pycache__/__init__.cpython-38.pyc b/polls/views/__pycache__/__init__.cpython-38.pyc index dcd891975e70abc32f5cbc52834b1046962c9e2a..55dffc521393a3501c1a562b80cec54643278bb9 100644 GIT binary patch delta 378 zcmW-c%}T>S5XZB%ZTd}{rr)u(sUCtt-$W59!gvV5gc7=wExRkC7jNE6p2D*VK8ASA z8~6&I+}(xw@t@z$!p=|i!|rU_?S`cew|AjeI&?hpbvVDK*n=KA;1Dae;xg@{3oZ^| zfI}D>SD_;u!`S31o!}IvID;8_;2CGrW1Pbr7qBpWjh^5VmL}J!k3RS+H*Tz;dH8N1RMfNNQG_%VvZ$FT**^ayJ2xOjoAGUwrO%N} zStc%nRlX|Sz3{Hytfx?v^$YIkzOUhGX(P*0$v7XF5gCacAL`qY##qbBma~UFpJ*{v vfaX2JeZ(aundCFAJ%u-mpX#jfceUP#go}0lTe@}i7cNMbc*G?wRb9n@T+UwR delta 268 zcmdnOeu<4Ql$V!_0SGoP$c(?hIFV0=alu6Gzz{};6owR*9Kl?nD4|^8C}A+4HAf^@ zG)ffAX3G)F6^|0nm57qam5h=Ei?QcOdnv6y4K!a|vfTV7*9kJ2ms*KA8-Hw diff --git a/polls/views/__pycache__/group.cpython-38.pyc b/polls/views/__pycache__/group.cpython-38.pyc index 60c9ef52398fc258439092b78617b8d8d8d60935..6672315d7fc7020ce179bb95f07598a510ebb2ae 100644 GIT binary patch delta 159 zcmaFN@r#2ul$V!_0SJzYX2)l4Mk zVp_Kt4R0}Jrrcu5OUzBZ#hRI$n4Wrzy|^?vIkmW0lc|UwXw)tCTp(xiTqY$(!N~`h zRHcMKf!(iAlxzIi)43@ufwXMZ%N+GsyxK$ujFRDopleRt1v9%o~BEDvKQe D4UaF% delta 158 zcmeyx@tA`*l$V!_0SKNg$c*>d$a|NOv2OBf#&YW#<`j+;&R(Wq22C!%TPy+o!6BJb z85tNf8E>%_mn4>y7MHRCwLRU_@N~lZTTGcLw^;HLb5n1zX68=b!lc9~F!?%@Dx=`! zzf2PHLO_MLm`jUtZm}g66r|>*6tMzDG}($kHWvv@HeuFhl%1TytO_K%m^T7R8x}hN DTI??U diff --git a/polls/views/__pycache__/media.cpython-38.pyc b/polls/views/__pycache__/media.cpython-38.pyc index de596b7c9c492f9605d0e4616326fd24fd39d035..e88cea752baf18e42bdb0e066c6b758796c7b6fb 100644 GIT binary patch literal 4213 zcmb7HZEqY`6`uE*eP6%DcHSD^LKl!70xeZ#N~I=gnx<}OQX#D%X1sUe%w%V0bLVc- zpm7ypkdVMMA1DY^Rn8}fiqs+@s7m?5kKn_6C2pEOfDm8cIcL_6y|Iy4YtNp0&og)K zJwDHK?|r>iD{J`NH?A%HW?Iw!L5-as3ytUTO@9X?G@*C3Sa0jG(Kd8y8(lND+7|m} z*N&aG!@kvZW3TPSrFJPUx65&*U5TshYFumAIBs|AaiiVPwZIA*!V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NnpY$n$Rjpql&WDIs()H)UHtzP^U&MKua}h16l^;pLHsF4)<~R*(|Yc<+GJ9gxz2_ zX9ViIx@DszHhd)2sl^YhpGd~7D|l2Yc_fO2_lTv5FoJ6vF`09`8wX`y=CjYc)o4D5jQp{ zl_-qzoYhe7r93h43O`A*F@#9>MP|6NK7(*n*M+g-#AQHpuQV=8XdLD4w-?&bH2{Yk z+?}fi2-}fY+6f#euE!a8!qWAe!(WlQ3(Q~JgB{J49_+<36LB#bK!xh425a}%?hkUg zCo(=L_;Jpeh;vy8BOwLgxegp034W{x*Sz)1Q*|3myFl~?2;?o{Hg4hwQ%wF)k6>~U z(f??e{H8v+pwzFqO?YSiv`KAotJkt!mO_-WuMea$$=GN`z{9Z1VtueDW5xP8Tz01C zC2lR)2ga0jx$LdQP91ok@kFW^GSYqbfhqVGAlt1|yK<%|Y}XOgHM=72IexSbF2@;v S?7ly}1fmW3wh2s^EB*_|b0yjU literal 0 HcmV?d00001 diff --git a/polls/views/__pycache__/user.cpython-38.pyc b/polls/views/__pycache__/user.cpython-38.pyc index 5d0554f85cc90d41032f15fc41bf263c4866e86f..78652180cf8ba681f0eff500c0b1d9d346235ee0 100644 GIT binary patch delta 257 zcmX|)Jxc>Y5Qb+qw|lpj?B&a^!qy^UnJU=%6GA#6&0;Z!7RQ#eh+G{IwzWt~OYyJx zCnSv#D+_T<;ZzUL1MhrJwiCB-t^~P<9W8HP+kF|Ql<|3Kw>OP}lZ8i`! z>*j_vSzpwu2_g5|Tc1Cv7UvL321ZuCTy>&hk1}#nx+}a^F^@&4 zT8Ng-|GuF&J^}JOwEkJ3?nHU*L zc(Yit_-fcvxO*96m}=Q;IZF7O8EQFe*x=@|WeL=9rZCws)Uam>0$Dsj7Aw$Z0iZ2H zKt3;spCt@r@qt+)MSp4-7Kj4HM6$#dGUhR*FaYKF!E)jt9g|sDl^G=_Yp||ll$?Bt V)r6@?Z89_4XGWgQ-`T$K0syMLK6C&8 diff --git a/polls/views/compartment.py b/polls/views/compartment.py index 20ffed4..f0a2f52 100644 --- a/polls/views/compartment.py +++ b/polls/views/compartment.py @@ -9,7 +9,7 @@ from polls.decorators import polls_login_required @csrf_exempt @polls_login_required def compartments(request): - parent_code = request.GET.get('pcode', '620000000000') + parent_code = request.GET.get('code', '620000000000') compartments = Area_code_2020.objects.filter(pcode=parent_code) results = [] for o in compartments: diff --git a/polls/views/group.py b/polls/views/group.py index c479519..1467a66 100644 --- a/polls/views/group.py +++ b/polls/views/group.py @@ -18,7 +18,7 @@ def groups(request): if request.method == 'POST': return HttpResponse(status=405) id = request.user.id - groups = Group.objects.filter(status='开启') + groups = Group.objects.filter(status='1') results = [] for o in groups: result = dict() @@ -26,4 +26,4 @@ def groups(request): result['name'] = o.name result['image'] = request.build_absolute_uri(o.image.url) results.append(result) - return JsonResponse(results, safe=False) + return JsonResponse({'status': 'success', 'message': results}, safe=False) diff --git a/polls/views/media.py b/polls/views/media.py index 4d5cd6a..0c880c2 100644 --- a/polls/views/media.py +++ b/polls/views/media.py @@ -18,39 +18,14 @@ def medias(request): @csrf_exempt @polls_login_required -def create_media(request): - profile = request.user.userprofile_set.first() - o = profile.organization - print(profile) - if request.method == 'GET': +def my_medias(request): + if request.method == 'POST': return HttpResponse(status=405) - category = request.POST.get('category') - if not category: - return JsonResponse({'status': 'error', 'message': '类型错误'}) - code = request.POST.get('code') - if not code: - return JsonResponse({'status': 'error', 'message': '公众号名称不能为空'}) - media_id = request.POST.get('media_id') - if not media_id: - return JsonResponse({'status': 'error', 'message': '公众号ID不能为空'}) - alias = request.POST.get('alias') - if not alias: - return JsonResponse({'status': 'error', 'message': '别名不能为空'}) - - if category == 'weixin': - instance = Weixin(code=code, weixinid=media_id, alias=alias, - image=request.FILES['file'], status=1, organization=o) - elif category == 'weibo': - instance = Weibo(code=code, weixinid=media_id, alias=alias, - image=request.FILES['file'], status=1, organization=o) - elif category == 'toutiao': - instance = Toutiao(code=code, weixinid=media_id, alias=alias, - image=request.FILES['file'], status=1, organization=o) - else: - instance = Qita(code=code, weixinid=media_id, alias=alias, - image=request.FILES['file'], status=1, organization=o) - instance.save() - return JsonResponse({'status': 'success'}) + user = request.user + profile = user.userprofile_set.first() + organization_id = profile.organization.id + new_medias = NewMedia.media_list(organization_id) + return JsonResponse({'status': 'success', 'message': new_medias}, safe=False) @csrf_exempt @@ -110,17 +85,78 @@ def update_media(request): value = request.POST.get('value') if not name: return JsonResponse({'status': 'error', 'message': '值不能为空'}) - + result = dict() if category == 'weixin': instance = Weixin.objects.get(pk=media_id) + result['media_id'] = instance.weixinid elif category == 'weibo': instance = Weibo.objects.get(pk=media_id) + result['media_id'] = instance.weiboid elif category == 'toutiao': instance = Toutiao.objects.get(pk=media_id) + result['media_id'] = instance.toutiaoid elif category == 'douyin': instance = Douyin.objects.get(pk=media_id) + result['media_id'] = instance.douyinid else: instance = Qita.objects.get(pk=media_id) + result['media_id'] = instance.qitaid + setattr(instance, name, value) instance.save(update_fields=[name]) - return JsonResponse({'status': 'success'}) \ No newline at end of file + 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}) + + +@csrf_exempt +@polls_login_required +def media_detail(request, type, media_id): + result = dict() + if type == 'weixin': + media = Weixin.objects.get(pk=media_id) + result['media_id'] = media.weixinid + elif type == 'weibo': + media = Weibo.objects.get(pk=media_id) + result['media_id'] = media.weiboid + elif type == 'toutiao': + media = Toutiao.objects.get(pk=media_id) + result['media_id'] = media.toutiaoid + elif type == 'douyin': + media = Douyin.objects.get(pk=media_id) + result['media_id'] = media.douyinid + else: + media = Qita.objects.get(pk=media_id) + result['media_id'] = media.qitaid + + admins = [] + for admin in media.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'] = media.id + result['code'] = media.code + result['alias'] = media.alias + result['status'] = media.status + result['attention'] = media.attention + result['remark'] = media.remark + result['organization'] = media.organization.name + result['admin'] = admins + return JsonResponse({'status': 'success', 'message': result}, safe=False) diff --git a/polls/views/news.py b/polls/views/news.py index 0a05b37..15b4020 100644 --- a/polls/views/news.py +++ b/polls/views/news.py @@ -24,6 +24,24 @@ def news_list(request): return JsonResponse({'status': 'success', 'message': results}, safe=False) +@csrf_exempt +@polls_login_required +def news_top(request): + category = request.GET.get('category', '3') + news_list = News.objects.filter(type=category)[:5] + results = [] + for o in news_list: + result = dict() + result['id'] = o.id + result['title'] = o.title + result['author'] = o.author + result['source'] = o.source + result['image'] = request.build_absolute_uri(o.image.url) if o.image else '' + result['date'] = o.date.strftime("%Y-%m-%d") + results.append(result) + return JsonResponse({'status': 'success', 'message': results}, safe=False) + + def news_detail(request, news_id): news = News.objects.get(pk=news_id) return render(request, 'polls/news_detail.html', {'news': news}) diff --git a/polls/views/organizations.py b/polls/views/organizations.py new file mode 100644 index 0000000..d8a50b8 --- /dev/null +++ b/polls/views/organizations.py @@ -0,0 +1,46 @@ +from django.shortcuts import render +from dashboard.models import Organization +from django.http import JsonResponse + +from django.views.decorators.csrf import csrf_exempt +from polls.decorators import polls_login_required + + +@csrf_exempt +@polls_login_required +def organizations(request): + category = request.GET.get('category', '1') + code = request.GET.get('code') + print(category, code) + if category == '1': + organizations = Organization.objects.exclude( + province='' + ).filter( + cities='', + district='' + ) + elif category == '2': + organizations = Organization.objects.exclude( + province='' + ).filter( + cities=code, + district='' + ) + elif category == '3': + organizations = Organization.objects.exclude( + province='', + cities='', + ).filter( + district=code + ) + results = [] + for o in organizations: + result = dict() + result['id'] = o.id + result['name'] = o.name + result['province'] = o.province + result['cities'] = o.cities + result['district'] = o.district + results.append(result) + + return JsonResponse({'status': 'success', 'message': results}, safe=False) \ No newline at end of file diff --git a/polls/views/user.py b/polls/views/user.py index b48ac16..bf3cccc 100644 --- a/polls/views/user.py +++ b/polls/views/user.py @@ -34,7 +34,7 @@ def polls_login(request): user = UserModel.objects.filter(username=phone).first() if not user: return JsonResponse({'status': 'error', 'message': '用户名或密码错误'}) - profile = request.user.userprofile_set.first() + profile = user.userprofile_set.first() if not profile or profile.status == 0: return JsonResponse({'status': 'error', 'message': '用户在审核中'})