include AuthenticatedSystem
helper :user
require_dependency "user"
-
+ before_filter :add_stylesheets
+
+ def initialize
+ @stylesheets = []
+ end
+
+ def add_stylesheets
+ file = "#{Dir.pwd}/public/stylesheets/#{controller_name}.css"
+ if File.exists? file
+ @stylesheets << controller_name
+ end
+ end
+
end
end
def general_information
+ @sidebar_content = render_to_string :partial => 'progress',
+ :locals => { :page => 'overview' }
@election = Election.new
render :action => 'general_information'
end
# information for elections
####################################################################
def edit_candidates
+ @sidebar_content = render_to_string :partial => 'progress',
+ :locals => { :page => 'candidates' }
@election = Election.find( params[:id] )
end
def create
if params[:quickvote]
@quickvote = QuickVote.new(params[:quickvote])
+
+ # check to see if any of the advanced options have been changed
+ new_qv = QuickVote.new
+ if @quickvote.election_method != new_qv.election_method \
+ or @quickvote.enddate.day != new_qv.enddate.day \
+ or @quickvote.viewable != new_qv.viewable \
+ or @quickvote.notices != new_qv.notices
+ show_advanced = true
+ end
+ end
+
+ show_advanced ||= false
+
+ # render the sidebar
+ @sidebar_content = render_to_string(:partial => 'create_sidebar',
+ :locals => {:show_advanced => show_advanced})
+
+ if params[:quickvote]
+
# store the candidate grabbed through ajax and stored in flash
@quickvote.candidate_names = flash[:candidate_names]
@quickvote.description=@quickvote.description
+
#record who created the quickvote so that person can monitor it easily
@quickvote.quickuser = session.session_id
+
#Give registered users additional QuickVote functionality
@quickvote.user_id = session[:user][:id] if session[:user]
+
# try to save, if it fails, show the page again (the flash should
# still be intact
if @quickvote.save
@quickvote = @quickvote.reload
+ # blank sidebar and show the success page
+ @sidebar_content = ''
render :action => 'success'
else
flash.keep(:candidate_names)
flash.delete(:candidate_names) if flash.has_key?(:candidate_names)
@quickvote = QuickVote.new
end
+
end
def add_candidate
['candidates', 'Candidates'],
['voters', 'Voters'],
['review', 'Review'] ] %>
+<h2>Progress</h2>
<div id="election_creation_progress_bar">
<ul>
<% progress_steps.each_with_index do |kv, i| -%>
<% step, description = kv -%>
- <li class="<%= step == progress ? 'step_selected' : 'step_unselected' -%>
+ <li class="<%= step == page ? 'step_selected' : 'step_unselected' -%>
<%= " last" if i + 1 == progress_steps.length -%>
">Step <%= i + 1 %>: <%= description %></li>
<% end -%>
-<% %>
-
<% if @election.voters.length == 0 %>
+
<p>There are currently no voters registered for this election.</p>
+
<% else %>
+
<p>The following voters are currently registered for this election:</p>
<ul>
- <% @election.voters.each do |voter| %>
+<% @election.voters.each do |voter| %>
<div id="voter<%= voter.id %>">
<li><%= voter.email %>
<% if @edit %>
-<%= render_partial 'progress', 'candidates' %>
-<h1>Edit/Add Candidates</h1>
+<h2>Edit/Add Candidates</h2>
<%= error_messages_for :candidate %>
-<%= render_partial 'progress', 'overview' %>
-
-<h1>Create A New Vote</h1>
-
<h2>Vote Overview</h2>
<% form_tag (:action => 'create_election') do %>
-<%= render_partial 'progress', 'voters' %>
<% @edit = true %>
<h1><strong><%= @election.name %>:</strong> Enter List of Voter Email Addresses</h1>
<div id="footer">
- <a href="http://code.selectricity.org/">Copyleft</a> 2006, 2007 ||
+ <a href="http://code.selectricity.org/">Copyleft 2006, 2007</a> ||
<a href="http://www.media.mit.edu">MIT Media Lab</a>
</div>
<title><%= @page_title || "Selectricity" %></title>
<%= stylesheet_link_tag "common", :media => "all" %>
<%= stylesheet_link_tag "main", :media => "all" %>
+ <%= stylesheet_link_tag *(@stylesheets) %>
<%= javascript_include_tag "prototype", "effects", "dragdrop", "controls" %>
</head>
:controller => 'site', :action => 'index' %>
<div id="left-side-content">
+ <% if flash[:notice]%>
+ <div id="notice"><%= flash[:notice] %></div>
+ <% end%>
+
<%= @sidebar_content %>
</div>
</div> <!-- end of top-bar -->
<div id="main-box">
- <% if flash[:notice]%>
- <div id="notice"><%= flash[:notice] %></div>
- <% end%>
<%= @content_for_layout %>
</div>
+++ /dev/null
-<% fields_for 'quickvote', quickvote do |quickform| %>
-
-<p><label for="quickvote_election_method">Election Method</label></p>
-
-<p><%= quickform.select('election_method',
- %w(ssd condorcet plurality approval borda) ) %></p>
-
-<p><label for="quickvote_enddate">End Time</label></p>
-<p><%= quickform.date_select(:enddate, :start_year => Time.now.year) %></p>
-
-<p>Visibility</p>
-
-<p>Do you want the results to be visible while the election is active?</p>
-
-<p>Yes <%= quickform.radio_button(:viewable, 1)%>
-No <%= quickform.radio_button(:viewable, 0)%></p>
-
-<% if session[:user] %>
-<p>Notification</p>
-
-<p>Would you like to be e-mailed when this QuickVote concludes?</p>
-
-<p>Yes <%= quickform.radio_button(:notices, 1)%>
-No <%= quickform.radio_button(:notices, 0)%></p>
-<% end -%>
-
-<% end %>
--- /dev/null
+<%= error_messages_for 'quickvote' %>
+
+<script type="text/javascript">
+function show_advanced() {
+ Element.toggle($("advanced"));
+ Element.toggle($("advanced_toggle"));
+}
+<%= "Event.observe(window, 'load', show_advanced, false);" if show_advanced %>
+</script>
+
+<p id="advanced_toggle"><a href="#" onClick='show_advanced(); false;'>Show advanced options</a></p>
+
-<div id="voters-title">
- <span class="header">Title</span>
- <span class="subheader">Subtitle</span>
- <div style="clear:both;"></div>
-</div>
-
-<div id="controlroom-title">
- <span class="header">Title</span>
- <span class="subheader">Subtitle</span>
- <div style="clear:both;"></div>
-</div>
-
-<div id="quickvote-title">
+<div id="page-title">
<span class="header">Quickvote</span>
- <span class="subheader"></span>
+ <span class="subheader">Create New QuickVote</span>
<div style="clear:both;"></div>
</div>
-<%= error_messages_for 'quickvote' %>
-
-<span class="header">Header</span>
-<span class="subheader">Subheader</span>
-<div style="clear:both;"></div>
-
-<span class="header">Header</span>
-<span class="subheader"></span>
-<div style="clear:both;"></div>
-
-<span class="header">Header</span>
-<div style="clear:both;"></div>
+<div class="main-content">
<p><label for="quickvote_candidate_names">Choices</p>
<% form_tag(:action => 'create') do %>
<!--[form:election]-->
-
<p><label for="quickvote_name">One Word Description (for URL)</label></p>
-<p><em><font size="-1">required; 5-12 characters; only letters and numbers; no spaces</font></em></p>
+<p>required; 5-12 characters; only letters and numbers; no spaces</p>
<p><%= text_field 'quickvote', 'name', :size => 15, :maxsize => 12 %></p>
<p><label for="quickvote_description">Description</label></p>
-<p><font size="-1">required; one line summary on the first line</font></em><br/>
-
-<%= text_area 'quickvote', 'description', :cols => 50, :rows => 4 %></p>
+<p><font size="-1">required; free-form</font></em><br/>
-<%= check_box('options', 'advanced',
- :onclick => 'Element.toggle($("advanced")); false;' )%>Advanced
+<%= text_field 'quickvote', 'description', :size => 50 %></p>
<div id="advanced" style="display: none">
-<%= render :partial => 'advanced', :locals => {:quickvote => @quickvote} %>
-</div>
-<br />
+ <div class="plain-header">
+ <span class="header">Advanced Options</span>
+ <span class="subheader"></span>
+ </div>
+ <div class="clear-div"></div>
-<p><%= submit_tag "Create Quickvote" -%></p>
+ <% fields_for 'quickvote', @quickvote do |quickform| %>
-<% end %>
+ <p><label for="quickvote_election_method">Election Method</label></p>
+
+ <p><%= quickform.select('election_method',
+ %w(ssd condorcet plurality approval borda) ) %></p>
+
+ <p><label for="quickvote_enddate">End Time</label></p>
+ <p><%= quickform.date_select(:enddate, :start_year => Time.now.year) %></p>
+
+ <p><label for="quickvote_visibility">Visibility</label></p>
+
+ <p>Do you want the results to be visible while the election is active?</p>
+
+ <p>Yes <%= quickform.radio_button(:viewable, 1)%>
+ No <%= quickform.radio_button(:viewable, 0)%></p>
+
+ <% if session[:user] %>
+ <p>Notification</p>
+ <p>Would you like to be e-mailed when this QuickVote concludes?</p>
+ <p>Yes <%= quickform.radio_button(:notices, 1)%>
+ No <%= quickform.radio_button(:notices, 0)%></p>
+ <% end -%>
+ <% end %>
+</div>
+<br />
+
+<p><%= submit_tag "Create Quickvote" -%></p>
+<% end %>
+
+</div>
-<% %>
-
-<% if @voter.election.shortdesc %>
- <h1><%=h @voter.election.shortdesc %></h1>
-<% else %>
- <h1>QuickVote</h1>
-<% end %>
-
-<% if @voter.election.longdesc %>
- <p><strong>Description:</strong></p>
- <blockquote><%=h @voter.election.longdesc %></blockquote>
+<div id="page-title">
+ <span class="header">Quickvote</span>
+ <span class="subheader"><%=h @voter.election.description.capitalize %></span>
+</div>
-<h2>Vote</h2>
-<% end %>
+<div class="main-content">
<% if @voter.voted? %>
+
<p>You have already voted. You can:</p>
<ul>
</ol>
</div>
-<div class="clearbox"></div>
+<div class="clear-div"></div>
<%= button_to "Confirm Vote", quickaction_url( :action => 'confirm', :ident => @voter.election.name) %>
:complete => visual_effect(:highlight, 'rankings-list') %>
<% end %>
+</div> <!-- end main-content -->
-<% %>
-<%require 'whois/whois' %>
-<h1>Results</h1>
+<% require 'whois/whois' %>
+
+<div id="page-title">
+ <span class="header">Quickvote</span>
+ <span class="subheader">Results</span>
+</div>
+
+<div class="main-content">
<% if @election.shortdesc %>
- <p><strong>Description:</strong></p>
+ <p><strong>Vote Description:</strong></p>
<blockquote><em><%=h @election.shortdesc %></em>
<% if @election.longdesc -%>
<br />
<%= @election.voters.reject {|v| not v.voted? }.length %> (see below for details)
</blockquote>
-<h2>Winners</h2>
+<div class="plain-header">
+ <span class="header">Winner</span>
+ <span class="subheader"></span>
+</div>
<div class="mainresultbox">
<%= render :partial => 'result_' + @election.election_method,
:object => @results[@election.election_method] %>
</div>
-<h3> Other Voting Methods </h3>
+<div class="plain-header">
+ <span class="header">Other Voting Methods</span>
+ <span class="subheader"></span>
+</div>
+
<% for result_type in @election.other_methods %>
<div class="resultbox">
<%= render :partial => 'result_' + result_type,
<% end %>
-<div class="clearbox"></div>
+<div class="clear-div"></div>
<h2>Voters <%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %></h2>
<table class="voterbox">
<%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %><br />
+</div>
-<% -%>
-<h2>QuickVote Created</h2>
+<div id="page-title">
+ <span class="header">Quickvote</span>
+ <span class="subheader">New QuickVote Created</span>
+ <div style="clear:both;"></div>
+</div>
+
+<div class="main-content">
<p>Please direct voters to:</p>
participate in this election.</p>
<p><%= link_to "Jump to QuickVote", quickvote_url( :ident => @quickvote.name ) %></p>
+</div>
-<% %>
-<h1>Vote Recorded</h1>
+<div id="page-title">
+ <span class="header">Quickvote</span>
+ <span class="subheader">Vote Recorded Successfully</span>
+</div>
+
+<div class="main-content">
+
<p>Your vote has been recorded with the following ranked
preferences:</p>
<li><%= link_to "View Current Results", quickaction_url( :ident => @voter.election.name, :action => 'results' ) %></li>
</ul>
-
-
-
-
+</div>
vertical-align: baseline;
}
-
-#body {
- font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
- font-size: 12px;
- text-align: left;
- line-height: 1.5em;
-}
-
-#body a {
- text-decoration: underline;
- color: inherit;
- display: inline;
- opacity: 0.8;
-}
-
-#body a:hover {
- opacity: .5;
-}
-
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: separate;
#footer a {
text-decoration: none;
- color: #dc0d13;
}
#footer a:hover {
text-decoration: underline;
}
+
+/* flash notices */
+
+#notice {
+ background: #FFFBB3;
+ border: 1px black solid;
+ text-align: center;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ width: 250px;
+}
+
+#notice {
+ background: #FFFBB3;
+ border: 1px black solid;
+ text-align: center;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ width: 250px;
+}
--- /dev/null
+a {
+ color: #dc0d13;
+}
+
+#page-title .header {
+ background-color: #dc0d13;
+}
+
+#page-title .subheader {
+ color: #dc0d13;
+ background-color: #e5e5e5;
+}
+
body {
line-height: 1;
- color: white;
+ color: black;
background: #ffffff url(/images/bg_index.png) repeat-x top center;
}
+a {
+ color: #dc0d13
+}
+
+#body {
+ font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+ color: white;
+ font-size: 12px;
+ text-align: left;
+ line-height: 1.5em;
+}
+
+#body a {
+ text-decoration: underline;
+ color: inherit;
+ display: inline;
+ opacity: 0.8;
+}
+
+#body a:hover {
+ opacity: .5;
+}
+
/* Header */
#header h1 {
background: url(/images/title_front.png) center top no-repeat;
@charset "utf-8";
+
/* CSS Document */
/****************************************************************
pading: 0 1em 0 1em;
}
+label {
+ font-weight: bold;
+}
+
/* Left column. Includes logo, poll information, and graph. */
overflow: hidden;
}
-#quickvote-title .header {
- background-color: #74ce00;
-}
-
-#quickvote-title .subheader {
- color: #74ce00;
- background-color: #e5e5e5;
-}
-
-#controlroom-title .header {
- background-color: #dc0d13;
-}
-
-#controlroom-title .subheader {
- color: #dc0d13;
- background-color: #e5e5e5;
-}
-
-#voters-title .header {
- background-color: #005cd9;
-}
-
-#voters-title .subheader {
- color: #005cd9;
- background-color: #e5e5e5;
+.plain-header {
+ margin: 1em -1.2em 1em -1.2em;
}
.header {
display: block;
font-family: "trebuchet ms",trebuchet,verdana,arial,sans-serif;
- font-size:30px;
+ font-size: 30px;
text-transform: uppercase;
text-align: center;
color: white;
border: 1px solid #b3b3b3;
}
-#main-box h1 {
-
+.main-content {
+ margin: 1.2em;
+ line-height: 1.5em;
+ text-color: #454545;
}
-#main-box p {
- margin-bottom: 1.75em;
- padding: 0 1.7em 0 1.7em;
- line-height: 1.8em;
- color: #454545;
+.main-content p, .main-content blockquote, .main-content ul {
+ margin-bottom: 1em;
}
+blockquote {
+ margin-left: 3em;
+}
-#ErrorExplanation {
- width: 400px;
- border: 2px solid 'red';
- padding: 7px;
- padding-bottom: 12px;
+
+/* css related to error in forms */
+
+#errorExplanation {
+ border: 2px solid #C00;
+ width: 260px;
margin-bottom: 20px;
background-color: #f0f0f0;
}
-#ErrorExplanation h2 {
+#errorExplanation h2 {
+ font-size: 1em !important;
text-align: left;
font-weight: bold;
- padding: 5px 5px 5px 15px;
- font-size: 12px;
- margin: -7px;
+ padding: 5px 5px 5px 5px;
background-color: #c00;
color: #fff;
}
-#ErrorExplanation p {
+#errorExplanation p {
+ font-size: 1em;
color: #333;
margin-bottom: 0;
padding: 5px;
}
-#ErrorExplanation ul li {
- font-size: 12px;
+#errorExplanation ul li {
+ font-size: 1em;
list-style: square;
}
-.ListLine0 {
- background: #e0f8f8;
-
+.fieldWithErrors {
+ display: inline;
}
-.ListLine1 {
- background: #cccccc;
-
+.fieldWithErrors input, .fieldWithErrors select, .fieldWithErrors textarea {
+ background-color: #FFFBB3;
}
-#notice { background: #FFFBB3;
- text-align: left;
- font-weight: bold;
- border: 2px dotted 'red';
- margin-top: 10px;
- margin-left: 50px;
- padding: 5px 5px 5px 15px;
- width: 400px; }
-
#status {
width: 400px;
border: 1px solid #0000FF;
background-color: #f0f0f0;
}
-.fieldWithErrors {
- display: inline;
-}
-.fieldWithErrors input, .fieldWithErrors select {
- background-color: #ffdfdf;
-}
-
-#xxErrorExplanation h2 {
- text-align: left;
- font-weight: bold;
- padding: 5px 5px 5px 15px;
- font-size: 12px;
- margin: -7px;
- background-color: #c00;
- color: #fff;
-}
-
-#xxErrorExplanation p {
- color: #333;
- margin-bottom: 0;
- padding: 5px;
-}
-
-#xxErrorExplanation ul li {
- font-size: 12px;
- list-style: square;
-}
-
-.mainresultbox {
- text-align: center;
- width: 850px;
- border-width: 2px;
- border-style: solid;
- border-color: #4D801A;
- padding: 7px;
- margin-right: 30px;
- margin-bottom: 30px;
-}
-
-.mainresultbox h3 {
- text-align: center;
- font-weight: bold;
- padding: 5px 5px 5px 15px;
- margin: -7px;
- background-color: #73BF26;
- color: #fff;
- border-bottom: 0px;
-}
-
-.resultbox {
- text-align: center;
- width: 400px;
- float: left;
- border-width: 2px;
- border-style: solid;
- border-color: #4D801A;
- padding: 7px;
- margin-right: 30px;
- margin-bottom: 30px;
-}
-
-.resultbox h3 {
- text-align: center;
- font-weight: bold;
- padding: 5px 5px 5px 15px;
- margin: -7px;
- background-color: #73BF26;
- color: #fff;
- border-bottom: 0px;
-}
-.clearbox {
- clear: both;
- margin: 30px;
-}
-
li.moveable {
background-color: #E5FFCC;
border:1px solid #4D801A;
}
#election_creation_progress_bar ul li {
- display: inline;
+ display: block;
list-style: default;
}
-#election_creation_progress_bar ul li:after {
- font-weight: normal;
- color: #000;
- content: " || ";
-}
-
-#election_creation_progress_bar ul li.last:after {
- content: "";
-}
-
#election_creation_progress_bar li.step_selected {
font-weight: bold;
}
font-weight: bold;
}
-/*
-#plurality h4 {
- background: url(/images/voting_plurality.png);
- width: 217px;
-}
-
-#schulze h4 {
- background: url(/images/voting_schulze_quickvote.png);
- width: 183px;
-}
-
-#approval h4 {
- background: url(/images/voting_approval.png);
- width: 208px;
-}
-
-#borda h4 {
- background: url(/images/voting_borda.png);
- width: 147px;
-}
-
-#condorcet h4 {
- background: url(/images/voting_condorcet.png);
- width: 240px;
-}
-
-#irv h4 {
- background: url(/images/voting_irv.png);
- width: 86px;
-}
-*/
--- /dev/null
+a {
+ color: #569a00;
+}
+
+#page-title .header {
+ background-color: #74ce00;
+}
+
+#page-title .subheader {
+ color: #74ce00;
+ background-color: #e5e5e5;
+}
--- /dev/null
+a {
+ color: #005cd9;
+}
+
+#page-title .header {
+ background-color: #005cd9;
+}
+
+#page-title .subheader {
+ color: #005cd9;
+ background-color: #e5e5e5;
+}
-Tue Aug 28 13:24:45 -0400 2007
+Wed Aug 29 13:54:03 -0400 2007