From 280b566c6aa3892496a3e5eef7e671d3748f5769 Mon Sep 17 00:00:00 2001
From: Ben Adida <ben@BigDaddy.local>
Date: Fri, 4 Sep 2009 15:52:20 -0700
Subject: [PATCH] made things a lot more generic

---
 .gitignore                                    |   2 ++
 app.yaml => app.yaml.sample                   |   6 ++---
 settings.py => settings.py.sample             |  22 +++++++++++++---
 {iacr => single-election}/__init__.py         |   4 +--
 {iacr => single-election}/glue.py             |   0
 single-election/media/.gitignore              |   1 +
 .../media/boothcss/booth.css                  |   0
 .../media/boothcss/forms.css                  |   0
 .../media/logo.gif.sample                     | Bin
 {iacr => single-election}/media/main.css      |   0
 {iacr => single-election}/templates/base.html |   5 ++--
 .../templates/confirm.html                    |   4 +--
 {iacr => single-election}/templates/done.html |   2 +-
 .../templates/election_tallied.html           |   2 +-
 .../templates/index.html                      |  10 ++++----
 {iacr => single-election}/urls.py             |   0
 {iacr => single-election}/view_utils.py       |   4 +--
 {iacr => single-election}/views.py            |  24 +++++-------------
 urls.py                                       |   2 +-
 19 files changed, 46 insertions(+), 42 deletions(-)
 rename app.yaml => app.yaml.sample (85%)
 rename settings.py => settings.py.sample (88%)
 rename {iacr => single-election}/__init__.py (77%)
 rename {iacr => single-election}/glue.py (100%)
 create mode 100644 single-election/media/.gitignore
 rename {iacr => single-election}/media/boothcss/booth.css (100%)
 rename {iacr => single-election}/media/boothcss/forms.css (100%)
 rename iacr/media/iacrlogo.gif => single-election/media/logo.gif.sample (100%)
 rename {iacr => single-election}/media/main.css (100%)
 rename {iacr => single-election}/templates/base.html (86%)
 rename {iacr => single-election}/templates/confirm.html (81%)
 rename {iacr => single-election}/templates/done.html (88%)
 rename {iacr => single-election}/templates/election_tallied.html (87%)
 rename {iacr => single-election}/templates/index.html (71%)
 rename {iacr => single-election}/urls.py (100%)
 rename {iacr => single-election}/view_utils.py (82%)
 rename {iacr => single-election}/views.py (86%)

diff --git a/.gitignore b/.gitignore
index 1cfb0a5..4defc12 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+app.yaml
+settings.py
 *.pyc
 .DS_Store
 *~
\ No newline at end of file
diff --git a/app.yaml b/app.yaml.sample
similarity index 85%
rename from app.yaml
rename to app.yaml.sample
index 783f367..a162a36 100644
--- a/app.yaml
+++ b/app.yaml.sample
@@ -1,4 +1,4 @@
-application: iacr-helios
+application: XXX-helios
 version: 1
 runtime: python
 api_version: 1
@@ -19,13 +19,13 @@ handlers:
   secure: always
   
 - url: /static
-  static_dir: iacr/media
+  static_dir: single-election/media
   secure: always
 
 # this overrides the style for the booth
 # without having to fork the code
 - url: /booth/css
-  static_dir: iacr/media/boothcss
+  static_dir: single-election/media/boothcss
   secure: always
   
 - url: /booth
diff --git a/settings.py b/settings.py.sample
similarity index 88%
rename from settings.py
rename to settings.py.sample
index 14f1a1f..32b706f 100644
--- a/settings.py
+++ b/settings.py.sample
@@ -107,7 +107,7 @@ DEFAULT_FROM_EMAIL = 'Ben Adida for Helios <ben@adida.net>'
 SERVER_EMAIL = DEFAULT_FROM_EMAIL
 
 # Make this unique, and don't share it with anybody.
-SECRET_KEY = 'iacrrulez!!!ohyeah,andheliostoo'
+SECRET_KEY = 'votingrulez!!!ohyeah,andheliostoo'
 
 LOGIN_URL = '/auth/'
 #LOGOUT_URL = '/account/logout/'
@@ -117,7 +117,7 @@ INSTALLED_APPS = (
     'appengine_django',
     'auth',
     'helios',
-    'iacr',
+    'single-election',
 )
 
 
@@ -125,6 +125,20 @@ APPEND_SLASH = False
 DEBUG = True
 TEMPLATE_DEBUG = True
 
-URL_HOST = "https://iacr-helios.appspot.com"
+URL_HOST = "https://FILL-ME-IN-helios.appspot.com"
+
+# election stuff
+SINGLE_ELECTION_UUID = 'FILL-ME-IN'
+SINGLE_ELECTION_SHORT_NAME = 'FILL-ME-IN'
+
+SINGLE_ELECTION_PARAMS = {
+  'short_name' : SINGLE_ELECTION_SHORT_NAME,
+  'name' : 'IACR 2009 Election',
+  'description' : 'Election for the IACR Board - 2009',
+  'uuid' : 'iacr',
+  'openreg': False,
+  'tally_type': 'homomorphic',
+  'ballot_type': 'homomorphic',
+  'use_voter_aliases': True
+}
 
