Created
January 10, 2011 01:33
-
-
Save adinardi/772226 to your computer and use it in GitHub Desktop.
This was the ballot generator I made for CSH when I was chairman.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
IDS = {} | |
def build_top(): | |
html = """ | |
<html> | |
<body> | |
<style> | |
body { | |
font-size: 10px; | |
} | |
</style> | |
""" | |
return html | |
def build_bottom(): | |
html = """ | |
</body> | |
</html> | |
""" | |
return html | |
def build_ballot(): | |
global IDS | |
html = """ | |
<div style="float: left; width: 180px; height: 165px; border: 2px solid black;"> | |
<div><u><b><center>CSH Official Ballot</center></b></u></div> | |
<div>Vote for 08-09 House Member of the Year.</div> | |
<div>VOTING MEMBERS MUST SUBMIT BALLOT BY TUESDAY, 9 PM.</div> | |
<br> | |
<div style="width: 170px"> | |
<div>___Chris Lockfort</div> | |
<div>___Alex Crawford</div> | |
<div>___Elliot Stern</div> | |
<div>___(other)_____________________</div> | |
</div> | |
<div><b><u>DUE: Tuesday, Apr 28 - 9:00PM</u></b></div> | |
Magic ID: """ | |
id = random.randint(1000000000, 1000000000000000) | |
while (IDS.has_key(id)): | |
print 'collide, regen' | |
id = random.randint(1000000000, 1000000000000000) | |
IDS[id] = 0 | |
htmlid = str(id) | |
html2 = """ | |
</div> | |
""" | |
return html + htmlid + html2 | |
def build_page(): | |
global IDS | |
html = build_top() | |
i = 0 | |
while i < 70: | |
html = html + build_ballot() | |
i = i + 1 | |
html = html + "<div style='clear: both; display: none'>" | |
for id in IDS: | |
html = html + str(id) + "\n" | |
html = html + "</div>" | |
html = html + build_bottom() | |
print html | |
return | |
build_page() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment