Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Rybička
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Rybička
Commits
afc2b8f9
Commit
afc2b8f9
authored
2 years ago
by
Tomáš
Browse files
Options
Downloads
Patches
Plain Diff
ensure repeatability
parent
42c48e82
No related branches found
No related tags found
1 merge request
!1
Test release
Pipeline
#11289
failed
2 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
rv_voting_calc/templates/rv_voting_calc/index.html
+5
-5
5 additions, 5 deletions
rv_voting_calc/templates/rv_voting_calc/index.html
rv_voting_calc/views.py
+16
-3
16 additions, 3 deletions
rv_voting_calc/views.py
static_src/rv_voting_calc.js
+5
-4
5 additions, 4 deletions
static_src/rv_voting_calc.js
with
26 additions
and
12 deletions
rv_voting_calc/templates/rv_voting_calc/index.html
+
5
−
5
View file @
afc2b8f9
...
...
@@ -10,12 +10,12 @@
{% render_bundle "rv_voting_calc" %}
<link
href=
"https://styleguide.pirati.cz/2.1
1
.x/css/styles.css"
href=
"https://styleguide.pirati.cz/2.1
0
.x/css/styles.css"
rel=
"stylesheet"
media=
"all"
>
<link
href=
"https://styleguide.pirati.cz/2.1
1
.x/css/pattern-scaffolding.css"
href=
"https://styleguide.pirati.cz/2.1
0
.x/css/pattern-scaffolding.css"
rel=
"stylesheet"
media=
"all"
>
...
...
@@ -25,7 +25,7 @@
<main>
<h1
class=
"text-6xl font-bebas mb-5"
>
Kalkulačka hlasování RV
</h1>
<div
class=
"grid grid-cols-2 gap-7 mb-5 pb-4 items-center border-b border-gray-100"
>
<div
class=
"grid
grid-cols-1 md:
grid-cols-2 gap-7 mb-5 pb-4 items-center border-b border-gray-100"
>
<h2
class=
"text-2xl font-bebas"
>
Hlasy členů
</h2>
<div
class=
"flex items-center gap-3 justify-between"
>
...
...
@@ -42,7 +42,7 @@
</div>
</div>
<div
class=
"grid grid-cols-2 gap-7"
>
<div
class=
"grid
grid-cols-1 md:
grid-cols-2 gap-7"
>
<ul
class=
"flex flex-col gap-2"
>
{% for member in rv_members %}
<li
class=
"flex gap-4 items-center"
>
...
...
@@ -66,7 +66,7 @@
>
</ul>
<div
class=
"mt-4 flex gap-4 justify-end"
>
<div
class=
"mt-4 flex gap-4
md:
justify-end
justify-center
"
>
<a
class=
"hidden btn"
id=
"permalink"
...
...
This diff is collapsed.
Click to expand it.
rv_voting_calc/views.py
+
16
−
3
View file @
afc2b8f9
...
...
@@ -4,6 +4,7 @@ import json
import
math
import
random
import
secrets
import
urllib.parse
import
gql
import
requests
...
...
@@ -57,6 +58,8 @@ def index(request):
# Get votes from a possible permalink
options_by_member
=
request
.
GET
.
get
(
"
votes
"
)
if
options_by_member
is
not
None
:
options_by_member
=
urllib
.
parse
.
unquote
(
options_by_member
)
# BEGIN Input validation
if
options_by_member
is
not
None
:
...
...
@@ -86,12 +89,12 @@ def get_rv_members(request, get_rv_gid: bool = False):
rv_gid
=
None
if
"
rv_gid
"
in
request
.
GET
:
rv_gid
=
urllib
.
parse
.
unquote
(
request
.
GET
[
"
rv_gid
"
])
try
:
base64
.
b64decode
(
request
.
GET
[
"
rv_gid
"
]
,
validate
=
True
)
base64
.
b64decode
(
rv_gid
,
validate
=
True
)
except
binascii
.
Error
:
raise
HTTPExceptions
.
BAD_REQUEST
rv_gid
=
request
.
GET
[
"
rv_gid
"
]
else
:
rv_gid
=
settings
.
CHOBOTNICE_RV_GID
...
...
@@ -465,6 +468,8 @@ def do_step_b_through_d(
def
get_calculated_votes
(
request
):
options_by_member
=
request
.
GET
.
get
(
"
votes
"
)
if
options_by_member
is
not
None
:
options_by_member
=
urllib
.
parse
.
unquote
(
options_by_member
)
# BEGIN Input validation
...
...
@@ -596,8 +601,15 @@ def get_calculated_votes(request):
base64
.
b64encode
(
secrets
.
token_bytes
()).
decode
(
"
utf-8
"
)
)
)
# Unquote the seed if it was found in the URL parameters
if
"
seed
"
in
request
.
GET
:
seed
=
urllib
.
parse
.
unquote
(
seed
)
random
.
seed
(
seed
)
print
(
seed
)
# Continue until steps B - D have reached a final conclusion and count
# the amount of times the function ran to achieve this.
iteration
=
0
...
...
@@ -623,6 +635,7 @@ def get_calculated_votes(request):
"
md_steps
"
:
md_steps
}
)
# Set the random seed cookie to the one used in the calculation.
response
.
set_cookie
(
"
seed
"
,
seed
)
# Do the same for RV's GID.
...
...
This diff is collapsed.
Click to expand it.
static_src/rv_voting_calc.js
+
5
−
4
View file @
afc2b8f9
...
...
@@ -93,11 +93,11 @@ $(window).ready(
+
`?votes=
${
encodeURIComponent
(
JSON
.
stringify
(
votes
))}
`
+
(
(
rvGid
!==
null
)
?
`&rv_gid=
${
rvGid
}
`
:
""
`&rv_gid=
${
encodeURIComponent
(
rvGid
)
}
`
:
""
)
+
(
(
seed
!==
null
)
?
`&seed=
${
seed
}
`
:
""
`&seed=
${
encodeURIComponent
(
seed
)
}
`
:
""
)
);
...
...
@@ -115,8 +115,8 @@ $(window).ready(
// Base URL
window
.
location
.
href
.
split
(
'
?
'
)[
0
]
+
`?votes=
${
encodeURIComponent
(
JSON
.
stringify
(
votes
))}
`
+
`&rv_gid=
${
Cookies
.
get
(
"
rv_gid
"
)}
`
+
`&seed=
${
Cookies
.
get
(
"
seed
"
)}
`
+
`&rv_gid=
${
encodeURIComponent
(
Cookies
.
get
(
"
rv_gid
"
)
)
}
`
+
`&seed=
${
encodeURIComponent
(
Cookies
.
get
(
"
seed
"
)
)
}
`
)
);
$
(
"
#download-log
"
).
attr
(
...
...
@@ -127,6 +127,7 @@ $(window).ready(
)
);
$
(
"
#result
"
)[
0
].
scrollIntoView
();
$
(
event
.
currentTarget
).
removeClass
(
"
btn--loading
"
).
prop
(
"
disabled
"
,
false
);
}
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment