Joel Aufrecht
Web app for voting in OCT elections.
Index: openacs-4/packages/oct-election/tcl/oct-election-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/oct-election/tcl/oct-election-procs.tcl,v
diff -u -r1.1.1.1 -r1.1.1.1.4.1
--- openacs-4/packages/oct-election/tcl/oct-election-procs.tcl 14 May 2005 19:49:49 -0000 1.1.1.1
+++ openacs-4/packages/oct-election/tcl/oct-election-procs.tcl 7 Nov 2005 19:51:49 -0000 1.1.1.1.4.1
@@ -28,33 +28,45 @@
set num_days 90
set valid_voter_p 0
db_1row get_election {
- select start_time,
- end_time,
- vote_forum_cutoff,
- label
+ select start_time,
+ end_time,
+ vote_forum_cutoff,
+ label,
+ (case when now() > start_time then 1 else 0 end) as past_start_p,
+ (case when now() > end_time then 1 else 0 end) as past_end_p
from oct_election
where election_id = :election_id
}
+ set pretty_vote_forum_cutoff [lc_time_fmt $vote_forum_cutoff %c]
set before_sql "to_date(:vote_forum_cutoff, 'YYYY-MM-DD')"
- #TODO: enable and test this on openacs
- set num_posts 2
- # set num_posts [db_string get_count "
- # select count(message_id) as num_posts
- # from cc_users, forums_messages
- # where cc_users.user_id = forums_messages.user_id
- # and posting_date between $before_sql - interval '$num_days days' and $before_sql
- # and cc_users.user_id = $user_id
- # group by cc_users.user_id
- #"]
-
- if {$num_posts < 2} {
+ set num_posts [db_string get_count "
+ select count(message_id) as num_posts
+ from cc_users, forums_messages
+ where cc_users.user_id = forums_messages.user_id
+ and posting_date between $before_sql - interval '$num_days days' and $before_sql
+ and cc_users.user_id = $user_id
+ "]
+
+ if {$num_posts < 2} {
set status 0
- set text "You are not a valid voter for this election. See OpenACS Governance"
+ set text "You are not a valid voter for this election because you have not posted at least twice in the OpenACS forums since $pretty_vote_forum_cutoff. See OpenACS Governance"
return [list $status $text]
}
+ if {!$past_start_p} {
+ set status 0
+ set text "The election will not begin until [lc_time_fmt $start_time %c]"
+ return [list $status $text]
+ }
+
+ if {$past_end_p} {
+ set status 0
+ set text "The election ended at [lc_time_fmt $end_time %c]"
+ return [list $status $text]
+ }
+
set status 1
set text "You have already voted in this election."
return [list $status $text]
Index: openacs-4/packages/oct-election/www/election-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/oct-election/www/election-edit.tcl,v
diff -u -r1.2 -r1.2.2.1
--- openacs-4/packages/oct-election/www/election-edit.tcl 14 May 2005 23:16:28 -0000 1.2
+++ openacs-4/packages/oct-election/www/election-edit.tcl 7 Nov 2005 19:51:49 -0000 1.2.2.1
@@ -40,8 +40,8 @@
} -new_data {
db_dml create_election {
insert into oct_election
- (start_time, end_time, number_of_candidates, label)
- values (:start_time, :end_time, :number_of_candidates, :label);
+ (start_time, end_time, number_of_candidates, vote_forum_cutoff, label)
+ values (:start_time, :end_time, :number_of_candidates, :vote_forum_cutoff, :label);
}
} -edit_data {
db_dml update_election {
Index: openacs-4/packages/oct-election/www/election.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/oct-election/www/election.adp,v
diff -u -r1.2 -r1.2.2.1
--- openacs-4/packages/oct-election/www/election.adp 14 May 2005 23:16:28 -0000 1.2
+++ openacs-4/packages/oct-election/www/election.adp 7 Nov 2005 19:51:49 -0000 1.2.2.1
@@ -3,10 +3,10 @@
@context;noquote@
Election: @label@
-
Number of winners possible: @number_of_candidates@
-
Start time: @start_time@
-
End time: @end_time@
-
Forum cutoff date: @vote_forum_cutoff@
+
Number of OCT vacancies: @number_of_candidates@
+
Start time: @pretty_start_time@
+
End time: @pretty_end_time@
+
Forum cutoff date: @pretty_vote_forum_cutoff@
Ballots: @ballot_count@
Edit
@@ -30,6 +30,6 @@
- @valid_voter_text@
+ @valid_voter_text;noquote@
Index: openacs-4/packages/oct-election/www/election.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/oct-election/www/election.tcl,v
diff -u -r1.3 -r1.3.2.1
--- openacs-4/packages/oct-election/www/election.tcl 14 May 2005 23:16:28 -0000 1.3
+++ openacs-4/packages/oct-election/www/election.tcl 7 Nov 2005 19:51:49 -0000 1.3.2.1
@@ -22,6 +22,10 @@
where election_id = :election_id
}
+set pretty_start_time [lc_time_fmt $start_time %c]
+set pretty_end_time [lc_time_fmt $end_time %c]
+set pretty_vote_forum_cutoff [lc_time_fmt $vote_forum_cutoff %c]
+
set ballot_count [db_string get_ballot_count {
select count(*)
from oct_ballot
@@ -87,4 +91,3 @@
select now() as now
from dual;
}
-