Commit 478045c6 by Duanbj

bugfix:首页展示非公开文章、文章取消发布按钮无效

parent 607c7610
......@@ -819,7 +819,6 @@
var publish = '0';
if(thisBtn.innerText==='取消发布'){
publish = '0';
console.log(isOpen);
}else{
publish = '2'
}
......@@ -835,9 +834,11 @@
if(response['message']){
console.log(thisBtn);
if(publish ==='2'){
alert("发布成功,该文章目前为公开状态。")
$(thisBtn).empty();
$(thisBtn).append('取消发布');
}else{
alert("取消成功,该文章目前仅自己可见。")
$(thisBtn).empty();
$(thisBtn).append('发布');
}
......
......@@ -92,9 +92,10 @@ def index_html(request):
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, publish=2).order_by('-editDateTime')
# 查看7天内是否有新文章,没有则选择已发布的文章中最新的两篇
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]
newest_article = Articles.objects.filter(publish='2').order_by('-editDateTime')[:2]
for art in newest_article:
users = User.objects.filter(userID=art.authorID).values('name')
art.author = users[0]['name']
......
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