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 -N -r1.1.1.1 -r1.1.1.1.2.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 14 May 2005 23:49:23 -0000 1.1.1.1.2.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]