Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spn-website
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jochen Bauer
spn-website
Commits
3cf27a4f
Commit
3cf27a4f
authored
May 11, 2018
by
nachtgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GET rotate=anything starts a GUI rotation
parent
3202268d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
highscore/templates/highscore/table.html
highscore/templates/highscore/table.html
+11
-1
highscore/views.py
highscore/views.py
+7
-4
No files found.
highscore/templates/highscore/table.html
View file @
3cf27a4f
...
...
@@ -48,4 +48,14 @@
</tbody>
</table>
</div>
{% endblock %}
\ No newline at end of file
{% endblock %}
{% block js %}
{% if rotate %}
<script>
setTimeout
(
function
(){
document
.
location
.
href
=
"
{% url rotate %}?rotate=rotate
"
;
},
3000
);
</script>
{% endif %}
{% endblock %}
highscore/views.py
View file @
3cf27a4f
...
...
@@ -17,7 +17,7 @@ def gattr(obj, attr):
return
getattr
(
obj
,
attr
)
def
table
(
request
,
data
,
usr
,
title
):
def
table
(
request
,
data
,
usr
,
title
,
rotate
):
i
=
0
for
d
in
data
:
...
...
@@ -31,6 +31,9 @@ def table(request, data, usr, title):
if
request
.
user
.
is_authenticated
:
context
[
'usr'
]
=
usr
if
request
.
GET
.
get
(
'rotate'
):
context
[
'rotate'
]
=
rotate
return
render
(
request
,
'highscore/table.html'
,
context
=
context
)
def
score
(
request
):
...
...
@@ -39,7 +42,7 @@ def score(request):
usr
=
SnakeGame
.
objects
.
filter
(
user
=
request
.
user
).
aggregate
(
score
=
Max
(
'final_mass'
))
else
:
usr
=
False
return
table
(
request
,
data
,
usr
,
'Highscore'
)
return
table
(
request
,
data
,
usr
,
'Highscore'
,
'highscore_maxage'
)
def
maxage
(
request
):
data
=
SnakeGame
.
objects
.
values
(
'user__username'
).
annotate
(
score
=
Max
(
F
(
'end_frame'
)
-
F
(
'start_frame'
))).
order_by
(
'-score'
)
...
...
@@ -48,7 +51,7 @@ def maxage(request):
usr
=
SnakeGame
.
objects
.
filter
(
user
=
request
.
user
).
aggregate
(
score
=
Max
(
F
(
'end_frame'
)
-
F
(
'start_frame'
)))
else
:
usr
=
False
return
table
(
request
,
data
,
usr
,
'Max Age'
)
return
table
(
request
,
data
,
usr
,
'Max Age'
,
'highscore_consumerate'
)
def
consumerate
(
request
):
data
=
SnakeGame
.
objects
.
raw
(
...
...
@@ -89,4 +92,4 @@ def consumerate(request):
)[
0
]
else
:
usr
=
False
return
table
(
request
,
data
,
usr
,
'Consume Rate'
)
return
table
(
request
,
data
,
usr
,
'Consume Rate'
,
'highscore'
)
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