Commit f7efaad1 by liuyingying

修改最新动态读取方式

parent ff3668d3
......@@ -83,14 +83,18 @@ def index_html(request):
article_year_list[year] = [art]
newest_post_list = {}
# 读取最近7天内动态
# 读取最近7天内动态,若读取最新论文4篇;文章2篇;CVE2条
start = datetime.datetime.now().date()-datetime.timedelta(hours=23*7, minutes=59, seconds=59)
newest_publication = Publications.objects.filter(date__gte=start, isOpen='1').order_by('-editDateTime')
if newest_publication.count() < 1:
newest_publication = Publications.objects.filter(isOpen='1').order_by('-editDateTime')[:4]
for pub in newest_publication:
pub.author = pub.uploadByUser
pub.url = '/static/publications/'+pub.link.split('/')[-1]
pub.date = str(pub.date)[5:10]
newest_article = Articles.objects.filter(editDateTime__gte=start).order_by('-editDateTime')
newest_article = Articles.objects.filter(editDateTime__gte=start, publish=2).order_by('-editDateTime')
if newest_article.count() < 1:
newest_article = Articles.objects.all().order_by('-editDateTime')[:2]
for art in newest_article:
users = User.objects.filter(userID=art.authorID).values('name')
art.author = users[0]['name']
......@@ -98,19 +102,13 @@ def index_html(request):
art.date = str(art.editDateTime)[5:10]
newest_cve = Bugs.objects.filter(datetime__gte=start).order_by('-datetime')
if newest_cve.count() < 1:
newest_cve = Bugs.objects.all().order_by('-datetime')[:2]
for cve in newest_cve:
cve.title = cve.identifier
cve.author = cve.owner
cve.date = str(cve.datetime)[5:10]
# 读取最新论文4篇;文章2篇;CVE2条
if newest_publication.count() < 1:
newest_publication = Publications.objects.all().order_by('-editDateTime')[:4]
if newest_article.count() < 1:
newest_article = Articles.objects.all().order_by('-editDateTime')[:2]
if newest_cve.count() < 1:
newest_cve = Bugs.objects.all().order_by('-datetime')[:2]
newest_post_list['publication'] = newest_publication
newest_post_list['article'] = newest_article
newest_post_list['cve'] = newest_cve
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment