Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helios Server
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Helios Server
Commits
7d00d841
Commit
7d00d841
authored
14 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
added social buttons to cast vote
parent
046e14ec
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
helios/templates/cast_done.html
+4
-0
4 additions, 0 deletions
helios/templates/cast_done.html
helios/views.py
+25
-10
25 additions, 10 deletions
helios/views.py
with
29 additions
and
10 deletions
helios/templates/cast_done.html
+
4
−
0
View file @
7d00d841
...
...
@@ -13,6 +13,10 @@
<tt
style=
"font-size:1.8em; font-weight: bold; padding-left: 20px;"
>
{{vote_hash}}
</tt>
</p>
<p>
<iframe
src=
"{{socialbuttons_url}}"
frameborder=
"0"
border=
"0"
style=
"width: 300px; height:35px;"
scrolling=
"no"
align=
"middle"
></iframe>
</p>
{% if logout %}
<p><b>
For your safety, we have logged you out.
</b></p>
<iframe
width=
"0"
height=
"0"
border=
"0"
frameborder=
"0"
src=
"/auth/logout"
>
...
...
This diff is collapsed.
Click to expand it.
helios/views.py
+
25
−
10
View file @
7d00d841
...
...
@@ -61,6 +61,19 @@ def get_election_govote_url(election):
def
get_castvote_url
(
cast_vote
):
return
settings
.
URL_HOST
+
reverse
(
castvote_shortcut
,
args
=
[
cast_vote
.
vote_tinyhash
])
# social buttons
def
get_socialbuttons_url
(
url
,
text
):
if
not
text
:
return
None
return
"
%s%s?%s
"
%
(
settings
.
SOCIALBUTTONS_URL_HOST
,
reverse
(
socialbuttons
),
urllib
.
urlencode
({
'
url
'
:
url
,
'
text
'
:
text
.
encode
(
'
utf-8
'
)
}))
# simple static views
def
home
(
request
):
user
=
get_user
(
request
)
...
...
@@ -318,14 +331,7 @@ def one_election_view(request, election):
status_update_message
=
u
"
Results are in for %s
"
%
election
.
name
# a URL for the social buttons
socialbuttons_url
=
None
if
status_update_message
:
socialbuttons_url
=
"
%s%s?%s
"
%
(
settings
.
SOCIALBUTTONS_URL_HOST
,
reverse
(
socialbuttons
),
urllib
.
urlencode
({
'
url
'
:
election_url
,
'
text
'
:
status_update_message
.
encode
(
'
utf-8
'
)
}))
socialbuttons_url
=
get_socialbuttons_url
(
election_url
,
status_update_message
)
trustees
=
Trustee
.
get_by_election
(
election
)
...
...
@@ -689,6 +695,7 @@ def one_election_cast_done(request, election):
if
voter
:
votes
=
CastVote
.
get_by_voter
(
voter
)
vote_hash
=
votes
[
0
].
vote_hash
cv_url
=
get_castvote_url
(
votes
[
0
])
# only log out if the setting says so *and* we're dealing
# with a site-wide voter. Definitely remove current_voter
...
...
@@ -699,8 +706,10 @@ def one_election_cast_done(request, election):
del
request
.
session
[
'
CURRENT_VOTER
'
]
save_in_session_across_logouts
(
request
,
'
last_vote_hash
'
,
vote_hash
)
save_in_session_across_logouts
(
request
,
'
last_vote_cv_url
'
,
cv_url
)
else
:
vote_hash
=
request
.
session
[
'
last_vote_hash
'
]
cv_url
=
request
.
session
[
'
last_vote_cv_url
'
]
logout
=
False
# local logout ensures that there's no more
...
...
@@ -710,9 +719,15 @@ def one_election_cast_done(request, election):
# if logout:
# auth_views.do_local_logout(request)
# tweet/fb your vote
socialbuttons_url
=
get_socialbuttons_url
(
cv_url
,
'
I cast a vote in %s
'
%
election
.
name
)
# remote logout is happening asynchronously in an iframe to be modular given the logout mechanism
# include_user is set to False if logout is happening
return
render_template
(
request
,
'
cast_done
'
,
{
'
election
'
:
election
,
'
vote_hash
'
:
vote_hash
,
'
logout
'
:
logout
},
include_user
=
(
not
logout
))
return
render_template
(
request
,
'
cast_done
'
,
{
'
election
'
:
election
,
'
vote_hash
'
:
vote_hash
,
'
logout
'
:
logout
,
'
socialbuttons_url
'
:
socialbuttons_url
},
include_user
=
(
not
logout
))
@election_view
()
@json
...
...
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