Commit 1a50360a by liuyingying

个人信息修改

parent 5f153bdb
......@@ -21,11 +21,20 @@ class User(models.Model):
scoreUsed = models.IntegerField(default=0)
personal_website = models.CharField(max_length=1000, default='')
mailAddress = models.CharField(max_length=100, default='mail@example.com')
profile = models.TextField(default=' ')
def is_admin(self):
return self.identity
class Education(models.Model):
userID = models.BigIntegerField(default=0)
start = models.DateField(default=timezone.now)
stop = models.DateField(default=timezone.now)
university = models.CharField(max_length=1000, default='')
degree = models.CharField(max_length=100, default='')
class Publications(models.Model):
pubID = models.BigIntegerField(primary_key=True)
title = models.CharField(max_length=1000)
......
......@@ -9,7 +9,6 @@
}
html,body{
width:100%;
font-family: -webkit-pictograph;
}
div{
width:100%;
......@@ -95,7 +94,7 @@ li:after{
display: block;
font-size:20px;
font-weight: 600;
border-bottom: solid 3px black;
border-bottom: solid 2px black;
}
.content{
width:100%;
......@@ -156,12 +155,29 @@ li:after{
font-style: italic;
font-weight: bold;
}
.education{
}
.education li{
list-style-type: none;
float: left;
width:33%;
}
.education ul li:first-child{
font-weight:200;
font-size: 14px;
}
.education ul li:last-child{
text-align: right;
}
.profile{
padding:10px 5px;
}
.ul_list{
width:100%;
}
.ul_list>ul{
width:100%;
padding-left: 40px;
}
.ul_list ul>li{
width:100%;
......
......@@ -125,8 +125,8 @@ nav{
position: fixed;
/*border-bottom: solid 1px #e3e6e8;*/
background:white;
margin-top:80px;
z-index: 9999;
margin-top:80px;
}
section{
......@@ -143,6 +143,80 @@ nav>div{
width:100%;
height:100%;
}
.welcome{
width:100%;
height:100%;
margin-top:-80px;
padding-top:90px;
position:relative;
}
#our_bg{
width:80%;
height:80%;
transition: .5s ease-in-out;
margin:0 auto;
position:absolute;
z-index:9;
left:10%;
}
#bg_img{
background: url("/static/hunter/images/welcome.jpeg") no-repeat;
background-size:100% 100%;
margin:0 auto;
height:100%;
width:100%;
}
#our_intro{
width:80%;
height:80%;
background-color:rgba(0,0,0,.3);
color:white;
z-index:99;
position:absolute;
left:10%;
}
#our_intro>p{
width:100%;
display: block;
text-align: center;
}
#our_intro>span{
color:white;
text-align:center;
width:100%;
display: block;
}
.bar_bottom{
width:80%;
height:60px;
background-color: white;
border:solid 1px grey;
position:absolute;
bottom:0;
left:10%;
}
.bar_bottom>div{
width:600px;
height:100%;
margin:0 auto;
}
.bar_bottom span{
float: left;
height:100%;
}
.bar_bottom a{
float: left;
display:block;
width:50px;
height:50px;
margin:5px;
background: url("/static/hunter/images/edit.png") no-repeat;
background-size:100% 100%;
}
.bar_bottom:hover{
background: transparent;
}
#hunter{
width:40%;
height:100%;
......
......@@ -26,6 +26,24 @@
</div>
<div class="wrap">
<div class="section">
<span>MY PROFILE</span>
<div class="profile">
{{ user.profile }}
</div>
</div>
<div class="section">
<span>EDUCATION</span>
<div class="education">
{% for item in education_list %}
<ul>
<li>{{ item.start }} - {{ item.stop }}</li>
<li>{{ item.university }}</li>
<li>{{ item.degree }}</li>
</ul>
{% endfor %}
</div>
</div>
<div class="section">
<span>PUBLICATIONS</span>
{% for year,publications in publication_year_list.items %}
<div class="content">
......
......@@ -26,6 +26,7 @@
</div>
</div>
</div>
<div class="wrap" id="former_member">
<div class="member_wrap" onclick="close_former()" title="点击空白处关闭">
{% for tp,users in user_type_list_former.items %}
......@@ -60,11 +61,28 @@
<a href="#project" 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="#home" class="main_bar active">最新动态</a>
</div>
</div>
</div>
</nav>
<section class="welcome">
<div id="our_bg">
<div id="bg_img">
</div>
</div>
<div id="our_intro">
<p>HUNTER-HT</p>
<span>Hunter is a software research group that focuses on vulnerability detection. Our research interests cover multiple layers of software, including operating systems, firmware, binaries and web aplications. We are committed to developing tools of symbolic execution, fuzzing and binary analysis for automated detection of software vulnerabilities</span>
</div>
<div class="bar_bottom">
<div>
<span>去看看我们的Hunter圈</span>
<a href="" target="_blank">GO</a>
</div>
</div>
</section>
<section id="home">
<div class="box"></div>
<div class="left-bar">
......
......@@ -15,6 +15,7 @@
-o-transition:all .5s;
margin:0;
padding: 0;
}
body{
background-color: rgba(253, 253, 253, .3);
......@@ -51,12 +52,12 @@
#hunter>span{
font-family: "Bitstream Vera Sans Mono", Monaco, "Courier New", Courier, monospace;
font-size: 20px;
font-weight: bold;
height: 40px;
line-height: 40px;
display: block;
position: absolute;
left: 25px;
font-weight: bold;
height: 40px;
line-height: 40px;
display: block;
position: absolute;
left: 25px;
}
#bar{
width:60%;
......@@ -103,6 +104,12 @@
width: 200px;
padding-left: 5px;
}
.item textarea{
width:600px;
height:200px;
border:solid 1px #f1f1f1;
padding:5px 10px;
}
.item .required{
color: red;
font-size: 12px;
......@@ -113,6 +120,7 @@
color: #9c9c9c;
margin: 15px 7px 0;
}
.item button{
float: right;
}
......@@ -132,6 +140,51 @@
float:left;
}
#education{
}
.edu_item{
margin-bottom:10px;
width:650px;
}
.edu_item label{
font-size:13px;
font-weight: 200;
width:40px;
height:30px;
line-height:30px;
}
.edu_item input{
height:30px;
border-radius:0;
}
.edu_item div{
width:300px;
margin-bottom:5px;
}
.add_btn{
width:600px;
}
.add_btn > button{
float: left;
width: 25px;
height: 25px;
outline:none;
overflow: hidden;
background-size:contain;
background-image: url("/static/hunter/images/add.png");
}
.dele_edu{
width:110px;
height:100%;
}
.dele_edu >button{
width:20px;
height:20px;
border:none;
background-image: url("/static/hunter/images/delete.png");
}
</style>
<body>
......@@ -177,13 +230,49 @@
<div class="item">
<label for="mail">邮箱:</label>
<input id="mail" name="mail" type="text" value="{{ user.mailAddress }}">
<span class="hint">在首页成员列表个人详情页面显示</span>
<span class="hint">在首页成员列表 + 个人详情页面显示</span>
</div>
<div class="item">
<label for="personal_web">个人网站:</label>
<input id="personal_web" name="personal_web" type="text" value="{{ user.personal_website }}">
<span class="hint">可选填,在个人信息页面显示</span>
</div>
<div class="item" style="_height:50px; min-height:50px;">
<label for="education">教育经历:</label>
<div class="add_btn"><button onclick="add_edu()"></button></div>
<div id="education">
{% for edu in edus %}
<div>
<div class="dele_edu"><button onclick="dele_edu(this)"></button></div>
<div class="edu_item">
<div>
<label for="start"></label>
<input name="start" type="date" value="{{ edu.start }}">
</div>
<div>
<label for="stop"></label>
<input name="stop" type="date" value="{{ edu.stop }}">
</div>
<div>
<label for="university">学校</label>
<input name="university" value="{{ edu.university }}">
</div>
<div>
<label for="degree">学位</label>
<input name="degree" value="{{ edu.degree }}">
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="item">
<label for="extra_profile">
My Profile:
</label>
<textarea name="extra_profile" id="extra_profile" placeholder="添加自我介绍,补充信息" >{{ user.profile }}</textarea>
</div>
<div class="item">
<button onclick="close_window()" class="close_btn">关闭</button>
<button onclick="submit_profile()" class="submit_btn">确认</button>
......@@ -204,6 +293,33 @@
function close_window(){
window.close();
}
function add_edu(){
let item = '<div>\n' +
' <div class="dele_edu"><button onclick="dele_edu(this)"></button></div>\n' +
' <div class="edu_item">\n' +
' <div>\n' +
' <label for="start">起</label>\n' +
' <input name="start" type="date">\n' +
' </div>\n' +
' <div>\n' +
' <label for="stop">止</label>\n' +
' <input name="stop" type="date">\n' +
' </div>\n' +
' <div>\n' +
' <label for="university">学校</label>\n' +
' <input name="university">\n' +
' </div>\n' +
' <div>\n' +
' <label for="degree">学位</label>\n' +
' <input name="degree">\n' +
' </div>\n' +
' </div>\n' +
' </div>';
$("#education").append(item);
}
function dele_edu(thisBtn){
$(thisBtn.parentElement.parentElement).remove();
}
function submit_profile() {
let storage = window.localStorage;
let userID = storage.userID;
......@@ -212,6 +328,30 @@
let pwd = $("#pwd").val();
let mail = $("#mail").val()||" ";
let website = $("#personal_web").val()||" ";
let length = $('#education').children().length;/*开始读教育数据*/
let profile = $('#extra_profile').val();
let edu_arr = "";
let start_n = $('input[name="start"]');
let stop_n = $('input[name="stop"]');
let university_n = $('input[name="university"]');
let degree_n = $('input[name="degree"]');
for(let i=0; i<length; i++){
if(start_n[i].value&&stop_n[i].value&&university_n[i]&&degree_n[i].value){
edu_arr+=start_n[i].value;
edu_arr+="&";
edu_arr+=stop_n[i].value;
edu_arr+="&";
edu_arr+=university_n[i].value;
edu_arr+="&";
edu_arr+=degree_n[i].value;
edu_arr+="#";
}
else{
$("#error_log").empty();
$("#error_log").append("教育经历请填写完整,或者删除");
}
}
console.log(edu_arr);
if(pwd!==$("#confirm_pwd").val()){
$("#error_log").innerHTML="密码不一致";
}else if(!name_eng&&!name_hanzi)
......@@ -230,14 +370,14 @@
"pwd":pwd,
"mail":mail,
"website":website,
"profile":profile,
"length":length,
"edu_arr":edu_arr,
},
success:function(response){
console.log(response);
if(response['message']){
alert('修改成功');
window.close();
window.open('/');
}else{
alert("提交失败,请反馈");
}
......
......@@ -236,11 +236,16 @@ def detail(request, user_id):
my_article_year_list[year].append(art)
else:
my_article_year_list[year] = [art]
education_list = Education.objects.filter(userID=user_id).order_by("-start")
for item in education_list:
item.start = str(item.start)[0:10].replace('-','.')
item.stop = str(item.stop)[0:10].replace('-','.')
context = {
'user': usr,
'art_year_list': my_article_year_list,
'publication_year_list': publication_year_list,
'cve_year_list': my_cve_year_list,
'education_list': education_list,
}
return render(request, 'hunter/detail.html', context)
......@@ -651,7 +656,11 @@ def add_article(request):
def profile_edit(request, user_id):
user = get_object_or_404(User, pk=user_id)
return render(request, 'hunter/profile.html', {'user': user})
edu = Education.objects.filter(userID=user_id).order_by("-start")
for item in edu:
item.start=str(item.start)[0:10]
item.stop=str(item.stop)[0:10]
return render(request, 'hunter/profile.html', {'user': user, 'edus':edu})
@csrf_exempt
......@@ -662,15 +671,35 @@ def profile_submit(request):
pwd=request.POST["pwd"]
mail=request.POST["mail"]
website=request.POST["website"]
length = request.POST["length"]
profile = request.POST['profile']
print(profile)
edus = {}
if int(length)>0:
edu_arr = request.POST['edu_arr']
print(edu_arr)
edu_arr = edu_arr.split('#')
if Education.objects.filter(userID=userID).count()>0:
Education.objects.filter(userID=userID).delete()
for index in range(len(edu_arr)-1):
values = edu_arr[index]
item = str(values).split('&')
edus[index]=str(values).split('&')
try:
Education.objects.create(userID=userID,start=item[0], stop=item[1], university=item[2], degree=item[3])
except ProgrammingError as e:
return JsonResponse({"message": 0, 'error': e})
print(edus)
if len(str(pwd).strip()) > 0:
try:
User.objects.filter(userID=userID).update(name_hanzi=name_hanzi, name_eng=name_eng, pwd=pwd, mailAddress= mail, personal_website=website)
User.objects.filter(userID=userID).update(name_hanzi=name_hanzi, name_eng=name_eng, pwd=pwd, mailAddress= mail, personal_website=website, profile=profile)
return JsonResponse({'message':1})
except ObjectDoesNotExist as e:
return JsonResponse({"message":0,'error':e})
else:
try:
User.objects.filter(userID=userID).update(name_hanzi=name_hanzi, name_eng=name_eng, mailAddress= mail, personal_website=website)
User.objects.filter(userID=userID).update(name_hanzi=name_hanzi, name_eng=name_eng, mailAddress= mail, personal_website=website, profile=profile)
return JsonResponse({'message':1})
except ObjectDoesNotExist as 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