diff --git a/auth b/auth index 76192665b69d0b10e68dee394a878964af199f46..809c803c91711f3cab3f3edd783400848ebeb27f 160000 --- a/auth +++ b/auth @@ -1 +1 @@ -Subproject commit 76192665b69d0b10e68dee394a878964af199f46 +Subproject commit 809c803c91711f3cab3f3edd783400848ebeb27f diff --git a/helios b/helios index d02ada61409e2a02c934e8541d88646b4472fd9f..70c662f1d8ee1904798ef14ad2ba4bffc2a18692 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 9882a51c08fb45375d9f41b1baa72dced05303da..799a43bdb03b139343cb7f510641695670beb3b8 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 690d807266ec9a22a00fc2ea472f7697b7cf7590..bd94364c8fce60becb67e2b1b67a59dabc33a74a 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 d24bf7753b30df930b4c51b9d0a187afd5180a9f..c1f7d0459153244ea222a8cf3e499f1b69d38d16 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 ></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 9e5c61063b3156b0a43e95462aef14abf7dbab0a..ce3b1ceb1253ed8ae47970133bd38986f16f7b64 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 +