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');
......
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