Gentoo Archives: gentoo-commits

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/council-webapp:master commit in: site/app/controllers/
Date: Mon, 01 Aug 2011 14:38:43
Message-Id: 7b3f49a25aecef13a7b20ba7014c7432318bbd26.betelgeuse@gentoo
1 commit: 7b3f49a25aecef13a7b20ba7014c7432318bbd26
2 Author: Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
3 AuthorDate: Tue Jul 26 14:15:36 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 26 14:15:36 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=7b3f49a2
7
8 Improve controller readability
9
10 ---
11 site/app/controllers/agendas_controller.rb | 2 +-
12 site/app/controllers/voting_options_controller.rb | 8 ++++----
13 2 files changed, 5 insertions(+), 5 deletions(-)
14
15 diff --git a/site/app/controllers/agendas_controller.rb b/site/app/controllers/agendas_controller.rb
16 index 669f364..f94d96c 100644
17 --- a/site/app/controllers/agendas_controller.rb
18 +++ b/site/app/controllers/agendas_controller.rb
19 @@ -14,7 +14,7 @@ class AgendasController < ApplicationController
20 end
21
22 def results
23 - data = JSON.parse(request.env["rack.input"].read)
24 + data = JSON.parse(request.env['rack.input'].read)
25 Agenda.update_voting_options data['agenda']
26 Agenda.process_results data data['votes']
27 agenda = Agenda.current
28
29 diff --git a/site/app/controllers/voting_options_controller.rb b/site/app/controllers/voting_options_controller.rb
30 index 14ec89f..73a0dfb 100644
31 --- a/site/app/controllers/voting_options_controller.rb
32 +++ b/site/app/controllers/voting_options_controller.rb
33 @@ -6,7 +6,10 @@ class VotingOptionsController < ApplicationController
34
35 def community_vote
36 option = VotingOption.find(params[:id])
37 - unless option.nil?
38 + if option.nil?
39 + flash[:notice] = "No such voting option"
40 + redirect_to :controller => :agendas, :action => :index
41 + else
42 if current_user.signed_up?
43 Vote.vote_for_option(current_user, option, false)
44 flash[:notice] = "You voted for #{option.description}"
45 @@ -14,9 +17,6 @@ class VotingOptionsController < ApplicationController
46 flash[:notice] = "You must be logged in to vote"
47 end
48 redirect_to :controller => :agenda_items, :action => :show, :id => option.agenda_item_id
49 - else
50 - flash[:notice] = "No such voting option"
51 - redirect_to :controller => :agendas, :action => :index
52 end
53 end
54 end