Commit e52e8a83 by liuyingying

唔太感动了终于结束了

parent 4909462f
...@@ -38,6 +38,7 @@ class Publications(models.Model): ...@@ -38,6 +38,7 @@ class Publications(models.Model):
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')
editDateTime = models.DateField(default=timezone.now)
class PubToUser(models.Model): class PubToUser(models.Model):
...@@ -55,12 +56,13 @@ class Articles(models.Model): ...@@ -55,12 +56,13 @@ class Articles(models.Model):
editDateTime = models.DateField(default=timezone.now) editDateTime = models.DateField(default=timezone.now)
isPrivate = models.CharField(max_length=5, default='0') isPrivate = models.CharField(max_length=5, default='0')
attachment = models.CharField(max_length=1000, default='') attachment = models.CharField(max_length=1000, default='')
url = models.CharField(max_length=1000, default='')
class ScoreRecords(models.Model): class ScoreRecords(models.Model):
recordID = models.BigIntegerField(primary_key=True) recordID = models.BigIntegerField(primary_key=True)
userID = models.BigIntegerField() userID = models.BigIntegerField()
username = models.CharField(max_length=50,default='null') username = models.CharField(max_length=50, default='null')
reason = models.TextField(default='no reason') reason = models.TextField(default='no reason')
editDate = models.DateField(default=timezone.now) editDate = models.DateField(default=timezone.now)
...@@ -73,5 +75,6 @@ class Bugs(models.Model): ...@@ -73,5 +75,6 @@ class Bugs(models.Model):
description = models.TextField() description = models.TextField()
url = models.CharField(max_length=1000) url = models.CharField(max_length=1000)
software = models.CharField(max_length=1000, default='Xsoftware') software = models.CharField(max_length=1000, default='Xsoftware')
editDateTime = models.DateField(default=timezone.now)
...@@ -160,7 +160,7 @@ nav>div{ ...@@ -160,7 +160,7 @@ nav>div{
/*border-bottom:solid 5px #97b7e6;*/ /*border-bottom:solid 5px #97b7e6;*/
} }
.top>button{ .top button{
width:50px; width:50px;
height:25px; height:25px;
float: right; float: right;
...@@ -193,8 +193,8 @@ nav>div{ ...@@ -193,8 +193,8 @@ nav>div{
font-size: 14px; font-size: 14px;
margin: 5px 25px 10px; margin: 5px 25px 10px;
} }
#bar>.top>a{ #bar>.top a{
color:grey; color:blue;
} }
#bar>.bottom{ #bar>.bottom{
font-size: 18px; font-size: 18px;
...@@ -640,10 +640,11 @@ section > .smaller_box{ ...@@ -640,10 +640,11 @@ section > .smaller_box{
width:10%; width:10%;
height:35px; height:35px;
float: right; float: right;
padding-top: 3px;
} }
.add_one > a{ .add_one > a{
float: right; float: right;
margin: 5px 20px; margin: 5px 15px;
} }
.add_one button{ .add_one button{
width:30px; width:30px;
...@@ -651,7 +652,6 @@ section > .smaller_box{ ...@@ -651,7 +652,6 @@ section > .smaller_box{
float: right; float: right;
border:none; border:none;
background: transparent; background: transparent;
margin-right: 15px;
} }
li svg{ li svg{
margin:10px 5px; margin:10px 5px;
...@@ -681,3 +681,10 @@ li svg{ ...@@ -681,3 +681,10 @@ li svg{
outline: none !important; outline: none !important;
display: block; display: block;
} }
.add_url{
width: 20px;
height: 20px;
margin: 5px 0;
float: left !important;
background: url("/static/hunter/images/link.png") no-repeat !important;
}
\ No newline at end of file
...@@ -253,7 +253,11 @@ ...@@ -253,7 +253,11 @@
{% for art in arts %} {% for art in arts %}
<ul> <ul>
<li class="big_text"> <li class="big_text">
{% if art.url %}
<a href="{{ art.url }}" target="_blank">{{ art.title }}</a>
{% else %}
<a href="{% url 'hunter:article' art.articleID %}" target="_blank">{{ art.title }}</a> <a href="{% url 'hunter:article' art.articleID %}" target="_blank">{{ art.title }}</a>
{% endif %}
</li> </li>
<li>{{ art.author }}</li> <li>{{ art.author }}</li>
<li class="middle_text right">{{ art.editDateTime }}</li> <li class="middle_text right">{{ art.editDateTime }}</li>
...@@ -301,7 +305,7 @@ ...@@ -301,7 +305,7 @@
}else{ }else{
$('#top_bar').empty(); $('#top_bar').empty();
$('#top_bar').append("<ul><li onclick='logout()'>退出</li><li title='点击进入个人中心'><a href='/user/"+storage["userID"]+"/' target='_blank'>"+storage["username"]+"</a></li></ul>"); $('#top_bar').append("<ul><li><button onclick='logout()'>退出</button></li><li title='点击进入个人中心'><a href='/user/"+storage["userID"]+"/' target='_blank'>"+storage["username"]+"</a></li></ul>");
hide_log(); hide_log();
} }
...@@ -376,7 +380,7 @@ ...@@ -376,7 +380,7 @@
} }
function login_success(name,userid){ function login_success(name,userid){
$('#top_bar').empty(); $('#top_bar').empty();
$('#top_bar').append("<ul><li onclick='logout()'>退出</li><li title='点击进入个人中心'><a href='/user/"+userid+"/' target='_blank'>"+name+"</a></li></ul>"); $('#top_bar').append("<ul><li><button onclick='logout()'>退出</button></li><li title='点击进入个人中心'><a href='/user/"+userid+"/' target='_blank'>"+name+"</a></li></ul>");
hide_log(); hide_log();
window.open("/user/"+userid); window.open("/user/"+userid);
} }
......
...@@ -14,7 +14,14 @@ ...@@ -14,7 +14,14 @@
<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 id="title" name="title" type="text">
</div>
<div>
<label for="url">文章地址:</label>
<input id="url" name="url" type="text">
</div>
</div> </div>
<div id="error_log">{{ error_message }}</div> <div id="error_log">{{ error_message }}</div>
...@@ -119,7 +126,9 @@ ...@@ -119,7 +126,9 @@
</span> </span>
<div class="add_one"> <div class="add_one">
<a href="{% url 'hunter:write_art' %}">
<button class="add_url" onclick="addArt()" title="添加外部平台文章链接"></button>
<a href="{% url 'hunter:write_art' %}" title="写文章">
<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> <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>
</a> </a>
</div> </div>
...@@ -131,7 +140,12 @@ ...@@ -131,7 +140,12 @@
{% for art in arts %} {% for art in arts %}
<ul id="articleid{{ art.articleID }}"> <ul id="articleid{{ art.articleID }}">
<li class="big_text"> <li class="big_text">
{% if art.url %}
<a href="{{ art.url }}" target="_blank">{{ art.title }}</a>
{% else %}
<a href="{% url 'hunter:article' art.articleID %}" target="_blank">{{ art.title }}</a> <a href="{% url 'hunter:article' art.articleID %}" target="_blank">{{ art.title }}</a>
{% endif %}
</li> </li>
<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>
...@@ -302,8 +316,40 @@ ...@@ -302,8 +316,40 @@
} }
function addArt(){ function addArt(){
} submit_what='article';
create_html();
$('#edit_title').empty();
$('#edit_title').append('添加出版');
}
function submit_article(){
let storage = window.localStorage;
let userID = storage['userID'];
let title = $('input[name="title"]').val();
let url = $('input[name="url"]').val();
if(url.indexOf('http')===-1){
url='http://'+url;
}
$.ajax({
url: '/add/article/url/',
type: 'post',
data:{
"userID":userID,
"title":title,
"url":url,
},
success: function (response) {
if(response['message']){
window.location.reload();
}
else {
console.log("错啦");
}
},
error:function(xhr){
}
});
}
function deleArt(artid){ function deleArt(artid){
let is_sure = confirm("确定要删除吗?"); let is_sure = confirm("确定要删除吗?");
...@@ -441,6 +487,18 @@ ...@@ -441,6 +487,18 @@
create_article_html(); create_article_html();
} }
} }
function create_article_html(){
$('#edit_content').empty();
let input_html = '<div>\n' +
' <label for="title">文章标题:</label>\n' +
' <input id="title" name="title" type="text">\n' +
' </div>\n' +
' <div>\n' +
' <label for="url">文章地址:</label>\n' +
' <input id="url" name="url" type="text">\n' +
' </div>';
$('#edit_content').append(input_html);
}
function create_cve_html(){ function create_cve_html(){
$('#edit_content').empty(); $('#edit_content').empty();
let input_html = '<div>\n' + let input_html = '<div>\n' +
...@@ -465,6 +523,7 @@ ...@@ -465,6 +523,7 @@
' </div>\n'; ' </div>\n';
$('#edit_content').append(input_html); $('#edit_content').append(input_html);
} }
function create_article_html(){ function create_article_html(){
......
...@@ -100,6 +100,8 @@ ...@@ -100,6 +100,8 @@
},false); },false);
function saveArt(){ function saveArt(){
let username = document.getElementById("username").innerHTML; let username = document.getElementById("username").innerHTML;
let storage = window.localStorage;
let userID = storage['userID'];
let title = document.getElementById("title").value; let title = document.getElementById("title").value;
let content = document.getElementById("originCnt").value; let content = document.getElementById("originCnt").value;
if(title.length<=0){ if(title.length<=0){
...@@ -116,7 +118,7 @@ ...@@ -116,7 +118,7 @@
}else{ }else{
formdata.append("isHaveFile", "0"); formdata.append("isHaveFile", "0");
} }
formdata.append("username",username); formdata.append("userID",userID);
formdata.append("title",title); formdata.append("title",title);
formdata.append("content",content); formdata.append("content",content);
$.ajax({ $.ajax({
......
...@@ -14,6 +14,7 @@ urlpatterns = [ ...@@ -14,6 +14,7 @@ urlpatterns = [
path('write/', views.write_art, name='write_art'), path('write/', views.write_art, name='write_art'),
path('uploadImg/', views.uploadImg, name='uploadImg'), path('uploadImg/', views.uploadImg, name='uploadImg'),
path('article/<int:article_id>/', views.article, name='article'), path('article/<int:article_id>/', views.article, name='article'),
path('add/article/url/', views.add_url_article, name='add_url_article'),
path('login/', views.login, name='login'), path('login/', views.login, name='login'),
path('delete/publication/', views.delete_publication, name='delete_publication'), path('delete/publication/', views.delete_publication, name='delete_publication'),
path('delete/cve/', views.delete_cve, name='delete_cve'), path('delete/cve/', views.delete_cve, name='delete_cve'),
......
...@@ -93,7 +93,7 @@ def index(request): ...@@ -93,7 +93,7 @@ def index(request):
newest_post_list = {} newest_post_list = {}
start = datetime.datetime.now().date()-datetime.timedelta(hours=23*7, minutes=59, seconds=59) start = datetime.datetime.now().date()-datetime.timedelta(hours=23*7, minutes=59, seconds=59)
newest_publication = Publications.objects.filter(date__gte=start).order_by('-date') newest_publication = Publications.objects.filter(date__gte=start).order_by('-editDateTime')
for pub in newest_publication: for pub in newest_publication:
pub.author = pub.uploadByUser pub.author = pub.uploadByUser
pub.url = '/static/hunter/publications/'+pub.link.split('/')[-1] pub.url = '/static/hunter/publications/'+pub.link.split('/')[-1]
...@@ -105,7 +105,7 @@ def index(request): ...@@ -105,7 +105,7 @@ def index(request):
art.url = '/article/'+str(art.articleID) art.url = '/article/'+str(art.articleID)
art.date = str(art.editDateTime)[5:10] art.date = str(art.editDateTime)[5:10]
newest_cve = Bugs.objects.filter(datetime__gte=start).order_by('-datetime') newest_cve = Bugs.objects.filter(datetime__gte=start).order_by('-editDateTime')
for cve in newest_cve: for cve in newest_cve:
cve.title = cve.identifier cve.title = cve.identifier
cve.author = cve.owner cve.author = cve.owner
...@@ -248,7 +248,7 @@ def article(request, article_id): ...@@ -248,7 +248,7 @@ def article(request, article_id):
@csrf_exempt @csrf_exempt
def write_art(request): def write_art(request):
if request.is_ajax(): if request.is_ajax():
username = request.POST.get('username', '') userID = request.POST.get('userID', '')
title = request.POST.get('title', '') title = request.POST.get('title', '')
content = request.POST.get('content', '') content = request.POST.get('content', '')
editdatetime = datetime.datetime.now().date() editdatetime = datetime.datetime.now().date()
...@@ -277,12 +277,12 @@ def write_art(request): ...@@ -277,12 +277,12 @@ def write_art(request):
else: else:
articleID = Articles.objects.last().articleID + 1 articleID = Articles.objects.last().articleID + 1
try: try:
authorID = User.objects.get(name=username).userID authorID = User.objects.get(userID=userID)
except ObjectDoesNotExist as e: except ObjectDoesNotExist as e:
response = JsonResponse({"message": 0, 'error':'用户不存在,请检查是否登录'}) response = JsonResponse({"message": 0, 'error':'用户不存在,请检查是否登录'})
return response return response
try: try:
Articles.objects.create(articleID=articleID, authorID=authorID, title=title, content=content, Articles.objects.create(articleID=articleID, authorID=userID, title=title, content=content,
editDateTime=editdatetime, editDateTime=editdatetime,
attachment=link) attachment=link)
response = JsonResponse({"message": 1}) response = JsonResponse({"message": 1})
...@@ -293,6 +293,31 @@ def write_art(request): ...@@ -293,6 +293,31 @@ def write_art(request):
@csrf_exempt @csrf_exempt
def add_url_article(request):
userID = request.POST.get('userID', '')
title = request.POST.get('title', '')
editdatetime = datetime.datetime.now().date()
url = request.POST['url']
if Articles.objects.last() is None:
articleID = 1
else:
articleID = Articles.objects.last().articleID + 1
try:
authorID = User.objects.get(userID=userID)
except ObjectDoesNotExist as e:
response = JsonResponse({"message": 0, 'error': '用户不存在,请检查是否登录'})
return response
try:
Articles.objects.create(articleID=articleID, authorID=userID, title=title,
editDateTime=editdatetime,
url=url)
response = JsonResponse({"message": 1})
except ProgrammingError as e:
response = JsonResponse({"message": 0, 'error': '数据库错误'})
return response
@csrf_exempt
def uploadImg(request): def uploadImg(request):
file_obj = request.FILES.get("image") file_obj = request.FILES.get("image")
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...@@ -471,3 +496,4 @@ def profile_submit(request): ...@@ -471,3 +496,4 @@ def profile_submit(request):
return JsonResponse({'message':1}) return JsonResponse({'message':1})
except ObjectDoesNotExist as e: except ObjectDoesNotExist as e:
return JsonResponse({"message":0,'error':e}) return JsonResponse({"message":0,'error':e})
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