From 43fdd9f1d752c9b8b06d2350982da25080baf920 Mon Sep 17 00:00:00 2001
From: Ben Adida <ben@adida.net>
Date: Sun, 8 Aug 2010 16:14:55 -0700
Subject: [PATCH] updates to look and feel

---
 auth                           |  2 +-
 helios                         |  2 +-
 server_ui/media/main.css       | 15 +++++++++
 server_ui/templates/base.html  |  9 ++---
 server_ui/templates/index.html | 60 +++++++++++++++++++++++++---------
 server_ui/views.py             | 30 +++++++++++++++--
 6 files changed, 91 insertions(+), 27 deletions(-)

diff --git a/auth b/auth
index 7619266..809c803 160000
--- a/auth
+++ b/auth
@@ -1 +1 @@
-Subproject commit 76192665b69d0b10e68dee394a878964af199f46
+Subproject commit 809c803c91711f3cab3f3edd783400848ebeb27f
diff --git a/helios b/helios
index d02ada6..70c662f 160000
--- a/helios
+++ b/helios
@@ -1 +1 @@
-Subproject commit d02ada61409e2a02c934e8541d88646b4472fd9f
+Subproject commit 70c662f1d8ee1904798ef14ad2ba4bffc2a18692
diff --git a/server_ui/media/main.css b/server_ui/media/main.css
index 9882a51..799a43b 100644
--- a/server_ui/media/main.css
+++ b/server_ui/media/main.css
@@ -55,6 +55,13 @@ body {
   font-size: 16pt;
 }
 
+#mystuff {
+ float:right;
+ width: 250px;
+ border-left: 1px solid #888;
+ padding-left: 20px;
+}
+
 table.pretty {
     margin: 1em 1em 1em 2em;
     background: whitesmoke;
@@ -75,6 +82,14 @@ table.pretty th, td {
   border: 1px solid #888;
 }
 
+.highlight-box-margin {
+  background:#ccc;
+  padding: 10px;
+  color: black;
+  border: 1px solid #888;
+  margin-right: 300px;
+}
+
 .round {
 -moz-border-radius-bottomleft:5px;
 -moz-border-radius-bottomright:5px;
diff --git a/server_ui/templates/base.html b/server_ui/templates/base.html
index 690d807..bd94364 100644
--- a/server_ui/templates/base.html
+++ b/server_ui/templates/base.html
@@ -50,13 +50,8 @@
 {% endif %}
 </span>
 {% if user %}
-logged in as
-<img border="0" height="15" src="/static/auth/login-icons/{{user.user_type}}.png" alt="{{user.user_type}}" />
-{% if user.name %}
-{{user.name}}
-{% else %}
-{{user.user_id}}
-{% endif %}  [<a href="{% url auth.views.logout %}?return_url={{CURRENT_URL}}">logout</a>]<br />
+logged in as {{user.display_html_small|safe}}
+[<a href="{% url auth.views.logout %}?return_url={{CURRENT_URL}}">logout</a>]<br />
 {% else %}
 not logged in. [<a href="{% url auth.views.index %}?return_url={{CURRENT_URL}}">log in</a>]<br />
 {% endif %}
diff --git a/server_ui/templates/index.html b/server_ui/templates/index.html
index d24bf77..c1f7d04 100644
--- a/server_ui/templates/index.html
+++ b/server_ui/templates/index.html
@@ -7,32 +7,62 @@
 
 {% block content %}
 
-<p>
-    Welcome to the {{settings.SITE_TITLE}} system!
-</p>
+<div id="mystuff">
+{% if user %}
+<div style="font-size:1.4em;" class="highlight-box">
+{{user.display_html_big|safe}}
+</div>
+{% if create_p %}
+<h4>Administration</h4>
+{% if elections_administered %}
+<ul>
+{% for election in elections_administered %}
+<li> <a href="{% url helios.views.one_election_view election.uuid %}">{{election.name}}</a></li>
+{% endfor %}
+</ul>
+{% else %}
+<em>none yet</em><br />
+{% endif %}
+<div style="text-align:right">
+<button style="font-size:1.2em;"><a href="{% url helios.views.election_new %}">create election &gt;</a></button>
+</div>
+{% endif %}
 
-<p>
+<h4>Recent Votes</h4>
+{% if elections_voted %}
+<ul>
+{% for election in elections_voted %}
+<li><a href="{% url helios.views.one_election_view election.uuid %}">{{election.name}}</a></li>
+{% endfor %}
+</ul>
+{% else %}
+<em>none yet</em>
+{% endif %}
+{% else %}
+<h3>Log In to Start Voting</h3>
+{{login_box|safe}}
+{% endif %}
+<br /><br />
+</div>
+
+<p style="font-size: 1.4em;">
   {{settings.WELCOME_MESSAGE|safe}}
 </p>
 
-{% if create_p %}
-<a href="{% url helios.views.election_new %}">create election</a>
-|
-<a href="{% url helios.views.elections_administered %}">elections you administer</a>
-{% endif %}
-
 {% if elections|length %}
-<p style="font-size: 1.4em;">
-Current Featured Elections:
-<ul>
+<p>
 {% for election in elections %}
-  <li> <a href="{% url helios.views.election_shortcut election.short_name %}">{{election.name}}</a></li>
+<div class="highlight-box-margin">
+<a style="font-size: 1.4em;" href="{% url helios.views.election_shortcut election.short_name %}">{{election.name}}</a> by {{election.admin.display_html_small|safe}}<br />
+{{election.description}}
+</div>
+<br />
 {% endfor %}
-</ul>
 </p>
 {% else %}
 <h4>no featured elections at the moment</h4>
 {% endif %}
 
+<br clear="right" /><br />
 
 {% endblock %}
diff --git a/server_ui/views.py b/server_ui/views.py
index 9e5c610..ce3b1ce 100644
--- a/server_ui/views.py
+++ b/server_ui/views.py
@@ -17,6 +17,8 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404, HttpRespons
 
 from django.conf import settings
 
+import copy
+import auth.views as auth_views
 
 def get_election():
   return None
@@ -25,9 +27,31 @@ def home(request):
   # load the featured elections
   featured_elections = Election.get_featured()
   
+  user = get_user(request)
   create_p = can_create_election(request)
-  
-  return render_template(request, "index", {'elections': featured_elections, 'create_p':create_p})
+
+  if create_p:
+    elections_administered = Election.get_by_user_as_admin(user)
+  else:
+    elections_administered = None
+
+  if user:
+    elections_voted = Election.get_by_user_as_voter(user)
+  else:
+    elections_voted = None
+ 
+  auth_systems = copy.copy(settings.AUTH_ENABLED_AUTH_SYSTEMS)
+  try:
+    auth_systems.remove('password')
+  except: pass
+
+  login_box = auth_views.login_box_raw(request, return_url="/", auth_systems=auth_systems)
+
+  return render_template(request, "index", {'elections': featured_elections,
+                                            'elections_administered' : elections_administered,
+                                            'elections_voted' : elections_voted,
+                                            'create_p':create_p,
+                                            'login_box' : login_box})
   
 def about(request):
   return HttpResponse(request, "about")
@@ -105,4 +129,4 @@ def cast_done(request):
   past_votes = CastVote.get_by_election_and_voter(election, voter)
   
   return render_template(request, 'done', {'election': election, 'past_votes' : past_votes, 'voter': voter})
-  
\ No newline at end of file
+  
-- 
GitLab