This commit is contained in:
Bob 2020-09-13 15:22:41 +08:00
commit 42c9f4ee9c
5 changed files with 19 additions and 2 deletions

View File

@ -16,6 +16,7 @@ urlpatterns = [
path('notices/read/', views.read_notice, name='polls_read_notice'), path('notices/read/', views.read_notice, name='polls_read_notice'),
path('medias/create/', views.create_media, name='polls_add_media'), path('medias/create/', views.create_media, name='polls_add_media'),
path('medias/list/', views.medias, name='polls_medias'), path('medias/list/', views.medias, name='polls_medias'),
path('news/list/', views.news_list, name='polls_news'),
path('news/detail/', views.news_detail, name='polls_news_detail'), path('news/detail/', views.news_detail, name='polls_news_detail'),
path('monitor/statistics/', views.monitor_statistics, name='polls_monitor_statistics') path('monitor/statistics/', views.monitor_statistics, name='polls_monitor_statistics')
] ]

View File

@ -1,5 +1,5 @@
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, read_notice from .notice import notices, read_notice
from .media import medias, create_media from .media import medias, create_media
from .news import news_detail from .news import news_list, news_detail
from .monitor import monitor_statistics from .monitor import monitor_statistics

View File

@ -1,4 +1,20 @@
from django.shortcuts import render from django.shortcuts import render
from dashboard.models import News
from django.http import JsonResponse
def news_list(request):
category = request.GET.get('category','1')
news_list = News.objects.filter(type=category)
results = []
for o in news_list:
result = dict()
result['id'] = o.id
result['title'] = o.title
result['author'] = o.author
result['content'] = o.content
result['date'] = o.date
results.append(result)
return JsonResponse(results, safe=False)
def news_detail(request): def news_detail(request):
return render(request, 'polls/news_detail.html') return render(request, 'polls/news_detail.html')