Commit f56f7c45 by Xu Zhou

管理员页面使用session保持认证。

parent b451c0a0
...@@ -291,6 +291,11 @@ svg{ ...@@ -291,6 +291,11 @@ svg{
height:45px; height:45px;
line-height: 45px; line-height: 45px;
} }
.list_private_art {
width:100%;
height:50px;
line-height: 50px;
}
.user_score_List>.list_head >ul> li,.list_score_body > li{ .user_score_List>.list_head >ul> li,.list_score_body > li{
width:25%; width:25%;
float: left; float: left;
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
</div> </div>
</div> </div>
</div> </div>
<table class="table tableList"> <table class="table tableList">
<thead> <thead>
<tr> <tr>
<th>用户名</th> <th>用户名</th>
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
</div> </div>
<!--Publication列表--> <!--Publication列表-->
<div id="paperadmin" class="userlist"> <div id="paperadmin" class="userlist" style="border:1px solid #000;">
<table class="table tableList"> <table class="table tableList">
<thead> <thead>
...@@ -107,20 +107,24 @@ ...@@ -107,20 +107,24 @@
</table> </table>
</div> </div>
<div id="privateArtadmin" class="userlist" > <!--内部文章管理-->
<ul id="articleList" class="node-list"> <div id="privateArtadmin" class="userlist" style="border:1px solid #000;">
{% for article in articles %} <div class="list_private_art">
<li> <ul id="articleList" class="node-list">
<div class="article-content"> {% for article in articles %}
<button class="title" onclick=getArticle({{ article.articleID }})>{{ article.title }}</button> <li>
<span>{{ article.publish }}</span> <div class="article-content">
<span>{{ article.editDateTime }}</span> <button class="title" onclick=getArticle({{ article.articleID }})>{{ article.title }}</button>
<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> <span>{{ article.publish }}</span>
<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> <span>{{ article.editDateTime }}</span>
</div> <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>
</li> <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>
{% endfor %} </div>
</ul> </li>
{% endfor %}
</ul>
</div>
<div id="articleView" class="hide" > <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> <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>
<div id="artTitle"><h1></h1></div> <div id="artTitle"><h1></h1></div>
...@@ -128,7 +132,11 @@ ...@@ -128,7 +132,11 @@
<div id="content"></div> <div id="content"></div>
</div> </div>
</div> </div>
<div id="scoreRecords" class="userlist">
<!--学习积分-->
<div id="scoreRecords" class="userlist" style="border:1px solid #000;">
<div style="width:100%;height:50px;"> <div style="width:100%;height:50px;">
<span id="user_score_List" style="color:#ff9800" onclick="changeScoreList(this)">积分列表</span> <span id="user_score_List" style="color:#ff9800" onclick="changeScoreList(this)">积分列表</span>
<span id="score_history_List" onclick="changeScoreList(this)">详细记录</span> <span id="score_history_List" onclick="changeScoreList(this)">详细记录</span>
......
from django.shortcuts import render, get_object_or_404 from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse, Http404 from django.http import HttpResponse, Http404, HttpResponseNotFound
from .models import * from .models import *
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.http import JsonResponse from django.http import JsonResponse
...@@ -725,16 +725,19 @@ def check_admin_privilage(user_id): ...@@ -725,16 +725,19 @@ def check_admin_privilage(user_id):
# 管理员 # 管理员
def admin(request): def admin(request):
if request.method != 'POST': admin_id = request.session.get('admin_id')
return HttpResponse(status=404) if admin_id == None:
if request.method != 'POST':
user_id = request.POST.get('user_id', '') return HttpResponseNotFound('<h1>Page not found</h1>')
if user_id == '':
return HttpResponse(status=404) user_id = request.POST.get('user_id', '')
print ("admin user_id = ", user_id) if user_id == '':
return HttpResponse(status=404)
if not check_admin_privilage(user_id): print ("admin user_id = ", user_id)
return HttpResponse(status=404)
if not check_admin_privilage(user_id):
return HttpResponse(status=404)
request.session['admin_id'] = user_id
if User.objects.last(): if User.objects.last():
if User.objects.last().userID > 0: if User.objects.last().userID > 0:
......
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