Commit fcf50492 by liuyingying

News板块完成

parent 0e2e28c8
...@@ -200,7 +200,33 @@ nav>div{ ...@@ -200,7 +200,33 @@ nav>div{
font-size: 18px; font-size: 18px;
color:black; color:black;
} }
.former{
width:200px;
}
.former >#show_btn,#close_btn{
width: 80px;
height: 30px;
border-radius: 0;
margin: 5px;
float: left;
font-size: 14px;
cursor: pointer;
}
.former > #show_btn{
border:none;
background-color: rgb(97, 152, 232);
color: white;
}
.former > #close_btn{
border: solid 1px #f1f1f1;
background-color: white;
color:dimgrey;
}
#former_member{
margin-top:30px;
padding-top:20px;
border-top:solid 1px #f1f1f1;
}
.left-bar{ .left-bar{
width: 100%; width: 100%;
...@@ -213,6 +239,7 @@ nav>div{ ...@@ -213,6 +239,7 @@ nav>div{
line-height: 40px; line-height: 40px;
font-size:22px; font-size:22px;
color:black; color:black;
float:left;
font-weight: 400; font-weight: 400;
font-family: "Roboto Condensed",Helvetica,Arial,sans-serif;; font-family: "Roboto Condensed",Helvetica,Arial,sans-serif;;
} }
...@@ -222,6 +249,47 @@ nav>div{ ...@@ -222,6 +249,47 @@ nav>div{
width:100%; width:100%;
padding-left:20px; padding-left:20px;
} }
.new_wrap{
width:100%;
padding-left:20px;
}
.list_wrap{
padding: 20px 70px;
}
.list_wrap > p{
font-size:14px;
height: 25px;
background: #6e829e;
width: 100px;
color: white;
padding: 2px 10px 0;
margin: 0 0 10px;
}
.new_list{
width:100%;
height:30px;
padding:0 20px;
}
.new_list span{
display: block;
float: left;
color: dimgray;
font-size: 14px;
}
.new_list span:first-child{
width:100px;
}
.new_list a{
color: rgb(52, 133, 251);
}
.new_list a:hover{
text-decoration: underline;
}
.new_list>span:last-child{
/*float: right !important;*/
}
.wrap ul:hover{ .wrap ul:hover{
background: #ddd; background: #ddd;
border-radius: 5px; border-radius: 5px;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
<a href="#cve" class="main_bar">漏洞成果</a> <a href="#cve" class="main_bar">漏洞成果</a>
<a href="#project" class="main_bar">项目研究</a> <a href="#project" class="main_bar">项目研究</a>
<a href="#publish" class="main_bar">出版物</a> <a href="#publish" class="main_bar">出版物</a>
<a href="#member" class="main_bar">成员</a>
<a href="#" class="main_bar active">首页</a> <a href="#" class="main_bar active">首页</a>
</div> </div>
</div> </div>
...@@ -49,8 +50,46 @@ ...@@ -49,8 +50,46 @@
<div class="box"></div> <div class="box"></div>
<div class="left-bar"> <div class="left-bar">
<span> <span>
最新动态
</span>
</div>
<div class="new_wrap">
<div class="list_wrap">
{% for key, item in newest_post_list.items %}
{% if item %}
<p>{{ key }}</p>
{% for it in item %}
<div class="new_list">
<span>{{ it.date }}</span>
{% if key == 'publication' %}
<span>{{ it.author }}在{{ it.journame }}上发表了{{ it.publishType }}</span>
{% else %}
<span>{{ it.author }}发布了</span>
{% endif %}
{% if key == 'cve' %}
<span><a href="{{ it.url }}">{{ it.title }}</a></span>
{% else %}
<span><a href="{{ it.url }}">《{{ it.title }}》</a></span>
{% endif %}
</div>
{% endfor %}
{% endif %}
{% endfor %}
</div>
</div>
</section>
<section id="member">
<div class="box"></div>
<div class="left-bar">
<span>
小组成员 小组成员
</span> </span>
<span class="former">
<button id="show_btn" onclick="show_former()">显示前成员</button>
<button style="display: none" id="close_btn" onclick="close_former()">隐藏</button>
</span>
</div> </div>
<div class="wrap"> <div class="wrap">
{% for tp,users in user_type_list.items %} {% for tp,users in user_type_list.items %}
...@@ -69,7 +108,23 @@ ...@@ -69,7 +108,23 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="wrap" id="former_member" style="display: none;">
{% for tp,users in user_type_list_former.items %}
<div class="member_type">
<p>{{ tp }}</p>
{% if users %}
{% for user in users %}
<ul>
<li>
<a href="{% url 'hunter:detail' user.userID %}" target="_blank">{{ user.name_hanzi }}</a>
</li>
<li class="user_mail">{{ user.mailAddress }}</li>
</ul>
{% endfor %}
{% endif %}
</div>
{% endfor %}
</div>
</section> </section>
...@@ -237,7 +292,7 @@ ...@@ -237,7 +292,7 @@
</footer> </footer>
<script> <script>
var pre_clicked=4; var pre_clicked=5;
window.onload=function(){ window.onload=function(){
$(".bottom>a").click(function(){ $(".bottom>a").click(function(){
let i = $(".bottom>a").index(this); let i = $(".bottom>a").index(this);
...@@ -251,6 +306,17 @@ ...@@ -251,6 +306,17 @@
} }
}; };
function show_former(){
$('#show_btn').css('display','none');
$('#close_btn').css('display','block');
$('#former_member').css('display','block');
}
function close_former(){
$('#show_btn').css('display','block');
$('#close_btn').css('display','none');
$('#former_member').css('display','none');
}
function logout(){ function logout(){
let storage = window.localStorage; let storage = window.localStorage;
......
...@@ -231,7 +231,8 @@ ...@@ -231,7 +231,8 @@
let date = $('#date_input').val(); let date = $('#date_input').val();
let type = $('select[name="type"] option:selected').val(); let type = $('select[name="type"] option:selected').val();
let myfile = $("input[name='myfile']")[0].files[0]; let myfile = $("input[name='myfile']")[0].files[0];
let storage = window.localStorage;
let username = storage.username;
let formatData = new FormData(); let formatData = new FormData();
formatData.append("myfile", myfile); formatData.append("myfile", myfile);
formatData.append("title", title); formatData.append("title", title);
...@@ -239,6 +240,7 @@ ...@@ -239,6 +240,7 @@
formatData.append("journalname", journalname); formatData.append("journalname", journalname);
formatData.append("date", date); formatData.append("date", date);
formatData.append("type", type); formatData.append("type", type);
formatData.append("username", username);
$.ajax({ $.ajax({
url:"{% url 'hunter:add_publication' %} ", url:"{% url 'hunter:add_publication' %} ",
......
...@@ -36,6 +36,25 @@ def index(request): ...@@ -36,6 +36,25 @@ def index(request):
else: else:
user_type_list[member_type] = [u] user_type_list[member_type] = [u]
user_list_former = User.objects.filter(isCurrent=0, identity='0').all()
user_type_list_former = {"Academic STAFF": [], "Phd": [], "Master": [], "Engineer STAFF": []}
for u in user_list_former:
if u.member_type == 0:
u.member_type = "Academic STAFF"
else:
if u.member_type == 1:
u.member_type = "Engineer STAFF"
else:
if u.member_type == 2:
u.member_type = "Phd"
else:
u.member_type = "Master"
member_type = u.member_type
if member_type in user_type_list.keys():
user_type_list_former[member_type].append(u)
else:
user_type_list_former[member_type] = [u]
publication_list = Publications.objects.order_by('-date') publication_list = Publications.objects.order_by('-date')
publication_year_list = {} publication_year_list = {}
for pub in publication_list: for pub in publication_list:
...@@ -70,11 +89,37 @@ def index(request): ...@@ -70,11 +89,37 @@ def index(request):
article_year_list[year].append(art) article_year_list[year].append(art)
else: else:
article_year_list[year] = [art] article_year_list[year] = [art]
newest_post_list = {}
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')
for pub in newest_publication:
pub.author = pub.uploadByUser
pub.url = '/static/hunter/publications/'+pub.link
pub.date = str(pub.date)[5:10]
newest_article = Articles.objects.filter(editDateTime__gte=start).order_by('-editDateTime')
for art in newest_article:
users = User.objects.filter(userID=art.authorID).values('name')
art.author = users[0]['name']
art.url = '/article/'+str(art.articleID)
art.date = str(art.editDateTime)[5:10]
newest_cve = Bugs.objects.filter(datetime__gte=start).order_by('-datetime')
for cve in newest_cve:
cve.title = cve.identifier
cve.author = cve.owner
cve.date = str(cve.datetime)[5:10]
newest_post_list['publication'] = newest_publication
newest_post_list['article'] = newest_article
newest_post_list['cve'] = newest_cve
context = { context = {
'user_type_list': user_type_list, 'user_type_list': user_type_list,
'user_type_list_former': user_type_list_former,
'publication_year_list': publication_year_list, 'publication_year_list': publication_year_list,
'cve_year_list': cve_year_list, 'cve_year_list': cve_year_list,
'article_year_list': article_year_list, 'article_year_list': article_year_list,
'newest_post_list': newest_post_list,
} }
return render(request, 'hunter/index.html', context) return render(request, 'hunter/index.html', context)
...@@ -287,6 +332,7 @@ def add_publication(request): ...@@ -287,6 +332,7 @@ def add_publication(request):
title = request.POST['title'] title = request.POST['title']
print(title) print(title)
authors = request.POST['authors'] authors = request.POST['authors']
uploadby = request.POST['username']
myfile = request.FILES['myfile'] myfile = request.FILES['myfile']
print(authors) print(authors)
s=',' s=','
...@@ -312,7 +358,7 @@ def add_publication(request): ...@@ -312,7 +358,7 @@ def add_publication(request):
dest.close() dest.close()
link = myfile.name link = myfile.name
try: try:
Publications.objects.create(pubID=pubID, title=title,link=link, messages='kidding', authors = authors,journalname=journalname,date=date,) Publications.objects.create(pubID=pubID, title=title,link=link, messages='kidding', authors = authors,journalname=journalname,uploadByUser=uploadby,date=date,)
except ProgrammingError as e: except ProgrammingError as e:
return JsonResponse({"message": 0}) return JsonResponse({"message": 0})
authorArr = authors.split(',') authorArr = authors.split(',')
......
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