Commit 4f494701 by liuyingying

累死我了

parent 1bcfb3c0
...@@ -33,7 +33,7 @@ class Publications(models.Model): ...@@ -33,7 +33,7 @@ class Publications(models.Model):
publishType = models.CharField(max_length=100,default=' ') publishType = models.CharField(max_length=100,default=' ')
journalname = models.CharField(max_length=1000,default=' ') journalname = models.CharField(max_length=1000,default=' ')
date = models.DateField(default=timezone.now) date = models.DateField(default=timezone.now)
indexType = models.CharField(max_length=100,default=' ') indexType = models.CharField(max_length=100,default='')
uploadByUser = models.CharField(max_length=50,default='no records') uploadByUser = models.CharField(max_length=50,default='no records')
isOpen = models.CharField(max_length=5, default='1') isOpen = models.CharField(max_length=5, default='1')
......
...@@ -12,11 +12,14 @@ body{ ...@@ -12,11 +12,14 @@ body{
width:100%; width:100%;
} }
button{ button{
line-height: 25px;
/* border: solid 1px black; */ /* border: solid 1px black; */
border-radius: 5px; border-radius: 5px;
cursor: pointer; cursor: pointer;
} }
select{
height: 30px;
font-weight: 200;
}
#error_log{ #error_log{
color:red; color:red;
width:60%; width:60%;
...@@ -219,6 +222,10 @@ nav>div{ ...@@ -219,6 +222,10 @@ nav>div{
width:100%; width:100%;
padding-left:20px; padding-left:20px;
} }
.wrap ul:hover{
background: #ddd;
border-radius: 5px;
}
.member_type{ .member_type{
display: block; display: block;
...@@ -291,12 +298,13 @@ blockquote>p{ ...@@ -291,12 +298,13 @@ blockquote>p{
font-style: italic; font-style: italic;
color: #0063a9; color: #0063a9;
} }
.wrap>ul{ .wrap ul{
display: block; display: block;
width:100%; width:100%;
padding-right: 20px;
} }
.wrap>ul>li{ .wrap ul>li{
display: block; display: block;
line-height: 40px; line-height: 40px;
float:left; float:left;
...@@ -324,7 +332,7 @@ ul:after{ ...@@ -324,7 +332,7 @@ ul:after{
.cve_big_text>a{ .cve_big_text>a{
color:#306cc5; color:#306cc5;
} }
.wrap>ul>li>a:hover{ .wrap ul>li>a:hover{
color: #3c7fe2; color: #3c7fe2;
font-size:18px; font-size:18px;
} }
...@@ -451,7 +459,7 @@ footer .copyright a:hover{ ...@@ -451,7 +459,7 @@ footer .copyright a:hover{
line-height: 45px; line-height: 45px;
text-align: right; text-align: right;
} }
#edit_content>form>div>input{ #edit_content>div>input{
width: 65%; width: 65%;
height: 45px; height: 45px;
font-size: 16px; font-size: 16px;
...@@ -509,6 +517,12 @@ footer .copyright a:hover{ ...@@ -509,6 +517,12 @@ footer .copyright a:hover{
padding: 2px 5px; padding: 2px 5px;
margin-right:25px; margin-right:25px;
} }
#bar>.smaller_bottom_bar>span{
width:auto;
float: right;
padding: 2px 5px;
margin-right:25px;
}
.smaller_bottom_bar>a:hover{ .smaller_bottom_bar>a:hover{
font-size:16px; font-size:16px;
border-bottom:solid 2px #6e829e; border-bottom:solid 2px #6e829e;
...@@ -521,6 +535,7 @@ section > .smaller_box{ ...@@ -521,6 +535,7 @@ section > .smaller_box{
.smaller_bar{ .smaller_bar{
height: 35px; height: 35px;
padding: 0 7px; padding: 0 7px;
background: #dee2ec;
} }
.smaller_bar span{ .smaller_bar span{
font-size: 18px; font-size: 18px;
...@@ -540,27 +555,35 @@ section > .smaller_box{ ...@@ -540,27 +555,35 @@ section > .smaller_box{
font-size:18px; font-size:18px;
} }
.add_one{ .add_one{
width:100%; width:10%;
height:40px; height:35px;
float: right;
} }
.add_one button{ .add_one button{
width:30px; width:30px;
height:30px; height:30px;
float: right; float: right;
border-radius:15px; border:none;
background: transparent;
margin-right: 15px;
} }
li svg{
margin:10px 5px;
}
.right button, .li_right button{
background: transparent;
}
.add_one button svg{ .add_one button svg{
margin:5px; margin:8px 5px;
} }
.add_one button:hover svg{ .add_one button:hover svg{
width:30px; height:25px;
height:30px; width:25px;
border-radius:15px; border-radius:15px;
margin:0; margin:0;
} }
.myfile{ .myfile{
float: right;
} }
.myfile >input{ .myfile >input{
background: transparent !important; background: transparent !important;
......
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
</ul> </ul>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
...@@ -249,6 +248,14 @@ ...@@ -249,6 +248,14 @@
} }
}; };
function logout(){
let session = window.sessionStorage;
session['username']="";
session['password']="";
$('#top_bar').empty();
$('#top_bar').append("<ul><li onclick='login()'>登录</li></ul>");
}
function click_bar(index){ function click_bar(index){
let a_list = document.getElementsByClassName("main_bar"); let a_list = document.getElementsByClassName("main_bar");
$(a_list[pre_clicked]).removeClass('active'); $(a_list[pre_clicked]).removeClass('active');
......
...@@ -14,60 +14,24 @@ ...@@ -14,60 +14,24 @@
<div id="edit_wrap" > <div id="edit_wrap" >
<div id="edit_title">修改</div> <div id="edit_title">修改</div>
<div id="edit_content"> <div id="edit_content">
<div>
<label for="title">标题:</label>
<input type="text" placeholder="" name="title" required>
</div>
<div>
<label for="authors">作者:</label>
<input type="text" placeholder="Example:Tom,Bob,Jane" name="authors" required>
</div>
<div>
<label>
<select class="col-sm-2 control-select" name="type">
<option value="0">请选择</option>
<option value="会议">会议</option>
<option value="期刊">期刊</option>
<option value="专利">专利</option>
<option value="软著">软著</option>
</select>
</label>
<input type="text" class="form-control" name="journalname" placeholder="名称" required>
</div>
<div>
<label for="date">日期</label>
<input type="datetime-local" name="date">
{# <div class="input-group date form_date " data-date="" data-date-format="yyyy-MM-dd" data-link-field="dtp_input2" data-link-format="yyyymmdd">#}
{# <input size="16" type="text" name="date" value="" readonly="" required>#}
{# <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>#}
{# </div>#}
{# <input type="hidden" id="dtp_input2" value="" /><br/>#}
</div>
<div class="myfile" >
<input type="file" name="myfile" required>
</div>
</div> </div>
<div id="error_log">{{ error_message }}</div> <div id="error_log">{{ error_message }}</div>
<div id="btn_edit"> <div id="btn_edit">
{# <button id="cancel_btn" onclick="hide_edit()">#}
{# 取消#}
{# </button>#}
{# <button id="submit_btn" onclick="submit_edit()">#}
{# 提交#}
{# </button>#}
</div> </div>
</div> </div>
</div> </div>
<nav> <nav>
<div> <div>
<div id="hunter"> <div id="hunter">
<span>HUNTER</span> <span><a href="{% url 'hunter:index' %}">HUNTER</a></span>
</div> </div>
<div id="bar" class=""> <div id="bar" class="">
<div class="smaller_bottom_bar"> <div class="smaller_bottom_bar">
<a href="" class="main_bar">退出</a> <a href="" class="main_bar" onclick="exit()">退出</a>
<a href="" class="main_bar">修改个人信息</a> <a href="" class="main_bar" id="{{ u.userID }}">修改个人信息</a>
<a href="" class="main_bar">{{ u.name_hanzi }}</a> <span id="username" class="main_bar">{{ u.name }}</span>
</div> </div>
</div> </div>
</div> </div>
...@@ -79,18 +43,24 @@ ...@@ -79,18 +43,24 @@
<span> <span>
我的出版 我的出版
</span> </span>
<div class="add_one">
<button onclick="addPub()">
<svg t="1587711895133" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3772" width="20" height="20"><path d="M512 1024C229.2224 1024 0 794.7776 0 512 0 229.2224 229.2224 0 512 0 794.7776 0 1024 229.2224 1024 512 1024 794.7776 794.7776 1024 512 1024ZM716.8 486.4 537.6 486.4 537.6 307.2 486.4 307.2 486.4 486.4 307.2 486.4 307.2 537.6 486.4 537.6 486.4 716.8 537.6 716.8 537.6 537.6 716.8 537.6 716.8 486.4Z" p-id="3773" fill="#6e829e"></path></svg>
</button>
</div>
</div> </div>
<div class="wrap smaller_wrap"> <div class="wrap smaller_wrap">
{% for year,publications in publication_year_list.items %} {% for year,publications in publication_year_list.items %}
<blockquote ><p>{{ year }}</p></blockquote> <blockquote><p>{{ year }}</p></blockquote>
{% if publications %} {% if publications %}
{% for publication in publications %} {% for publication in publications %}
<ul> <ul id="pubid{{ publication.pubID }}">
<li class="big_text li_long"><a href="{% static 'hunter/publications/' %}{{ publication.link }}" target="_blank">{{ publication.title }}</a></li> <li class="big_text li_long"><a href="{% static 'hunter/publications/' %}{{ publication.link }}" target="_blank">{{ publication.title }}</a></li>
<li class="right"><button onclick="delePub({{ art.articleID }})"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg> <li class="right"><button onclick="delePub({{ publication.pubID }})"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>
</button></li>
<li class="right"><button onclick="editPublication({{ publication.pubID }})"><svg t="1587711451871" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2741" width="20" height="20"><path d="M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z" p-id="2742" fill="#6e829e"></path></svg>
</button></li> </button></li>
{# <li class="right"><button onclick="editPublication({{ publication.pubID }})"><svg t="1587711451871" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2741" width="20" height="20"><path d="M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z" p-id="2742" fill="#6e829e"></path></svg>#}
{# </button></li>#}
<li class="middle_text right">{{ publication.date }}</li> <li class="middle_text right">{{ publication.date }}</li>
<li class="right">{{ publication.journalname }}</li> <li class="right">{{ publication.journalname }}</li>
<li class="right">{{ publication.publishType }}</li> <li class="right">{{ publication.publishType }}</li>
...@@ -99,11 +69,7 @@ ...@@ -99,11 +69,7 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
<div class="add_one">
<button onclick="addPub()">
<svg t="1587711895133" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3772" width="20" height="20"><path d="M512 1024C229.2224 1024 0 794.7776 0 512 0 229.2224 229.2224 0 512 0 794.7776 0 1024 229.2224 1024 512 1024 794.7776 794.7776 1024 512 1024ZM716.8 486.4 537.6 486.4 537.6 307.2 486.4 307.2 486.4 486.4 307.2 486.4 307.2 537.6 486.4 537.6 486.4 716.8 537.6 716.8 537.6 537.6 716.8 537.6 716.8 486.4Z" p-id="3773" fill="#6e829e"></path></svg>
</button>
</div>
{% endfor %} {% endfor %}
</div> </div>
...@@ -115,18 +81,23 @@ ...@@ -115,18 +81,23 @@
<span> <span>
我的漏洞 我的漏洞
</span> </span>
<div class="add_one">
<button onclick="addCVE()">
<svg t="1587711895133" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3772" width="20" height="20"><path d="M512 1024C229.2224 1024 0 794.7776 0 512 0 229.2224 229.2224 0 512 0 794.7776 0 1024 229.2224 1024 512 1024 794.7776 794.7776 1024 512 1024ZM716.8 486.4 537.6 486.4 537.6 307.2 486.4 307.2 486.4 486.4 307.2 486.4 307.2 537.6 486.4 537.6 486.4 716.8 537.6 716.8 537.6 537.6 716.8 537.6 716.8 486.4Z" p-id="3773" fill="#6e829e"></path></svg>
</button>
</div>
</div> </div>
<div class="wrap smaller_wrap"> <div class="wrap smaller_wrap">
{% for year, cves in cve_year_list.items %} {% for year, cves in cve_year_list.items %}
<blockquote ><p>{{ year }}</p></blockquote> <blockquote ><p>{{ year }}</p></blockquote>
{% if cves %} {% if cves %}
{% for cve in cves %} {% for cve in cves %}
<ul> <ul id="cveid{{ cve.identifier }}">
<li class="cve_big_text"><a href="{{ cve.url }}" target="_blank">{{ cve.identifier }}</a></li> <li class="cve_big_text"><a href="{{ cve.url }}" target="_blank">{{ cve.identifier }}</a></li>
<li class="li_right"><button onclick="deleCVE({{ art.articleID }})"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg> <li class="li_right"><button onclick="deleCVE({{ cve.identifier }})"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>
</button></li>
<li class="li_right"><button onclick="editCVE('{{ cve.identifier }}')"><svg t="1587711451871" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2741" width="20" height="20"><path d="M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z" p-id="2742" fill="#6e829e"></path></svg>
</button></li> </button></li>
{# <li class="li_right"><button onclick="editCVE('{{ cve.identifier }}')"><svg t="1587711451871" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2741" width="20" height="20"><path d="M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z" p-id="2742" fill="#6e829e"></path></svg>#}
{# </button></li>#}
<li class="li_right">{{ cve.datetime }}</li> <li class="li_right">{{ cve.datetime }}</li>
<li class="li_right">{{ cve.software }}</li> <li class="li_right">{{ cve.software }}</li>
<li class="li_right">{{ cve.bugType }}</li> <li class="li_right">{{ cve.bugType }}</li>
...@@ -135,11 +106,7 @@ ...@@ -135,11 +106,7 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
<div class="add_one">
<button onclick="addCVE()">
<svg t="1587711895133" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3772" width="20" height="20"><path d="M512 1024C229.2224 1024 0 794.7776 0 512 0 229.2224 229.2224 0 512 0 794.7776 0 1024 229.2224 1024 512 1024 794.7776 794.7776 1024 512 1024ZM716.8 486.4 537.6 486.4 537.6 307.2 486.4 307.2 486.4 486.4 307.2 486.4 307.2 537.6 486.4 537.6 486.4 716.8 537.6 716.8 537.6 537.6 716.8 537.6 716.8 486.4Z" p-id="3773" fill="#6e829e"></path></svg>
</button>
</div>
{% endfor %} {% endfor %}
</div> </div>
...@@ -151,6 +118,12 @@ ...@@ -151,6 +118,12 @@
<span> <span>
我的笔记 我的笔记
</span> </span>
<div class="add_one">
<button onclick="addArt()">
<svg t="1587711895133" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3772" width="20" height="20"><path d="M512 1024C229.2224 1024 0 794.7776 0 512 0 229.2224 229.2224 0 512 0 794.7776 0 1024 229.2224 1024 512 1024 794.7776 794.7776 1024 512 1024ZM716.8 486.4 537.6 486.4 537.6 307.2 486.4 307.2 486.4 486.4 307.2 486.4 307.2 537.6 486.4 537.6 486.4 716.8 537.6 716.8 537.6 537.6 716.8 537.6 716.8 486.4Z" p-id="3773" fill="#6e829e"></path></svg>
</button>
</div>
</div> </div>
<div class="wrap smaller_wrap"> <div class="wrap smaller_wrap">
{% for year, arts in article_year_list.items %} {% for year, arts in article_year_list.items %}
...@@ -164,18 +137,13 @@ ...@@ -164,18 +137,13 @@
<li>{{ art.author }}</li> <li>{{ art.author }}</li>
<li class="right"><button onclick="deleArt({{ art.articleID }})"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg> <li class="right"><button onclick="deleArt({{ art.articleID }})"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>
</button></li> </button></li>
<li class="right"><button onclick="editArt({{ art.articleID }})"><svg t="1587711451871" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2741" width="20" height="20"><path d="M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z" p-id="2742" fill="#6e829e"></path></svg> {# <li class="right"><button onclick="editArt({{ art.articleID }})"><svg t="1587711451871" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2741" width="20" height="20"><path d="M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z" p-id="2742" fill="#6e829e"></path></svg>#}
</button></li> {# </button></li>#}
<li class="middle_text right">{{ art.editDateTime }}</li> <li class="middle_text right">{{ art.editDateTime }}</li>
<li class="small_text right">{{ art.authorID }}</li> <li class="small_text right">{{ art.authorID }}</li>
</ul> </ul>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
<div class="add_one">
<button onclick="addArt()">
<svg t="1587711895133" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3772" width="20" height="20"><path d="M512 1024C229.2224 1024 0 794.7776 0 512 0 229.2224 229.2224 0 512 0 794.7776 0 1024 229.2224 1024 512 1024 794.7776 794.7776 1024 512 1024ZM716.8 486.4 537.6 486.4 537.6 307.2 486.4 307.2 486.4 486.4 307.2 486.4 307.2 537.6 486.4 537.6 486.4 716.8 537.6 716.8 537.6 537.6 716.8 537.6 716.8 486.4Z" p-id="3773" fill="#6e829e"></path></svg>
</button>
</div>
{% endfor %} {% endfor %}
</div> </div>
...@@ -225,25 +193,41 @@ ...@@ -225,25 +193,41 @@
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ window.onload=function(){
let session = window.sessionStorage;
}); if($('#username').text()!==sessionStorage["username"]){
alert("请求异常,请重新登录");
console.log($('#username').val());
{#window.location.href='/';#}
}
};
function exit(){
let session = window.sessionStorage;
session['username']="";
session['password']="";
window.location.href='/index/';
}
var submit_what = ''; var submit_what = '';
function addPub(){ function addPub(){
submit_what = 'publication';
create_html(); create_html();
$('#edit_title').empty(); $('#edit_title').empty();
$('#edit_title').append('添加出版'); $('#edit_title').append('添加出版');
submit_what = 'publication'; }
function editPublication(pubid){
console.log(pubid);
create_html();
} }
function submit_pub(){ function submit_pub(){
var title = $('input[name="title"]').val(); let title = $('input[name="title"]').val();
var authors = $('input[name="authors"]').val(); let authors = $('input[name="authors"]').val();
var journalname = $('input[name="journalname"]').val(); let journalname = $('input[name="journalname"]').val();
var date = $('input[name="date"]').val(); let date = $('#date_input').val();
var type = $('select[name="type"] option:selected').val(); let type = $('select[name="type"] option:selected').val();
let myfile = $("input[name='myfile']")[0].files[0];
var formatData = new FormData(); let formatData = new FormData();
formatData.append("myfile", $("input[name='myfile']")[0].files[0]); formatData.append("myfile", myfile);
formatData.append("title", title); formatData.append("title", title);
formatData.append("authors", authors); formatData.append("authors", authors);
formatData.append("journalname", journalname); formatData.append("journalname", journalname);
...@@ -251,28 +235,60 @@ ...@@ -251,28 +235,60 @@
formatData.append("type", type); formatData.append("type", type);
$.ajax({ $.ajax({
url:'/add/publication/', url:"{% url 'hunter:add_publication' %} ",
type: 'post', type: 'post',
data:formatData, data:formatData,
contentType: false, contentType: false,
processData: false, processData: false,
success: function (response){ success: function (response){
console.log(response); if(response['message']){
hide_edit();
let isFind=0;
let year = date.substr(0,4);
let date_month = date.substr(5,10);
$('#publish blockquote').each(function(){
if(this.children[0].innerText===year){
isFind=1;
$(this.parentElement).append(' <ul>\n' +
' <li class="big_text li_long"><a href="/static/hunter/publications/'+myfile.name+'" target="_blank">'+title+'</a></li>\n' +
' <li class="right"><button onclick="delePub('+response['pubID']+')"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>\n' +
' </button></li>\n' +
' <li class="right"><button onclick="editPublication('+response['pubID']+')"><svg t="1587711451871" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2741" width="20" height="20"><path d="M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z" p-id="2742" fill="#6e829e"></path></svg>\n' +
' </button></li>\n' +
' <li class="middle_text right">'+date_month+'}</li>\n' +
' <li class="right">'+journalname+'</li>\n' +
' <li class="right">'+type+'</li>\n' +
' <li class="small_text">'+authors+'</li>\n' +
' </ul>');
}
});
if(!isFind){
$('#publish wrap')[0].prepend('<blockquote><p>'+year +'</p></blockquote>'+' <ul>\n' +
' <li class="big_text li_long"><a href="/static/hunter/publications/'+myfile.name+'" target="_blank">'+title+'</a></li>\n' +
' <li class="right"><button onclick="delePub('+response['pubID']+')"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>\n' +
' </button></li>\n' +
' <li class="right"><button onclick="editPublication('+response['pubID']+')"><svg t="1587711451871" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2741" width="20" height="20"><path d="M863.079412 351.09129a29.2569 29.2569 0 0 1 58.5138 0v555.881108a117.027602 117.027602 0 0 1-117.027601 117.027602H219.427602a117.027602 117.027602 0 0 1-117.027602-117.027602V146.292987a117.027602 117.027602 0 0 1 117.027602-117.027602h380.339706a29.2569 29.2569 0 0 1 0 58.513801H219.427602a58.513801 58.513801 0 0 0-58.513801 58.513801v760.679411a58.513801 58.513801 0 0 0 58.513801 58.513801h585.138009a58.513801 58.513801 0 0 0 58.513801-58.513801V351.09129zM855.414104 10.306913a29.2569 29.2569 0 1 1 44.587516 37.916943l-248.683654 292.569005a29.2569 29.2569 0 1 1-44.587516-37.916943l248.683654-292.569005zM307.198303 526.632692h263.312104a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z m0 175.541403h409.596606a29.2569 29.2569 0 0 1 0 58.513801H307.198303a29.2569 29.2569 0 0 1 0-58.513801z" p-id="2742" fill="#6e829e"></path></svg>\n' +
' </button></li>\n' +
' <li class="middle_text right">'+date_month+'}</li>\n' +
' <li class="right">'+journalname+'</li>\n' +
' <li class="right">'+type+'</li>\n' +
' <li class="small_text">'+authors+'</li>\n' +
' </ul>');
}
}else{
$('#error_log').append(response['error']);
}
}, },
error: function (xhr){ error: function (xhr){
console.error('something wrong');
} }
}); });
} }
function addArt(){
}
function addCVE(){
$('#edit_title').empty();
$('#edit_title').append('添加CVE');
create_html()
}
function delePub(pubid){ function delePub(pubid){
let is_sure = alert("确定要删除吗?"); let is_sure = confirm("确定要删除吗?");
console.log(is_sure);
console.log(pubid);
if(is_sure){ if(is_sure){
$.ajax({ $.ajax({
url: '/delete/publication/', url: '/delete/publication/',
...@@ -281,10 +297,9 @@ ...@@ -281,10 +297,9 @@
"pub_id":pubid, "pub_id":pubid,
}, },
success: function (response) { success: function (response) {
alert(response['message']);
if(response['message']){ if(response['message']){
this.parentElement.parentElement.style.display='none'; $('#pubid'+pubid).css('display','none');
this.parentElement.parentElement.innerHTML=''; $('#pubid'+pubid).empty();
} }
}, },
error:function (xhr) { error:function (xhr) {
...@@ -294,60 +309,211 @@ ...@@ -294,60 +309,211 @@
}) })
} }
} }
function deleArt(artid){
function addArt(){
} }
function deleCVE(cveid) {
function deleArt(artid){
} }
function editPublication(pubid){ function addCVE(){
console.log(pubid); submit_what = 'cve';
create_html(); create_html();
$('#edit_title').empty();
$('#edit_title').append('添加CVE');
} }
function editArt(artid){ function submit_cve(){
let session = window.sessionStorage;
let owner = session['username'];
let cve_id = $('input[name="identifier"]').val();
let bugtype = $('input[name="bugtype"]').val();
let date = $('#date_input').val();
let software = $("input[name='software']").val();
let url_cve = $("input[name='url_cve]").val();
let formatData = new FormData();
formatData.append("owner", owner);
formatData.append("cve_id", cve_id);
formatData.append("bugType", bugtype);
formatData.append("software", software);
formatData.append("date", date);
formatData.append("url",url_cve);
$.ajax({
url:"{% url 'hunter:add_cve' %} ",
type: 'post',
data:formatData,
contentType: false,
processData: false,
success: function (response){
if(response['message']){
hide_edit();
let isFind=0;
let year = date.substr(0,4);
let date_month = date.substr(5,10);
$('#cve blockquote').each(function(){
if(this.children[0].innerText===year){
isFind=1;
$(this.parentElement).prepend('<ul id="cveid'+cve_id +'">\n' +
' <li class="cve_big_text"><a href="'+url_cve +'" target="_blank">'+cve_id +'</a></li>\n' +
' <li class="li_right"><button onclick="deleCVE('+cve_id +')"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>\n' +
' </button></li>\n' +
' <li class="li_right">'+date_month +'</li>\n' +
' <li class="li_right">'+software +'</li>\n' +
' <li class="li_right">'+bugtype +'</li>\n' +
' <li class="li_long li_small_text">'+software +'</li>\n' +
' </ul>');
}
});
if(!isFind){
$('#cve wrap')[0].prepend('<blockquote><p>'+year +'</p></blockquote>'+'<ul id="cveid'+cve_id +'">\n' +
' <li class="cve_big_text"><a href="'+url_cve +'" target="_blank">'+cve_id +'</a></li>\n' +
' <li class="li_right"><button onclick="deleCVE('+cve_id +')"><svg t="1587713476030" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4730" width="20" height="20"><path d="M864 128H544v-16a32 32 0 0 0-64 0v16H160a32 32 0 0 0 0 64h704a32 32 0 0 0 0-64z m-64 128a32 32 0 0 0-32 32v592H256V288a32 32 0 0 0-64 0v624a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V288a32 32 0 0 0-32-32zM416 784V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z m128 0V304a32 32 0 0 0-64 0v480a32 32 0 0 0 64 0z" fill="#b34340" p-id="4731"></path></svg>\n' +
' </button></li>\n' +
' <li class="li_right">'+date_month +'</li>\n' +
' <li class="li_right">'+software +'</li>\n' +
' <li class="li_right">'+bugtype +'</li>\n' +
' <li class="li_long li_small_text">'+software +'</li>\n' +
' </ul>');
}
}else{
$('#error_log').append(response['error']);
}
}
});
} }
function editCVE(cveid){ function deleCVE(cveid) {
let is_sure = confirm("确定要删除吗?");
console.log(is_sure);
console.log(cveid); console.log(cveid);
create_html(); if(is_sure){
} $.ajax({
function show_edit(){ url: '/delete/cve/',
$('#edit_div').addClass('show_edit') type: 'post',
data:{
"cve_id":cveid,
},
success: function (response) {
if(response['message']){
$('#cveid'+cveid).css('display','none');
$('#cveid'+cveid).empty();
}
},
error:function (xhr) {
console.error('something went wrong...');
login_fail("something went wrong...");
}
})
}
} }
function create_html(){ function create_html(){
show_edit(); show_edit();
let html = let html =
' <button id="cancel_btn" onclick="hide_edit()">\n' + ' <button id="cancel_btn" onclick="hide_edit()">\n' +
' 取消\n' + ' 取消\n' +
' </button>\n' + ' </button>\n' +
' <button id="submit_btn" onclick="submit_edit()">\n' + ' <button id="submit_btn" onclick="submit_'+submit_what+'()">\n' +
' 提交\n' + ' 提交\n' +
' </button>\n'; ' </button>\n';
$('#btn_edit').empty(); $('#btn_edit').empty();
$('#btn_edit').append(html); $('#btn_edit').append(html);
if(submit_what==='publication'){
/*for 循环中不需要清空*/ create_publication_html();
}
if(submit_what==='cve'){
create_cve_html();
}
if(submit_what==='article'){
create_article_html();
}
}
function create_cve_html(){
$('#edit_content').empty();
let input_html = '<div>\n' + let input_html = '<div>\n' +
' <span>名字:</span>\n' + ' <label for="identifier">编号:</label>\n' +
' <input type="text">\n' + ' <input type="text" placeholder="" name="identifier" required>\n' +
' </div>'; ' </div>\n' +
' <div>\n' +
' <label for="url_cve">链接:</label>\n' +
' <input type="text" placeholder="http://xx.xx.xx" name="url_cve" required>\n' +
' </div>\n' +
' <div>\n' +
' <label for="date">日期</label>\n' +
' <input type="date" dataformatas="YYYY-MM-DD" id="date_input" name="date">\n' +
' </div>\n' +
' <div>\n' +
' <label for="softwore">存在于</label>\n' +
' <input type="text" name="softwore" placeholder="xx软件/系统/..." required>\n' +
' </div>\n' +
' <div>\n' +
' <label for="bugtype">漏洞类型</label>\n' +
' <input type="text" name="bugtype" placeholder="内存泄漏/溢出/..." required>\n' +
' </div>\n';
$('#edit_content').append(input_html); $('#edit_content').append(input_html);
}
function create_article_html(){
} }
function create_publication_html(){ function create_publication_html(){
$('#edit_content').empty(); $('#edit_content').empty();
let html =""; let input_html = '<div>\n' +
' <label for="title">标题:</label>\n' +
' <input type="text" placeholder="" name="title" required>\n' +
' </div>\n' +
' <div>\n' +
' <label for="authors">作者:</label>\n' +
' <input type="text" placeholder="Example:Tom,Bob,Jane" name="authors" required>\n' +
' </div>\n' +
' <div>\n' +
' <label>\n' +
' <select class="col-sm-2 control-select" name="type">\n' +
' <option value="0">请选择</option>\n' +
' <option value="会议">会议</option>\n' +
' <option value="期刊">期刊</option>\n' +
' <option value="专利">专利</option>\n' +
' <option value="软著">软著</option>\n' +
' </select>\n' +
' </label>\n' +
' <input type="text" class="form-control" name="journalname" placeholder="名称" required>\n' +
' </div>\n' +
' <div>\n' +
' <label for="date">日期</label>\n' +
' <input type="date" dataformatas="YYYY-MM-DD" id="date_input" name="date">\n' +
' </div>\n' +
' <div class="myfile" >\n' +
' <input type="file" name="myfile" required>\n' +
' </div>';
$('#edit_content').append(input_html);
} }
function submit_edit(){ function submit_edit(){
if(submit_what==='publication') { if(submit_what==='publication') {
submit_pub(); submit_pub();
} }
if(submit_what==='cve'){
submit_cve();
}
} }
function login_fail(message){ function login_fail(message){
$('#error_log').empty(); $('#error_log').empty();
$('#error_log').append(message); $('#error_log').append(message);
} }
function hide_edit(){ function hide_edit() {
$('#edit_div').removeClass('show_edit') $('#edit_div').removeClass('show_edit');
$('#edit_content').empty();
}
function editArt(artid){
} }
function editCVE(cveid){
console.log(cveid);
create_html();
}
function show_edit(){
$('#edit_div').addClass('show_edit');
}
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
from django.urls import path from django.urls import path
from . import views from . import views
app_name = 'hunter' app_name = 'hunter'
urlpatterns = [ urlpatterns = [
path('', views.index, name='index'), path('', views.index, name='index'),
path('/index/', views.index, name='index'),
# path('<int:pk>/', views.UserDetail.as_view(), name='user'), # path('<int:pk>/', views.UserDetail.as_view(), name='user'),
# path('<int:pk>/article/', views.ArticleDetail.as_view(), name='article'), # path('<int:pk>/article/', views.ArticleDetail.as_view(), name='article'),
path('user/<int:user_id>/', views.user, name='user'), path('user/<int:user_id>/', views.user, name='user'),
path('article/<int:article_id>/', views.article, name='article'), path('article/<int:article_id>/', views.article, name='article'),
path('login/', views.login, name='login'), path('login/', views.login, name='login'),
path('delete/publication/<int:pub_id>', views.delete_publication, name='delete_publication'), path('delete/publication/', views.delete_publication, name='delete_publication'),
path('add/publication/', views.add_publication, name = 'add_publication'), path('delete/cve/', views.delete_cve, name='delete_cve'),
path('delete/article/', views.delete_article, name='delete_article'),
path('add/publication/', views.add_publication, name='add_publication'),
path('add/cve/', views.add_cve, name='add_cve'),
path('add/article/', views.add_article, name='add_article'),
] ]
\ No newline at end of file
...@@ -98,9 +98,12 @@ def login(request): ...@@ -98,9 +98,12 @@ def login(request):
def user(request, user_id): def user(request, user_id):
u = User.objects.get(userID=user_id) try:
print(u.name_hanzi) usr = User.objects.get(userID=user_id)
username = u.name except ObjectDoesNotExist as e:
return redirect(request, 'hunter/index.html')
username = usr.name
u = {'userID': user_id, 'name': username}
my_publication_year_list = {} my_publication_year_list = {}
pub_ids = PubToUser.objects.filter(username=username).all().values("pubID") pub_ids = PubToUser.objects.filter(username=username).all().values("pubID")
for pub_id in pub_ids: for pub_id in pub_ids:
...@@ -108,6 +111,7 @@ def user(request, user_id): ...@@ -108,6 +111,7 @@ def user(request, user_id):
pub = get_object_or_404(Publications, pk=pub_id['pubID']) pub = get_object_or_404(Publications, pk=pub_id['pubID'])
year = str(pub.date)[0:4] year = str(pub.date)[0:4]
pub.date = str(pub.date)[5:10] pub.date = str(pub.date)[5:10]
pub.link = pub.link.split('/')[-1]
if year in my_publication_year_list.keys(): if year in my_publication_year_list.keys():
my_publication_year_list[year].append(pub) my_publication_year_list[year].append(pub)
else: else:
...@@ -150,7 +154,9 @@ def article(request, article_id): ...@@ -150,7 +154,9 @@ def article(request, article_id):
return render(request, 'hunter/article.html', {'article': art}) return render(request, 'hunter/article.html', {'article': art})
def delete_publication(request, pub_id): @csrf_exempt
def delete_publication(request):
pub_id = request.POST['pub_id']
print(pub_id) print(pub_id)
try: try:
PubToUser.objects.filter(pubID=pub_id).delete() PubToUser.objects.filter(pubID=pub_id).delete()
...@@ -161,17 +167,47 @@ def delete_publication(request, pub_id): ...@@ -161,17 +167,47 @@ def delete_publication(request, pub_id):
response = JsonResponse({"message": 1}) response = JsonResponse({"message": 1})
return response return response
@csrf_exempt
def delete_cve(request):
cve_id = request.POST['cve_id']
try:
Bugs.objects.filter(identifier=cve_id).delete()
response = JsonResponse({"message": 1})
return response
except ProgrammingError as e:
response = JsonResponse({"message": 0})
return response
@csrf_exempt
def delete_article(request):
cve_id = request.POST['cve_id']
try:
Bugs.objects.filter(identifier=cve_id).delete()
response = JsonResponse({"message": 1})
return response
except ProgrammingError as e:
response = JsonResponse({"message": 0})
return response
@csrf_exempt @csrf_exempt
def add_publication(request): def add_publication(request):
title = request.POST['title'] title = request.POST['title']
print(title) print(title)
authors = request.POST['authors'] authors = request.POST['authors']
myfile = request.FILES['myfile'] myfile = request.FILES['myfile']
str=','.decode('utf-8') print(authors)
authors = authors.replace(str, ',') s=','
authors = authors.replace(s, ',')
print(authors)
journalname = request.POST.get('journalname') journalname = request.POST.get('journalname')
date = request.POST.get('date') date = request.POST.get('date')
print(date)
index = request.POST.get('index') index = request.POST.get('index')
if Publications.objects.filter(title=title).count() > 0:
return JsonResponse({'message': 0, "error": "该标题已存在"})
if Publications.objects.last() is None: if Publications.objects.last() is None:
pubID = 1 pubID = 1
else: else:
...@@ -184,20 +220,44 @@ def add_publication(request): ...@@ -184,20 +220,44 @@ def add_publication(request):
for chunk in myfile.chunks(): for chunk in myfile.chunks():
dest.write(chunk) dest.write(chunk)
dest.close() dest.close()
link = os.path.join('static','publications',myfile.name) link = myfile.name
try: try:
Publications.objects.create(pubID=pubID, title=title,link=link, messages='kidding', authors = authors,journalname=journalname,date=date,indexType=index) Publications.objects.create(pubID=pubID, title=title,link=link, messages='kidding', authors = authors,journalname=journalname,date=date,)
except ProgrammingError as e: except ProgrammingError as e:
return render(request, 'user.html', {'message':'Publications表错误:' + e}) return JsonResponse({"message": 0})
authorArr = authors.split(',') authorArr = authors.split(',')
print(authorArr)
for author in authorArr: for author in authorArr:
try: try:
PubToUser.objects.create(pubID = pubID,username=author) PubToUser.objects.create(pubID = pubID,username=author)
return redirect(request, 'index.html', {'uploadMessage': '文件上传成功'}) response = JsonResponse({"message": 1, 'pubID':pubID})
except ProgrammingError as e: except ProgrammingError as e:
return render(request, 'index.html', {'uploadError': 'PubToUser数据表错误:' + e}) return JsonResponse({"message": 0})
# message["warning"] = "上传成功" # message["warning"] = "上传成功"
# return HttpResponse(json.dumps(message), content_type='application/json') # return HttpResponse(json.dumps(message), content_type='application/json')
return redirect(request, 'index.html') return response
@csrf_exempt
def add_cve(request):
owner = request.POST['owner']
bugType = request.POST['bugType']
identifier = request.POST['cve_id']
datetime = request.POST['date']
software = request.POST['software']
url = request.POST['url']
if Bugs.objects.filter(identifier=identifier).count() > 0:
return JsonResponse({'message': 0, "error": "该CVE已存在"})
try:
Bugs.objects.create(owner=owner, bugType=bugType, identifier=identifier, datetime=datetime,
software=software, url=url)
response = JsonResponse({"message": 1})
return response
except ProgrammingError as e:
response = JsonResponse({"message": 0})
return response
@csrf_exempt
def add_article(request):
return 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