Commit f12f4069 by Xu Zhou

内部文章在index中不可见;修改文章列表样式未table。

parent f56f7c45
......@@ -55,7 +55,7 @@ class PubToUser(models.Model):
username = models.CharField(max_length=50)
userID = models.IntegerField(default=0)
#publish=0 用户私有,publish=1 组内可见,publish=2 公开
class Articles(models.Model):
articleID = models.BigIntegerField(primary_key=True)
authorID = models.IntegerField()
......
......@@ -293,7 +293,7 @@ svg{
}
.list_private_art {
width:100%;
height:50px;
height:100px;
line-height: 50px;
}
.user_score_List>.list_head >ul> li,.list_score_body > li{
......
......@@ -81,9 +81,9 @@
<!--Publication列表-->
<div id="paperadmin" class="userlist" style="border:1px solid #000;">
<span id="user_score_List" style="color:#ff9800" >发表文章</span>
<table class="table tableList">
<thead>
</thead>
<tbody>
{% for publication in publications %}
......@@ -109,21 +109,29 @@
<!--内部文章管理-->
<div id="privateArtadmin" class="userlist" style="border:1px solid #000;">
<div class="list_private_art">
<ul id="articleList" class="node-list">
<span id="user_score_List" style="color:#ff9800" >内部文档</span>
<table class="table tableList">
<thead>
</thead>
<tbody>
{% for article in articles %}
<li>
<div class="article-content">
<tr>
<td class="col-sm-8 col-md-8" style="color:#ff9800">
<button class="title" onclick=getArticle({{ article.articleID }})>{{ article.title }}</button>
<span>{{ article.publish }}</span>
<span>{{ article.editDateTime }}</span>
</td>
<td class="col-sm-2 col-md-2 col-md-offset-2">
{{ article.publish }}
</td>
<td class="col-sm-2 col-md-2 col-md-offset-2">{{ article.editDateTime }}</td>
<td class="col-sm-2 col-md-2 col-md-offset-2">
<a class="editbtn" title="编辑" target="_blank" href="/write/?title={{ article.title }}"><?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1538270903865" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3673" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M607.232 896a32 32 0 1 1 0 64H192a96 96 0 0 1-96-96V160a96 96 0 0 1 96-96h544a96 96 0 0 1 96 96 32 32 0 0 1-64 0 32 32 0 0 0-32-32H192a32 32 0 0 0-32 32v704a32 32 0 0 0 32 32h415.232zM832 585.76v146.656c0 42.656-64 42.656-64 0v-146.656c0-42.688 64-42.688 64 0z" p-id="3674" fill="#ea6f5a"></path><path d="M288 320a32 32 0 1 1 0-64h224a32 32 0 0 1 0 64H288zM288 480a32 32 0 0 1 0-64h128a32 32 0 0 1 0 64H288zM639.424 926.592a32 32 0 1 1-64 0L576 800a96 96 0 0 1 96-96l127.744 1.152a32 32 0 1 1 0 64L672 768a32 32 0 0 0-32 32l-0.576 126.592z" p-id="3675" fill="#ea6f5a"></path><path d="M637.92 947.648a32 32 0 1 1-44.32-46.208l180.384-172.992a32 32 0 1 1 44.288 46.176l-180.352 173.024zM880.896 334.528a31.424 31.424 0 0 0 3.328-44.416l-0.416-0.512a32 32 0 0 0-44.896-3.36L408.32 652.288l-15.2 51.84 58.336-4.544 429.44-365.056z m51.616-86.4a95.36 95.36 0 0 1-9.408 134.496l-438.08 372.448a32 32 0 0 1-18.24 7.52l-114.944 8.896a32 32 0 0 1-33.184-40.928l30.944-105.472a32 32 0 0 1 9.984-15.36L797.408 237.504a96 96 0 0 1 134.688 10.112l0.416 0.512z" p-id="3676" fill="#ea6f5a"></path></svg></a>
<button class="delebtn" title="删除" onclick="deleteArt(this)"><?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1539054739914" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2718" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M861.012317 164.091494C765.809507 68.885661 639.229448 16.455901 504.590713 16.455901S243.372927 68.885661 148.170117 164.091494C52.965291 259.293296 0.534525 385.874363 0.534525 520.51209c0 134.639743 52.430767 261.217786 147.635592 356.422612 95.20281 95.20281 221.782869 147.633577 356.420596 147.633577s261.217786-52.430767 356.420596-147.633577c95.204825-95.204825 147.635592-221.783877 147.635592-356.422612C1008.646902 385.874363 956.217143 259.293296 861.012317 164.091494zM791.219829 810.54584c-4.394084 4.393077-10.152441 6.590623-15.910797 6.590623-5.759364 0-11.518728-2.197546-15.911805-6.590623L504.590713 555.740334 249.785207 810.54584c-4.394084 4.393077-10.152441 6.590623-15.911805 6.590623-5.758356 0-11.516713-2.197546-15.910797-6.590623-8.788169-8.788169-8.788169-23.036448 0-31.824617L472.767104 523.916725 219.336953 270.485566c-8.788169-8.788169-8.788169-23.036448 0-31.824617 8.788169-8.785146 23.035441-8.785146 31.823609 0l253.431158 253.431158 253.431158-253.431158c8.788169-8.785146 23.035441-8.785146 31.823609 0 8.788169 8.788169 8.788169 23.036448 0 31.824617L536.41533 523.916725l254.804499 254.805506C800.007998 787.509392 800.007998 801.757672 791.219829 810.54584z" p-id="2719" fill="#ea6f5a"></path></svg></button>
</div>
</li>
</td>
</tr>
{% endfor %}
</ul>
</div>
</tbody>
</table>
<div id="articleView" class="hide" >
<button class="lastStep" onclick="returnToList()"><?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1541063213171" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2135" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M939.880137 487.72513l-782.215258 0 358.804922-318.92975c12.389168-11.011798 13.505595-29.980825 2.492774-42.369993-11.011798-12.386098-29.977755-13.505595-42.367947-2.492774L64.602344 490.13911c-6.407943 5.693676-10.073426 13.858636-10.073426 22.430872s3.665483 16.737196 10.073426 22.430872l411.993309 366.204449c5.717212 5.083785 12.83533 7.580652 19.925818 7.580652 8.274454 0 16.514115-3.403516 22.442128-10.07445 11.011798-12.387122 9.896394-31.357172-2.492774-42.367947L169.687704 548.100196 939.880137 548.100196c16.57449 0 30.011524-13.613042 30.011524-30.187533S956.454628 487.72513 939.880137 487.72513z" p-id="2136" fill="#FF9800"></path></svg></button>
......@@ -337,21 +345,22 @@
$('#useradminLi').css('background-color', 'white');
$('#paperadminLi').css('background-color', 'white');
$('#privateArtadminLi').css('background-color', 'white');
calUserScore();
//calUserScore();
}
}
function calUserScore(){
var current_score_lists = document.getElementsByClassName('list_score_body');
for(var i=0;i<current_score_lists.length;i++){
if('普通用户'==current_score_lists[i].lastElementChild.innerText.toString().trim()){
for(var i=0; i<current_score_lists.length; i++){
if('普通用户' == current_score_lists[i].lastElementChild.innerText.toString().trim()){
var current_score_list = current_score_lists[i];
var user_score = parseInt(current_score_list.children[1].innerText);
var user_score_used = parseInt(current_score_list.children[2].innerText);
current_score_list.children[3].innerText = user_score-user_score_used;
}else{
{#current_score_lists[i].innerHTML="";#}
{#current_score_lists[i].className="";#}
current_score_lists[i].style.display='none';
}
else{
{#current_score_lists[i].innerHTML = "";#}
{#current_score_lists[i].className = "";#}
current_score_lists[i].style.display = 'none';
}
}
}
......
......@@ -339,6 +339,7 @@
$('#former_member').css('left','-100%');
}
/*
function logout(){
let storage = window.localStorage;
storage['username']="";
......@@ -346,6 +347,7 @@
$('#top_bar').empty();
$('#top_bar').append("<ul><li onclick='login()'>登录</li></ul>");
}
*/
function click_bar(index){
let a_list = document.getElementsByClassName("main_bar");
$(a_list[pre_clicked]).removeClass('active');
......@@ -415,6 +417,28 @@
$('#top_bar').empty();
$('#top_bar').append('<button onclick="show_log()">登录</button>');
let storage = window.localStorage;
user_id = storage["userID"];
$.ajax({
url:'/logout/',
type:'post',
dataType:'json',
data:{
"user_id": user_id,
},
success:function(response){
console.log(response);
if(response['message'] === "success"){
console.log("logout OK, ret: ");
console.log(response);
location.reload();
}else{
console.log(response);
}
},
error:function (xhr) {
console.error('something went wrong when logout...');
}
})
storage.clear();
console.log(storage);
}
......
......@@ -20,6 +20,7 @@ urlpatterns = [
path('add/article/url/', views.add_url_article, name='add_url_article'),
path('login/', views.login, name='login'),
path('logout/', views.logout, name='logout'),
path('delete/publication/', views.delete_publication, name='delete_publication'),
path('change/publication/status/', views.change_pub_status, name='change_pub_status'),
path('delete/cve/', views.delete_cve, name='delete_cve'),
......
......@@ -21,6 +21,8 @@ from django.views.decorators.csrf import ensure_csrf_cookie
def index(request):
user_id = request.session.get('user_id')
print("request index.html, user_id = ", user_id)
user_list = User.objects.filter(isCurrent=1).all()
user_type_list = {"Academic STAFF": [], "Phd": [], "Master": [], "Engineer STAFF": []}
for u in user_list:
......@@ -77,6 +79,13 @@ def index(request):
article_list = Articles.objects.order_by('-editDateTime')
article_year_list = {}
for art in article_list:
#print(art.title, art.publish)
pub_type = int(art.publish)
if pub_type == 0: #article is private
continue
elif pub_type == 1 and user_id == None: #internal article
continue
year = str(art.editDateTime)[0:4]
art.editDateTime = str(art.editDateTime)[5:10]
u = User.objects.filter(userID=art.authorID).values('name')
......@@ -134,11 +143,18 @@ def login(request):
else:
if db_info.pwd == password:
user_id = db_info.userID
request.session['user_id'] = user_id
response = JsonResponse({"message": "success", "userid": user_id})
else:
response = JsonResponse({"message": "密码错误"})
return response
@csrf_exempt
def logout(request):
print('call logout')
request.session['user_id'] = None
response = JsonResponse({"message": "success"})
return response
def user(request, user_id):
usr = get_object_or_404(User, pk=user_id)
......
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