Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hunter-ht.cn
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘莹莹
hunter-ht.cn
Commits
c8d96667
Commit
c8d96667
authored
Apr 28, 2020
by
liuyingying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改个人信息
parent
9fbad193
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
225 additions
and
0 deletions
+225
-0
profile.html
Hunter_ht/hunter/templates/hunter/profile.html
+204
-0
urls.py
Hunter_ht/hunter/urls.py
+1
-0
views.py
Hunter_ht/hunter/views.py
+20
-0
No files found.
Hunter_ht/hunter/templates/hunter/profile.html
0 → 100644
View file @
c8d96667
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
修改个人信息
</title>
</head>
<style
type=
"text/css"
>
*
{
box-sizing
:
border-box
;
transition
:
all
.5s
;
-moz-transition
:
all
.5s
;
-webkit-transition
:
all
.5s
;
-o-transition
:
all
.5s
;
margin
:
0
;
padding
:
0
;
}
body
{
background-color
:
rgba
(
253
,
253
,
253
,
.3
);
width
:
100%
;
}
nav
{
width
:
100%
;
height
:
40px
;
position
:
fixed
;
/*border-bottom: solid 1px #e3e6e8;*/
background
:
white
;
}
nav
>
div
{
width
:
100%
;
height
:
40px
;
border-bottom
:
solid
1px
#ececec
}
button
{
/* border: solid 1px black; */
border-radius
:
5px
;
width
:
50px
;
height
:
30px
;
border
:
solid
1px
#f1f1f1
;
cursor
:
pointer
;
float
:
left
;
margin
:
5px
;
}
#hunter
{
width
:
40%
;
height
:
100%
;
float
:
left
;
position
:
relative
;
}
#hunter
>
span
{
font-family
:
"Bitstream Vera Sans Mono"
,
Monaco
,
"Courier New"
,
Courier
,
monospace
;
font-size
:
38px
;
font-weight
:
bold
;
height
:
40px
;
display
:
block
;
position
:
absolute
;
left
:
25px
;
bottom
:
25px
;
}
#bar
{
width
:
60%
;
height
:
100%
;
float
:
left
;
}
.close_btn
{
background-color
:
white
;
color
:
dimgray
;
}
.close_btn
:hover
{
background-color
:
whitesmoke
;
color
:
black
;
}
.submit_btn
{
color
:
white
;
background-color
:
rgb
(
52
,
133
,
251
)
;
}
.submit_btn
:hover
{
background-color
:
#306cc5
;
}
#profile
{
min-width
:
800px
;
min-height
:
100%
;
padding-top
:
50px
;
}
</style>
<body>
<nav>
<div>
<div
id=
"hunter"
>
<span>
HUNTER
</span>
</div>
<div
id=
"bar"
>
<div
class=
"btn"
>
<button
onclick=
"close_window()"
class=
"close_btn"
>
关闭
</button>
<button
onclick=
"submit_profile()"
class=
"submit_btn"
>
确认
</button>
</div>
</div>
</div>
</nav>
<div
id=
"profile"
>
<div
class=
"item"
>
<label
for=
"username"
>
用户名:
</label>
<input
id=
"username"
disabled
type=
"text"
value=
"{{ user.name }}"
>
<span
class=
"hint"
>
不可更改
</span>
</div>
<div
class=
"item"
>
<label
for=
"name_hanzi"
>
姓名:
</label>
<input
id=
"name_hanzi"
name=
"name_hanzi"
type=
"text"
value=
"{{ user.name_hanzi }}"
>
<span
class=
"required"
>
*
</span>
</div>
<div
class=
"item"
>
<label
for=
"name_eng"
>
Name:
</label>
<input
id=
"name_eng"
name=
"name_eng"
type=
"text"
placeholder=
"Pin Yin or Tom"
value=
"{{ user.name_eng }}"
>
<span
class=
"required"
>
*
</span>
</div>
<div
class=
"item"
>
<label
for=
"pwd"
>
新密码:
</label>
<input
id=
"pwd"
name=
"pwd"
type=
"text"
>
</div>
<div
class=
"item"
>
<label
for=
"confirm_pwd"
>
确认密码:
</label>
<input
id=
"confirm_pwd"
type=
"text"
>
</div>
<div
class=
"item"
>
<label
for=
"mail"
>
邮箱:
</label>
<input
id=
"mail"
name=
"mail"
type=
"text"
value=
"{{ user.mailAddress }}"
>
<span
class=
"required"
></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=
"required"
></span>
</div>
<div
class=
"item"
>
<span
class=
"error_log"
></span>
</div>
</div>
<script
type=
"text/javascript"
>
window
.
onload
=
function
(){
let
storage
=
window
.
localStorage
;
if
(
!
storage
[
'userID'
]){
alert
(
"请先登录"
);
close_window
();
}
};
function
close_window
(){
window
.
open
(
'www.hunter-ht.cn'
);
}
function
submit_profile
()
{
let
storage
=
window
.
localStorage
;
let
userID
=
storage
.
userID
;
let
name_hanzi
=
$
(
"input[name='name_hanzi']"
).
val
();
let
name_eng
=
$
(
"input[name='name_eng']"
).
val
();
let
pwd
=
$
(
"#pwd"
).
val
();
let
mail
=
$
(
"#mail"
).
val
()
||
" "
;
let
website
=
$
(
"#personal_web"
).
val
()
||
" "
;
if
(
pwd
!==
$
(
"#confirm_pwd"
).
val
()){
$
(
"#error_log"
).
innerHTML
=
"密码不一致"
;
}
else
if
(
name_eng
&&
name_hanzi
)
{
$
(
"#error_log"
).
innerHTML
=
"请填写中英文姓名"
;
}
else
{
let
storage
=
window
.
localStorage
;
let
userID
=
storage
.
userID
;
let
name_hanzi
=
$
(
"input[name='name_hanzi']"
).
val
();
let
name_eng
=
$
(
"input[name='name_eng']"
).
val
();
let
pwd
=
$
(
"#pwd"
).
val
();
let
mail
=
$
(
"#mail"
).
val
();
let
website
=
$
(
"#personal_web"
).
val
();
$
.
ajax
({
url
:
'/profile_edit/'
,
type
:
'post'
,
dataType
:
'json'
,
data
:{
"userID"
:
userID
,
"name_hanzi"
:
name_hanzi
,
"name_eng"
:
name_eng
,
"pwd"
:
pwd
,
"mail"
:
mail
,
"website"
:
website
,
},
success
:
function
(
response
){
console
.
log
(
response
);
if
(
response
[
'message'
]){
alert
(
'修改成功'
);
window
.
location
.
href
=
'www.hunter-ht.cn'
;
}
else
{
alert
(
"提交失败,请反馈"
);
}
},
error
:
function
(
xhr
)
{
console
.
error
(
'something went wrong...'
);
}
})
}
}
</script>
</body>
</html>
\ No newline at end of file
Hunter_ht/hunter/urls.py
View file @
c8d96667
...
@@ -8,6 +8,7 @@ urlpatterns = [
...
@@ -8,6 +8,7 @@ urlpatterns = [
# 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
(
'user/edit/profile/<int:user_id>/'
,
views
.
detail
,
name
=
'detail'
),
path
(
'user/detail/<int:user_id>/'
,
views
.
detail
,
name
=
'detail'
),
path
(
'user/detail/<int:user_id>/'
,
views
.
detail
,
name
=
'detail'
),
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'
),
...
...
Hunter_ht/hunter/views.py
View file @
c8d96667
...
@@ -441,3 +441,23 @@ def add_cve(request):
...
@@ -441,3 +441,23 @@ def add_cve(request):
@csrf_exempt
@csrf_exempt
def
add_article
(
request
):
def
add_article
(
request
):
return
0
return
0
def
profile_edit
(
request
,
user_id
):
user
=
get_object_or_404
(
User
,
pk
=
user_id
)
return
render
(
request
,
'hunter/profile.html'
,
{
'user'
:
user
})
@csrf_exempt
def
profile_submit
(
request
):
userID
=
request
.
POST
[
"userID"
]
name_hanzi
=
request
.
POST
[
"name_hanzi"
]
name_eng
=
request
.
POST
[
"name_eng"
]
pwd
=
request
.
POST
[
"pwd"
]
mail
=
request
.
POST
[
"mail"
]
website
=
request
.
POST
[
"website"
]
try
:
User
.
objects
.
filter
(
userID
=
userID
)
.
update
(
name_hanzi
=
name_hanzi
,
name_eng
=
name_eng
,
pwd
=
pwd
,
mailAddress
=
mail
,
personal_website
=
website
)
return
JsonResponse
({
'message'
:
1
})
except
ObjectDoesNotExist
as
e
:
return
JsonResponse
({
"message"
:
0
,
'error'
:
e
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment