Merge branch 'thh-checkvotename' into next
authorThomas Hochstein <thh@inter.net>
Sat, 15 Feb 2014 16:30:05 +0000 (17:30 +0100)
committerThomas Hochstein <thh@inter.net>
Sat, 15 Feb 2014 16:30:05 +0000 (17:30 +0100)
* thh-checkvotename:
  Display current voting identifier in menu.
  Correctly find $votename.
  Add forgotten template.
  Fix regular expression.
  Check correct voting in ballot.

UVmenu.pm
messages.cfg
templates/ballot
templates/ballot-personal
templates/wrong-voting [new file with mode: 0644]
usevote.cfg
usevote.global.cfg
uvcfv.pl
uvvote.pl

index d90da9c..5d96c8e 100644 (file)
--- a/UVmenu.pm
+++ b/UVmenu.pm
@@ -17,7 +17,8 @@ $VERSION = "0.4";
 ##############################################################################
 # Menu for interaction with the votetaker                                    #
 # Parameters: votes list and header (references to arrays)                   #
-#             Body, Mailadress, Name, Ballot ID (references to strings)      #
+#             Body, Mailadress, Name, Ballot ID,                             #
+#             Voting (references to strings)                                 #
 #             List of newly set fields (reference to array)                  #
 #             List of errors to correct (Array-Ref)                          #
 # Return Values: 'w': proceed                                                #
@@ -25,7 +26,7 @@ $VERSION = "0.4";
 ##############################################################################
 
 sub menu {
-  my ($votes, $header, $body, $addr, $name, $ballot_id, $set, $errors) = @_;
+  my ($votes, $header, $body, $addr, $name, $ballot_id, $voting, $set, $errors) = @_;
   my $input = "";
   my $voter_addr = $$addr || '';
   my $voter_name = $$name || '';
@@ -59,6 +60,7 @@ sub menu {
   while (1) {
 
     system($config{clearcmd});
+    print "-> $config{votename} <-\n";
     print UVmessage::get("MENU_PROBLEMS") . "\n";
 
     foreach my $error (keys %errors) {
@@ -79,6 +81,7 @@ sub menu {
       print "(5) ", UVmessage::get("MENU_BALLOT_ID"), " [$$ballot_id]\n"
         if ($config{personal});
       print "(6) ", UVmessage::get("MENU_BDSG"), "\n" if ($config{bdsg});
+      print "(7) ", UVmessage::get("MENU_VOTING"), " [", $$voting, "]\n";
     }
 
     print "\n",
@@ -269,6 +272,22 @@ sub menu {
         $errors{InvalidBDSG} = UVmessage::get("MENU_INVALIDBDSG");
       }
 
+    } elsif ($input eq '7') {
+      my $sel;
+      do {
+        print "[a] ", UVmessage::get("MENU_VOTING_CORRECT"), "\n",
+              "[b] ", UVmessage::get("MENU_VOTING_WRONG"), "\n\n",
+              UVmessage::get("MENU_PROMPT");
+        $sel = <STDIN>;
+      } until ($sel =~ /^[ab]$/i);
+
+      if ($sel =~ /^a$/i) {
+        delete $errors{NoVoting};
+        delete $errors{WrongVoting};
+      } else {
+        $errors{WrongVoting} = UVmessage::get("MENU_WRONGVOTING");
+      }
+
     } elsif ($input =~ /^i$/i) {
       my $ignore = UVmessage::get("MENU_IGNORE_STRING");
       # Set columns for Text::Wrap
index 8dca33c..6c9b339 100644 (file)
@@ -29,6 +29,8 @@ MENU_INVALIDBDSG = Datenschutzhinweis fehlerhaft oder nicht bestaetigt.
 MENU_DUPLICATEVOTE = Doppelte Stimmabgabe gefunden.
 MENU_NOVOTE = Keine Stimmabgabe gefunden.
 MENU_INVALIDVOTE = Ungueltige Stimmabgabe.
+MENU_NOVOTING = Bezeichnung der Abstimmung nicht gefunden.
+MENU_WRONGVOTING = Wahlschein fuer andere Abstimmung.
 MENU_NOBALLOTID = Keine Scheinkennung gefunden.
 MENU_WRONGBALLOTID = Scheinkennung falsch.
 MENU_ADDRESSNOTREGISTERED = Adresse nicht registriert.
@@ -67,6 +69,9 @@ MENU_BALLOT_ID = Scheinkennung
 MENU_BDSG = Datenschutzklausel
 MENU_BDSG_ACCEPTED = Datenschutzklausel wurde akzeptiert
 MENU_BDSG_DECLINED = Datenschutzklausel nicht akzeptiert bzw. Text veraendert
+MENU_VOTING = Abstimmung
+MENU_VOTING_CORRECT = Korrekter Wahlschein fuer diese Abstimmung
+MENU_VOTING_WRONG = Wahlschein fuer andere Abstimmung
 MENU_IGNORE = Diese Stimme ignorieren (ohne Benachrichtigung verwerfen)
 MENU_IGNORE_WARNING = Die Stimme wird nicht aufgezeichnet, und es wird keine Bestaetigung verschickt. ${MENU_IGNORE_STRING} eingeben, wenn Du sicher bist: 
 MENU_IGNORE_STRING = JA
@@ -173,6 +178,7 @@ VOTE_UNREGISTERED_ADDRESS = Adresse nicht registriert
 VOTE_INVALID_VOTE = Ungueltige Stimmabgabe
 VOTE_VIOLATED_RULE = Regel ${RULE} verletzt
 VOTE_NO_VOTES = Keine Stimmen abgegeben
+VOTE_WRONG_VOTING = Wahlschein gehoert nicht zu dieser Abstimmung
 VOTE_INVALID_ACCOUNT = Ungueltiger Account
 VOTE_INVALID_ADDRESS = Ungueltige Adresse
 VOTE_INVALID_REALNAME = Ungueltiger Realname
index 5e3242a..30add33 100644 (file)
@@ -14,7 +14,7 @@ bdsgtext-more   := value bdsgtext | drop-words 50 | create-lines 50
 
 =-=-=-=-=-=-=-=- Alles vor dieser Zeile bitte loeschen =-=-=-=-=-=-=-=-
 
-WAHLSCHEIN fuer [$votename-first]
+[$ballotintro] [$votename-first]
 [@votename-more|                [$line]\n]
 
 
index 13aef2a..495baec 100644 (file)
@@ -29,7 +29,7 @@ votetaker       := value mailfrom | fill-left 65
 
 =-=-=-=-=-=-=-=- Alles vor dieser Zeile bitte loeschen =-=-=-=-=-=-=-=-
 
-WAHLSCHEIN fuer [$votename-first]
+[$ballotintro] [$votename-first]
 [@votename-more|                [$line]\n]
 
 
diff --git a/templates/wrong-voting b/templates/wrong-voting
new file mode 100644 (file)
index 0000000..1d12e31
--- /dev/null
@@ -0,0 +1,21 @@
+votetaker       := value mailfrom | fill-left 65
+body            := value body     | quote "> "
+
+== TEMPLATE =================================================================
+Offenbar hast du einen Wahlschein fuer eine andere Abstimmung eingesandt
+oder der Name der Abstimmung geht aus dem Wahlschein nicht hervor. Wenn
+das ein Irrtum war, pruefe bitte noch einmal die im CfV angegebene
+Abstimmungsadresse und wiederhole Deine Stimmabgabe.
+
+Dieser Fehler kann auftreten, wenn Du an mehreren Abstimmungen teilnimmst
+und den Wahlschein von Hand einsendest (und dabei mehrere Abstimmungen
+verwechselst), oder wenn Du die Bezeichnung der Abstimmung im Wahlschein
+veraendert oder geloescht hast.
+
+Hier die Mail, die ich erhalten habe:
+
+[$body]
+
+
+[$votetaker]
+\[mit [$usevote_version]\]
\ No newline at end of file
index 73ca4fb..d6a6b33 100644 (file)
@@ -227,6 +227,10 @@ mailstart = "^From "
 begin_divider = Alles vor dieser Zeile bitte loeschen
 end_divider = Alles nach dieser Zeile bitte loeschen
 
+# Ueberschrift fuer den Wahlschein
+# Achtung, muss im Wahlschein genauso stehen!
+ballotintro = WAHLSCHEIN fuer
+
 # Text fuer die Namens-Angabe im Wahlschein. Achtung, muss im
 # Wahlschein genauso stehen!
 nametext = Dein Realname, falls nicht im FROM-Header:
@@ -290,4 +294,5 @@ tpl_invalid_name = "invalid-name"        # used by uvvote.pl
 tpl_multiple_votes = "multiple-votes"    # used by uvvote.pl
 tpl_no_ballot = "no-ballot"              # used by uvvote.pl
 tpl_no_votes = "no-votes"                # used by uvvote.pl
+tpl_wrong_voting = "wrong-voting"        # used by uvvote.pl
 tpl_rule_violated = "rule-violated"      # used by uvvote.pl   (c.f. usevote.rul)
index beb859f..2ba69b4 100644 (file)
@@ -99,6 +99,10 @@ mailstart = "^From "
 begin_divider = Alles vor dieser Zeile bitte loeschen
 end_divider = Alles nach dieser Zeile bitte loeschen
 
+# Ueberschrift fuer den Wahlschein
+# Achtung, muss im Wahlschein genauso stehen!
+ballotintro = WAHLSCHEIN fuer
+
 # Text fuer die Namens-Angabe im Wahlschein. Achtung, muss im
 # Wahlschein genauso stehen!
 nametext = Dein Realname, falls nicht im FROM-Header:
@@ -162,4 +166,5 @@ tpl_invalid_name = "invalid-name"        # used by uvvote.pl
 tpl_multiple_votes = "multiple-votes"    # used by uvvote.pl
 tpl_no_ballot = "no-ballot"              # used by uvvote.pl
 tpl_no_votes = "no-votes"                # used by uvvote.pl
+tpl_wrong_voting = "wrong-voting"        # used by uvvote.pl
 tpl_rule_violated = "rule-violated"      # used by uvvote.pl   (c.f. usevote.rul)
index 74174c6..6179915 100755 (executable)
--- a/uvcfv.pl
+++ b/uvcfv.pl
@@ -152,9 +152,9 @@ sub process_request {
     # check for suspicious addresses
     foreach my $element (@bad_addr) {
       if ($voter_addr =~ /^$element/) {
-        my (@votes, @set, $ballot_id); # irrelevant, but necessary for UVmenu::menu()
+        my (@votes, @set, $ballot_id, $voting); # irrelevant, but necessary for UVmenu::menu()
         my @errors = ('SuspiciousAccountBallot');
-        my $res = UVmenu::menu(\@votes, \@header, $body, \$voter_addr, \$voter_name, \$ballot_id, \@set, \@errors);
+        my $res = UVmenu::menu(\@votes, \@header, $body, \$voter_addr, \$voter_name, \$ballot_id, \$voting, \@set, \@errors);
 
         # "Ignore": don't deliver a ballot
         return 0 if ($res eq 'i');
index c859504..9505edc 100755 (executable)
--- a/uvvote.pl
+++ b/uvvote.pl
@@ -224,6 +224,7 @@ sub process_vote {
   my $onevote = 0;             # 0=no votes, 1=everything OK, 2=vote cancelled
   my $voteerror = "";          # error message in case of invalid vote
   my $ballot_id = "";          # ballot id (German: Wahlscheinkennung)
+  my $voting = "";             # voting (should be votename)
 
   # found address?
   if ($voter_addr) {
@@ -239,6 +240,15 @@ sub process_vote {
     push (@errors, 'InvalidAddress');
   }
 
+  # correct voting?
+  if ($$body =~ /\Q$config{ballotintro}\E\s+(.+?)\s*\n([>:|]*?[\t ]+(\S+.+)\s*$)?/m) {
+    $voting = $1;
+    $voting .= " $3" if (defined($3) and $3 !~ /\Q$config{nametext}\E/);
+    push (@errors, 'WrongVoting') if ($config{votename} !~ /^\s*\Q$voting\E\s*$/);
+  } else {
+    push (@errors, 'NoVoting');
+  }
+
   # personalized ballots?
   if ($config{personal}) {
     if ($$body =~ /$config{ballotidtext}\s+([a-z0-9]+)/) {
@@ -343,7 +353,7 @@ sub process_vote {
   # Errors encountered?
   if (@errors) {
     my $res = UVmenu::menu(\@votes, \@header, $body, \$voter_addr, \$voter_name,
-                           \$ballot_id, \@set, \@errors);
+                           \$ballot_id, \$voting, \@set, \@errors);
     return 0 if ($res eq 'i');      # "Ignore": Ignore vote, don't save
 
     my $tpl;
@@ -402,6 +412,12 @@ sub process_vote {
       my $msg = $template->processTemplate($config{tpl_bdsg_error});
       UVsendmail::mail($voter_addr, "Fehler", $msg, $msgid) if ($config{voteack});
       return 0;
+    } elsif ($error{NoVoting} or $error{WrongVoting}) {
+      $voteerror = UVmessage::get("VOTE_WRONG_VOTING");
+      my $template = UVtemplate->new();
+      $template->setKey('body'  => $$body);
+      my $msg = $template->processTemplate($config{tpl_wrong_voting});
+      UVsendmail::mail($voter_addr, "Fehler", $msg, $msgid) if ($config{voteack});
     } elsif ($error{NoVote}) {
       $voteerror = UVmessage::get("VOTE_NO_VOTES");
       my $template = UVtemplate->new();
This page took 0.017658 seconds and 4 git commands to generate.