From: Benjamin Mako Hill Date: Sun, 17 Jun 2012 22:59:36 +0000 (-0400) Subject: Merge branch 'live' of ssh://ephesus.xvm.mit.edu/org/selectricity/selectricity-live X-Git-Url: https://projects.mako.cc/source/selectricity-live/commitdiff_plain/005f5a86085c9cbcbc09c6655f3851a877462638?hp=d799e41626ef94ab28a3b5517dd2ed7d1e6b1001 Merge branch 'live' of ssh://ephesus.xvm.mit.edu/org/selectricity/selectricity-live Conflicts: README app/controllers/voter_controller.rb app/views/layouts/_footer.rhtml --- diff --git a/COPYING b/COPYING index 939a6f4..dba13ed 100644 --- a/COPYING +++ b/COPYING @@ -7,15 +7,15 @@ Preamble - The GNU Affero General Public License is a free, copyleft license -for software and other kinds of works, specifically designed to ensure + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. - The licenses for most software and other practical works are -designed to take away your freedom to share and change the works. By -contrast, our General Public Licenses are intended to guarantee your -freedom to share and change all versions of a program--to make sure it -remains free software for all its users. + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you @@ -60,12 +60,11 @@ modification follow. 0. Definitions. - "This License" refers to version 3 of the GNU Affero General Public -License. + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. - "Copyright" also means copyright-like laws that apply to other kinds -of works, such as semiconductor masks. - "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. @@ -377,12 +376,12 @@ that material) supplement the terms of this License with terms: All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further restriction, -you may remove that term. If a license document contains a further -restriction but permits relicensing or conveying under this License, you -may add to a covered work material governed by the terms of that license -document, provided that the further restriction does not survive such -relicensing or conveying. +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the @@ -551,34 +550,34 @@ shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. - Notwithstanding any other provision of this License, you have permission -to link or combine any covered work with a work licensed under version 3 -of the GNU General Public License into a single combined work, and to -convey the resulting work. The terms of this License will continue to -apply to the part which is the covered work, but the work with which it is -combined will remain governed by version 3 of the GNU General Public -License. + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may differ -in detail to address new problems or concerns. +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero -General Public License "or any later version" applies to it, you have -the option of following the terms and conditions either of that -numbered version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number -of the GNU Affero General Public License, you may choose any version -ever published by the Free Software Foundation. +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that -proxy's public statement of acceptance of a version permanently -authorizes you to choose that version for the Program. +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any @@ -617,9 +616,9 @@ an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS - How to Apply These Terms to Your New Programs + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -634,9 +633,9 @@ the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/README b/README index 9ec9d62..5ce586b 100644 --- a/README +++ b/README @@ -8,12 +8,26 @@ distribute, or rework Selectricity under the terms of that license. Of course, we'd sure like it if you would send fixes back to us and tell us about cool stuff you do with our software! -The best way to get Selectricity is just to download it from our source -tree. At the moment, we're hosting our code at Gitorious which is a -free software hosting provider. You can download Gitorious at the -project page by following detailed instructions at Gitorious: +The best way to get Selectricity is just to download it from our +source repository. You'll need the Git version control system or +source control manager to check it. You can get it here: - http://gitorious.org/selectricity + http://git-scm.com/ + +Once you have it, getting the source code is pretty easy. You just need +to check out a branch with a command like this: + + git clone http://projects.mako.cc/source/selectricity/.git + +By default, this will create a working copy with the latest +*development* version of our code. If you want the latest production +version (i.e., what we're running on the site), you need to switch to +the live version of the software which is kept in a branch called +"live." Once you cloned the repository above, you can switch into the +directory (i.e., run "cd selectricity") and then run the following +command: + + git checkout -b live origin/live =============================================== @@ -30,12 +44,6 @@ list here: http://mailman.mit.edu/mailman/listinfo/selectricity -In terms of bugs and documentation, we current plan to build this out in -our Gitorious wiki so feel free to get started with your own efforts -along these lines there: - - http://gitorious.org/selectricity/pages/Home - =============================================== === Dependencies ============================== @@ -70,7 +78,6 @@ tried it with any other system. Presumably though, anything that provides '/usr/bin/sendmail' should work. - =============================================== === Contributors to Selectricity Include ====== =============================================== diff --git a/app/controllers/quickvote_controller.rb b/app/controllers/quickvote_controller.rb index 4b3c0c9..701005d 100644 --- a/app/controllers/quickvote_controller.rb +++ b/app/controllers/quickvote_controller.rb @@ -158,14 +158,16 @@ class QuickvoteController < ApplicationController else # record the ip address for posterity - @voter.ipaddress = request.env["REMOTE_ADDR"] + @voter.ipaddress = request.env["HTTP_X_FORWARDED_FOR"] @voter.save # toggle the confirmation bit - @voter.vote.confirm! - - @voter.reload - render :action => 'thanks' + if @voter.vote.confirm! + @voter.reload + render :action => 'thanks' + else + redirect_to :action => 'index' + end end end @@ -183,9 +185,10 @@ class QuickvoteController < ApplicationController @election=QuickVote.ident_to_quickvote(params[:id]) @election.voters.each do |voter| next unless voter.ipaddress + location=nil - if defined? Cache and location=Cache.get("GEO:#{voter.ipaddress}") - elsif defined? Cache + if Cache and location=Cache.get("GEO:#{voter.ipaddress}") + elsif Cache location = GeoKit::Geocoders::IpGeocoder.geocode(voter.ipaddress) Cache.set "GEO:#{voter.ipaddress}", location else diff --git a/app/controllers/voter_controller.rb b/app/controllers/voter_controller.rb index 408bdab..a550f67 100644 --- a/app/controllers/voter_controller.rb +++ b/app/controllers/voter_controller.rb @@ -97,16 +97,18 @@ class VoterController < ApplicationController end def confirm - @voter.vote.confirm! - - if @voter.election.embeddable? and params[:embed] == "true" \ - and @voter.election.early_results? - redirect_to :action => :results, :id => @password, :embed => 'true' - elsif not(@voter.election.verifiable) \ - and @voter.election.kiosk and params[:kiosk] == "true" - redirect_to :action => "kiosk_ready", :id => @password, :kiosk => true + if @voter.vote.confirm! + if @voter.election.embeddable? and params[:embed] == "true" \ + and @voter.election.early_results? + redirect_to :action => :results, :id => @password, :embed => 'true' + elsif not(@voter.election.verifiable) \ + and @voter.election.kiosk and params[:kiosk] == "true" + redirect_to :action => "kiosk_ready", :id => @password, :kiosk => true + else + render :action => 'thanks' + end else - render :action => 'thanks' + redirect_to :action => 'index' end end diff --git a/app/models/election.rb b/app/models/election.rb index 4ce571a..b48c923 100644 --- a/app/models/election.rb +++ b/app/models/election.rb @@ -137,11 +137,11 @@ class Election < ActiveRecord::Base # skip if the voter has not voted or has an unconfirmed vote next unless voter.voted? - plurality_tally << voter.vote.rankings.sort[0].candidate.id + plurality_tally << voter.vote.rankings.sort[0].candidate_id approval_tally << voter.vote.rankings.sort[0..1].collect \ - { |ranking| ranking.candidate.id } + { |ranking| ranking.candidate_id } preference_tally << voter.vote.rankings.sort.collect \ - { |ranking| ranking.candidate.id } + { |ranking| ranking.candidate_id } end @plurality_result = PluralityVote.new(plurality_tally).result diff --git a/app/models/vote.rb b/app/models/vote.rb index cc42311..12dd64d 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -62,14 +62,19 @@ class Vote < ActiveRecord::Base end def confirm! - self.confirmed = 1 - self.time = Time.now - self.save - - unless self.voter.election.quickvote? - token.destroy and token.reload if token - self.token = Token.new + if self.voter.election.candidates.length == self.rankings.length + self.confirmed = 1 + self.time = Time.now self.save + + unless self.voter.election.quickvote? + token.destroy and token.reload if token + self.token = Token.new + self.save + end + return false + else + return true end end diff --git a/app/views/layouts/_footer.rhtml b/app/views/layouts/_footer.rhtml index 27332f0..dabd44c 100644 --- a/app/views/layouts/_footer.rhtml +++ b/app/views/layouts/_footer.rhtml @@ -1,7 +1,7 @@