-IACR_ELECTION_UUID = 'iacr'
\ No newline at end of file
diff --git a/iacr/__init__.py b/single-election/__init__.py
similarity index 77%
rename from iacr/__init__.py
rename to single-election/__init__.py
index 38485c0..248656b 100644
--- a/iacr/__init__.py
+++ b/single-election/__init__.py
@@ -1,5 +1,5 @@
 """
-This django app is meant only to connect the pieces of Helios and Auth that are specific to IACR
+This django app is meant only to connect the pieces of Helios and Auth that are specific to single election
 """
 
 import glue
@@ -8,7 +8,7 @@ import helios
 import auth
 import auth.models
 
-helios.TEMPLATE_BASE = "iacr/templates/base.html"
+helios.TEMPLATE_BASE = "single-election/templates/base.html"
 helios.ADMIN_ONLY = True
 helios.ADMIN = auth.models.User.get_or_create(user_type = 'password', user_id = 'benadida', info={'password':'test'})
 
diff --git a/iacr/glue.py b/single-election/glue.py
similarity index 100%
rename from iacr/glue.py
rename to single-election/glue.py
diff --git a/single-election/media/.gitignore b/single-election/media/.gitignore
new file mode 100644
index 0000000..94a1201
--- /dev/null
+++ b/single-election/media/.gitignore
@@ -0,0 +1 @@
+logo.gif
\ No newline at end of file
diff --git a/iacr/media/boothcss/booth.css b/single-election/media/boothcss/booth.css
similarity index 100%
rename from iacr/media/boothcss/booth.css
rename to single-election/media/boothcss/booth.css
diff --git a/iacr/media/boothcss/forms.css b/single-election/media/boothcss/forms.css
similarity index 100%
rename from iacr/media/boothcss/forms.css
rename to single-election/media/boothcss/forms.css
diff --git a/iacr/media/iacrlogo.gif b/single-election/media/logo.gif.sample
similarity index 100%
rename from iacr/media/iacrlogo.gif
rename to single-election/media/logo.gif.sample
diff --git a/iacr/media/main.css b/single-election/media/main.css
similarity index 100%
rename from iacr/media/main.css
rename to single-election/media/main.css
diff --git a/iacr/templates/base.html b/single-election/templates/base.html
similarity index 86%
rename from iacr/templates/base.html
rename to single-election/templates/base.html
index 0359d5b..141513c 100644
--- a/iacr/templates/base.html
+++ b/single-election/templates/base.html
@@ -7,7 +7,7 @@
     xml:lang="{% firstof LANGUAGE_CODE 'en' %}"
     lang="{% firstof LANGUAGE_CODE 'en' %}">
   <head>
-    <title>{% block title %}{% endblock %} - IACR Helios</title>
+    <title>{% block title %}{% endblock %} - Helios</title>
     {% block css %}
       <!--
           <link rel="stylesheet" type="text/css"  media="screen, projection" href="{{ MEDIA_URL }}combined-{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}.css" />
@@ -30,7 +30,7 @@
   <body>
     <div id="content">
         <div id="header">
-            <img src="/static/iacrlogo.gif" /><br />
+            <img src="/static/logo.gif" /><br />
         {% block header %}
         {% endblock %}
         </div>
@@ -43,7 +43,6 @@
               {% block content %}{% endblock %}
       <div id="footer">
         <br /><br />
-          <em>This web site is not endorsed by the IACR. It is only meant for demonstration purposes.</em>
       </div>
     </div>
     
diff --git a/iacr/templates/confirm.html b/single-election/templates/confirm.html
similarity index 81%
rename from iacr/templates/confirm.html
rename to single-election/templates/confirm.html
index 17a854f..f453da6 100644
--- a/iacr/templates/confirm.html
+++ b/single-election/templates/confirm.html
@@ -1,4 +1,4 @@
-{% extends 'iacr/templates/base.html' %}
+{% extends 'single-election/templates/base.html' %}
 {% block title %}Confirm Vote{% endblock %}
 
 {% block content %}
