From 7110aee065a826e040d49b842329d7dcb86fbb34 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Tue, 2 Jun 2009 20:33:41 +0200 Subject: new feature: edit link, NEUE DATENSTRUKTUR --- poll.rb | 58 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 18 deletions(-) (limited to 'poll.rb') diff --git a/poll.rb b/poll.rb index b81c28b..c4db994 100644 --- a/poll.rb +++ b/poll.rb @@ -9,6 +9,9 @@ require "yaml" class Poll attr_reader :head, :name, :hidden + YESVAL = "ayes" + MAYBEVAL = "bmaybe" + NOVAL = "cno" def initialize name @name = name @hidden = false @@ -35,6 +38,7 @@ class Poll ret += "#{columntitle}\n" } ret += "Last Edit\n" + ret += "\n" ret += "\n" ret end @@ -51,16 +55,17 @@ class Poll when nil value = UNKNOWN klasse = "undecided" - when "0 yes" + when YESVAL value = YES - when "2 no" + when NOVAL value = NO - when "1 maybe" + when MAYBEVAL value = MAYBE end ret += "#{value}\n" } ret += "#{poll['timestamp'].strftime('%d.%m, %H:%M')}" + ret += "edit" ret += "\n" } @@ -73,9 +78,9 @@ class Poll yes = 0 undecided = 0 @data.each_value{|participant| - if participant[columntitle] == "0 yes" + if participant[columntitle] == YESVAL yes += 1 - elsif !participant.has_key?(columntitle) or participant[columntitle] == "1 maybe" + elsif !participant.has_key?(columntitle) or participant[columntitle] == MAYBEVAL undecided += 1 end } @@ -108,21 +113,38 @@ class Poll ret end def participate_to_html + checked = {} + if $cgi.include?("edit") + participant = $cgi["edit"] + @head.each_key{|k| checked[k] = @data[participant][k]} + else + @head.each_key{|k| checked[k] = NOVAL} + end ret = "\n" - ret += "\n" - @head.sort.each{|columntitle,columndescription| - ret += " - - - - - - - - - -
+ ret += " + \n" + @head.sort.each{|columntitle,columndescription| + ret += "" + [[YES, YESVAL],[NO, NOVAL],[MAYBE, MAYBEVAL]].each{|valhuman, valbinary| + ret += " + + + " + } + ret += "
+ + + +
" } ret += "\n" -- cgit v1.2.3