aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinvite_participants.rb25
-rw-r--r--poll.rb20
2 files changed, 27 insertions, 18 deletions
diff --git a/invite_participants.rb b/invite_participants.rb
index 15c7dd1..6c9204a 100755
--- a/invite_participants.rb
+++ b/invite_participants.rb
@@ -33,26 +33,13 @@ require "html"
load "config.rb"
require "poll"
Dir.chdir(olddir)
-# BUGFIX for Time.parse, which handles the zone indeterministically
-class << Time
- alias_method :old_parse, :parse
- def Time.parse(date, now=self.now)
- Time.old_parse("2009-10-25 00:30")
- Time.old_parse(date)
- end
-end
table = YAML::load_file("data.yaml")
-# TODO: move to own tab
-#if $cgi.include?("add_participant")
-# if $cgi.include?("delete_participant")
-# table.delete($cgi["olduser"])
-# else
-# table.add_participant($cgi["olduser"],$cgi["add_participant"],{})
-# end
-#end
+if $cgi.include?("add_participant")
+ table.add_participant("",$cgi["add_participant"],{})
+end
$html = HTML.new("dudle - #{table.name} - Invite Participants")
$html.header["Cache-Control"] = "no-cache"
@@ -65,8 +52,10 @@ $html << Dudle::tabs("Invite Participants")
$html << <<TABLE
<div id='main'>
<h1>#{table.name}</h1>
- <h2>Invite or Delete Participants</h2>
- #{table.to_html}
+ <h2>Invite Participants</h2>
+ <form method='post' action=''>
+ #{table.to_html("","invite")}
+ </form>
TABLE
$html << "</div></body>"
diff --git a/poll.rb b/poll.rb
index b0c44ad..a0c55a9 100644
--- a/poll.rb
+++ b/poll.rb
@@ -60,7 +60,12 @@ class Poll
end
end
+ # showparticipation \in {true, false, "invite"}
def to_html(edituser = "", showparticipation = true)
+ if showparticipation == "invite"
+ showparticipation = false
+ invite = true
+ end
ret = "<table border='1' summary='Main Poll table'>\n"
sortcolumns = $cgi.include?("sort") ? $cgi.params["sort"] : ["timestamp"]
@@ -97,6 +102,7 @@ class Poll
# PARTICIPATE
ret += participate_to_html(edituser) unless @data.keys.include?(edituser) || !showparticipation
+ ret += invite_to_html if invite
# SUMMARY
ret += "<tr id='summary'><td class='name'>total</td>\n"
@@ -139,6 +145,20 @@ class Poll
ret
end
+ def invite_to_html
+ ret = <<INVITE
+<tr id='add_participant'>
+<td class='name'>
+ <input size='16' type='text' name='add_participant' />
+</td>
+<td class='checkboxes' colspan='#{@head.col_size + 1}'>
+ <input type='submit' value='Invite' />
+</td>
+</tr>
+INVITE
+
+ end
+
def participate_to_html(edituser)
checked = {}
if @data.include?(edituser)