@@ -38,7 +38,7 @@ function show_waiting() {
 </form>
 
 <p>
-    Forgot your password? <a href="{% url auth.auth_systems.password.password_forgotten_view %}?return_url={% url iacr.views.cast_confirm %}">Have it emailed to you</a>.<br />(don't worry, we won't forget your vote).
+    Forgot your password? <a href="{% url auth.auth_systems.password.password_forgotten_view %}?return_url={% url single-election.views.cast_confirm %}">Have it emailed to you</a>.<br />(don't worry, we won't forget your vote).
 </p>
 </div>
 
diff --git a/iacr/templates/done.html b/single-election/templates/done.html
similarity index 88%
rename from iacr/templates/done.html
rename to single-election/templates/done.html
index b9a0a4c..0447034 100644
--- a/iacr/templates/done.html
+++ b/single-election/templates/done.html
@@ -1,4 +1,4 @@
-{% extends 'iacr/templates/base.html' %}
+{% extends 'single-election/templates/base.html' %}
 {% block title %}Confirm Vote{% endblock %}
 
 {% block content %}
diff --git a/iacr/templates/election_tallied.html b/single-election/templates/election_tallied.html
similarity index 87%
rename from iacr/templates/election_tallied.html
rename to single-election/templates/election_tallied.html
index ab92e3a..7b536c5 100644
--- a/iacr/templates/election_tallied.html
+++ b/single-election/templates/election_tallied.html
@@ -1,4 +1,4 @@
-{% extends 'iacr/templates/base.html' %}
+{% extends 'single-election/templates/base.html' %}
 
 {% block content %}
 
diff --git a/iacr/templates/index.html b/single-election/templates/index.html
similarity index 71%
rename from iacr/templates/index.html
rename to single-election/templates/index.html
index b7420c2..4a8e0cb 100644
--- a/iacr/templates/index.html
+++ b/single-election/templates/index.html
@@ -1,14 +1,14 @@
-{% extends 'iacr/templates/base.html' %}
-{% block title %}IACR Helios{% endblock %}
+{% extends 'single-election/templates/base.html' %}
+{% block title %}Single Election Helios{% endblock %}
 
 {% block header %}
-<h2>IACR Election</h2>
+<h2>Single Election</h2>
 {% endblock %}
 
 {% block content %}
 
 <p>
-    Welcome the IACR 2009 Board Election.
+    Welcome to the SINGLE HELIOS ELECTION Server.
 </p>
 
 <p>
@@ -25,7 +25,7 @@
 
 <p style="font-size: 1.4em;">
     Proceed to
-<a href="{% url helios.views.one_election_view settings.IACR_ELECTION_UUID %}">the IACR election</a>.
+<a href="{% url helios.views.one_election_view settings.SINGLE_ELECTION_UUID %}">the SINGLE HELIOS ELECTION</a>.
 </p>
 
 {% endblock %}
diff --git a/iacr/urls.py b/single-election/urls.py
similarity index 100%
rename from iacr/urls.py
rename to single-election/urls.py
diff --git a/iacr/view_utils.py b/single-election/view_utils.py
similarity index 82%
rename from iacr/view_utils.py
rename to single-election/view_utils.py
index 5d53ca2..98eec83 100644
--- a/iacr/view_utils.py
+++ b/single-election/view_utils.py
@@ -1,5 +1,5 @@
 """
-Utilities for iacr views
+Utilities for single election views
 
 Ben Adida (2009-07-18)
 """
@@ -26,5 +26,5 @@ def render_template(request, template_name, vars = {}):
   if request.session.has_key('csrf_token'):
     vars_with_user['csrf_token'] = request.session['csrf_token']
   
-  return render_to_response('iacr/templates/%s.html' % template_name, vars_with_user)
+  return render_to_response('single-election/templates/%s.html' % template_name, vars_with_user)
   
diff --git a/iacr/views.py b/single-election/views.py
similarity index 86%
rename from iacr/views.py
rename to single-election/views.py
index cbb5dbc..20a5847 100644
--- a/iacr/views.py
+++ b/single-election/views.py
@@ -1,5 +1,5 @@
 """
-IACR specific views
+single-election specific views
 """
 
 from helios.models import *
@@ -17,27 +17,15 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404, HttpRespons
 from django.conf import settings
 
 
-ELECTION_SHORT_NAME = 'iacr09'
-
-
 def get_election():
-  return Election.get_by_key_name(ELECTION_SHORT_NAME)
+  return Election.get_by_key_name(settings.SINGLE_ELECTION_SHORT_NAME)
   
 def home(request):
-  # create the election if need be
-  election_params = {
-    'short_name' : ELECTION_SHORT_NAME,
-    'name' : 'IACR 2009 Election',
-    'description' : 'Election for the IACR Board - 2009',
-    'uuid' : 'iacr',
-    'cast_url' : settings.URL_HOST + reverse(cast),
-    'openreg': False,
-    'admin' : helios.ADMIN,
-    'tally_type': 'homomorphic',
-    'ballot_type': 'homomorphic',
-    'use_voter_aliases': True
-  }
+  election_params = settings.SINGLE_ELECTION_PARAMS
+  election_params['cast_url'] = settings.URL_HOST + reverse(cast)
+  election_params['admin'] = helios.ADMIN
   
+  # create the election if need be
   election, created_p = Election.get_or_create(**election_params)
   
   return render_template(request, "index")
diff --git a/urls.py b/urls.py
index 564c2f8..60e123f 100644
--- a/urls.py
+++ b/urls.py
@@ -5,5 +5,5 @@ from django.contrib import admin
 urlpatterns = patterns('',
     (r'^auth/', include('auth.urls')),
     (r'^helios/', include('helios.urls')),
-    (r'^', include('iacr.urls')),
+    (r'^', include('single-election.urls')),
 )
\ No newline at end of file
-- 
GitLab