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
2e9ee869
Commit
2e9ee869
authored
May 12, 2020
by
liuyingying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
挪动积分代码
parent
f255bf7a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
169 additions
and
0 deletions
+169
-0
admin.html
hunter/templates/hunter/admin.html
+146
-0
urls.py
hunter/urls.py
+3
-0
views.py
hunter/views.py
+20
-0
No files found.
hunter/templates/hunter/admin.html
0 → 100644
View file @
2e9ee869
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Title
</title>
</head>
<body>
<div
id=
"scoreRecords"
class=
"userlist"
style=
"display: none;"
>
<div
id=
"addScoreForm"
>
<div
style=
"margin-left:-150px;"
>
<select
class=
"select_0"
>
{% for user in users %}
<option
value=
"{{ user.userID }}"
>
{{ user.name }}
</option>
{% endfor %}
</select>
</div>
<div
style=
"width:40%;"
>
<div>
<input
id=
"reason"
name=
"reason"
type=
"text"
autocomplete=
"off"
placeholder=
"加积分或抵扣积分理由"
required
>
</div>
</div>
<div
class =
"addScore"
>
<select
class=
"select_1"
>
<option
value=
"1"
selected
>
奖励
</option>
<option
value=
"0"
>
抵扣
</option>
</select>
<button
class=
"addOrsub"
onclick=
"subScoreBtn()"
>
-
</button>
{#
<div>
#}
<input
id=
"scoreValue"
name=
"scoreValue"
style=
"width:50px; height: 34px; border:solid 1px #ccc;border-radius: 2px; text-align: center"
type=
"text"
autocomplete=
"off"
value=
"1"
>
{#
</div>
#}
<button
class=
"addOrsub"
onclick=
"addScoreBtn()"
>
+
</button>
</div>
<div>
<div>
<button
id=
"submitScore"
class=
"addScorebtn"
onclick=
"submitScore()"
>
确定
</button>
<p
style=
"color:red"
>
{{ message }}
</p>
</div>
</div>
</div><br>
<div
class=
" user_score_List"
>
<div
class=
"list_head"
>
<ul>
<li>
姓名
</li>
<li>
总分
</li>
<li>
已使用
</li>
<li>
可用积分
</li>
</ul>
</div>
{% for user in users %}
<ul
class=
"list_score_body"
id=
"{{ user.userID }}"
>
<li>
{{ user.name }}
</li>
<li>
{{ user.score }}
</li>
<li>
{{ user.scoreUsed }}
</li>
<li></li>
<li
style=
"display: none;"
>
{{ user.identity }}
</li>
</ul>
{% endfor %}
</div>
<div
class=
" score_history_List hide"
>
<div
class=
"list_head"
>
<ul>
<li>
姓名
</li>
<li>
详情
</li>
<li>
日期
</li>
</ul>
</div>
{% for record in records %}
<ul
class=
"list_records_body"
>
<li>
{{ record.username }}
</li>
<li>
{{ record.reason }}
</li>
<li>
{{ record.editDate }}
</li>
</ul>
{% endfor %}
</div>
</div>
<script>
function
showAddScore
(){
var
addScoreForm
=
document
.
getElementById
(
"addScoreForm"
);
addScoreForm
.
style
.
display
=
'block'
;
}
function
addScoreBtn
(){
document
.
getElementById
(
'scoreValue'
).
value
=
parseInt
(
document
.
getElementById
(
'scoreValue'
).
value
)
+
1
;
}
function
subScoreBtn
(){
document
.
getElementById
(
'scoreValue'
).
value
=
parseInt
(
document
.
getElementById
(
'scoreValue'
).
value
)
-
1
;
}
function
submitScore
()
{
var
usernameSel
=
document
.
getElementsByClassName
(
"select_0"
)[
0
];
var
index_0
=
usernameSel
.
selectedIndex
;
var
user_name
=
usernameSel
.
options
[
index_0
].
text
;
var
user_ID
=
usernameSel
.
options
[
index_0
].
value
;
var
addSel
=
document
.
getElementsByClassName
(
"select_1"
)[
0
];
var
index_1
=
addSel
.
selectedIndex
;
var
addOrSub
=
addSel
.
options
[
index_1
].
value
;
var
reason
=
document
.
getElementById
(
"reason"
).
value
;
if
(
reason
.
length
===
0
){
alert
(
"请填写加分或抵扣理由"
);
return
;
}
var
scoreNum
=
document
.
getElementById
(
"scoreValue"
).
value
;
$
.
ajax
({
url
:
/add_sub_score/
,
type
:
'post'
,
data
:
{
"username"
:
user_name
,
"userID"
:
user_ID
,
"score"
:
scoreNum
,
"reason"
:
reason
,
"action"
:
addOrSub
,
},
dataType
:
'json'
,
success
:
function
(
response
)
{
console
.
log
(
response
);
alert
(
response
[
"message"
]);
if
(
response
[
"message"
]
===
"success"
)
{
var
userUl
=
document
.
getElementById
(
user_ID
);
if
(
addOrSub
===
"1"
){
userUl
.
children
[
1
].
innerText
=
parseInt
(
userUl
.
children
[
1
].
innerText
)
+
parseInt
(
scoreNum
);
userUl
.
children
[
3
].
innerText
=
parseInt
(
userUl
.
children
[
3
].
innerText
)
+
parseInt
(
scoreNum
);
}
else
{
console
.
log
(
"减积分"
)
userUl
.
children
[
2
].
innerText
=
parseInt
(
userUl
.
children
[
2
].
innerText
)
+
parseInt
(
scoreNum
);
userUl
.
children
[
3
].
innerText
=
parseInt
(
userUl
.
children
[
3
].
innerText
)
-
parseInt
(
scoreNum
);
}
}
},
error
:
function
(
xhr
)
{
console
.
error
(
'Something went wrong....'
);
}
});
}
</script>
</body>
</html>
\ No newline at end of file
hunter/urls.py
View file @
2e9ee869
...
...
@@ -29,4 +29,6 @@ urlpatterns = [
path
(
'add/cve/'
,
views
.
add_cve
,
name
=
'add_cve'
),
path
(
'edit/cve/'
,
views
.
edit_cve
,
name
=
'edit_cve'
),
path
(
'add/article/'
,
views
.
add_article
,
name
=
'add_article'
),
path
(
'/ht/admin/'
,
views
.
admin
,
name
=
'admin'
),
]
\ No newline at end of file
hunter/views.py
View file @
2e9ee869
...
...
@@ -708,3 +708,23 @@ def profile_submit(request):
def
edit_art
(
request
,
article_id
):
art
=
get_object_or_404
(
Articles
,
pk
=
article_id
)
return
render
(
request
,
'hunter/editArticle.html'
,
{
'article'
:
art
})
# 管理员
def
admin
(
request
):
if
User
.
objects
.
last
():
if
User
.
objects
.
last
()
.
userID
>
0
:
users
=
User
.
objects
.
all
()
publications
=
Publications
.
objects
.
all
()
for
user
in
users
:
if
user
.
identity
==
'0'
:
user
.
identity
=
'普通用户'
else
:
user
.
identity
=
'管理员'
if
ScoreRecords
.
objects
.
last
()
is
None
:
records
=
0
;
else
:
records
=
ScoreRecords
.
objects
.
all
();
return
render
(
request
,
"admin.html"
,
locals
())
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