You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by gs...@apache.org on 2026/02/27 14:49:52 UTC

(steve) branch trunk updated (b6a2785 -> b62561d)

This is an automated email from the ASF dual-hosted git repository.

gstein pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git


    from b6a2785  refactor: return voter records as EasyDict objects in get_voters_for_email
     new a8641e5  feat: add mail-voters.py script for emailing eligible voters
     new 1447c5e  feat: implement EZT template rendering for voter emails
     new 12fe75b  fix: update sender email to voter@apache.org
     new 972fb55  chore: add display name to email sender
     new b62561d  switch shebang to "uv run"

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 v3/server/bin/create-election.py |   2 +-
 v3/server/bin/mail-voters.py     | 104 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+), 1 deletion(-)
 create mode 100755 v3/server/bin/mail-voters.py


(steve) 04/05: chore: add display name to email sender

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 972fb5577331a72ee3b4a20fee9fe230cd05be36
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Fri Feb 27 08:17:36 2026 -0600

    chore: add display name to email sender
    
    Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <ai...@aider.chat>
---
 v3/server/bin/mail-voters.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/v3/server/bin/mail-voters.py b/v3/server/bin/mail-voters.py
index a1f2a8c..78d0b60 100644
--- a/v3/server/bin/mail-voters.py
+++ b/v3/server/bin/mail-voters.py
@@ -72,7 +72,7 @@ def main(eid, template_file):
         
         # Send the email
         asfpy.messaging.mail(
-            sender="<vo...@apache.org>",
+            sender="Apache Election Platform <vo...@apache.org>",
             recipient=voter.email,
             subject=f"Vote in Election: {metadata.title}",
             message=rendered_body,


(steve) 01/05: feat: add mail-voters.py script for emailing eligible voters

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit a8641e51731935f347eb2fa633ed5179209f7a54
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Fri Feb 27 08:04:30 2026 -0600

    feat: add mail-voters.py script for emailing eligible voters
    
    Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <ai...@aider.chat>
---
 v3/server/bin/mail-voters.py | 96 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/v3/server/bin/mail-voters.py b/v3/server/bin/mail-voters.py
new file mode 100644
index 0000000..708cefa
--- /dev/null
+++ b/v3/server/bin/mail-voters.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python3
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Script to send emails to all eligible voters for a given election.
+Loads the election, renders an email template for each voter, and sends via asfpy.messaging.
+"""
+
+import argparse
+import pathlib
+import logging
+
+import asfpy.messaging
+import steve.election
+
+_LOGGER = logging.getLogger(__name__)
+
+THIS_DIR = pathlib.Path(__file__).resolve().parent
+DB_FNAME = THIS_DIR.parent / 'steve.db'
+
+
+def main(eid, template_file):
+    """
+    Main function to load election, get voters, render emails, and send.
+    """
+    # Load the election
+    election = steve.election.Election(DB_FNAME, eid)
+    
+    # Get metadata for context
+    metadata = election.get_metadata()
+    
+    # Get list of eligible voters
+    voters = election.get_voters_for_email()
+    
+    if not voters:
+        _LOGGER.info(f"No eligible voters found for election {eid}")
+        return
+    
+    # Load the EZT template
+    template = asfpy.messaging.load_template(template_file)  # Assuming asfpy.messaging has a load_template method; adjust if needed
+    
+    # Send email to each voter
+    for voter in voters:
+        # Render the template with voter data
+        # Note: This is a skeleton; implement template rendering as needed
+        # Example: rendered_body = template.render({'pid': voter.pid, 'name': voter.name, 'email': voter.email, 'election': metadata})
+        rendered_body = f"Dear {voter.name},\n\nThis is a test email for election {metadata.title}.\n\nRegards,\nElection System"
+        
+        # Send the email
+        asfpy.messaging.mail(
+            sender="Election System <no...@example.com>",  # Adjust sender
+            recipient=voter.email,
+            subject=f"Vote in Election: {metadata.title}",
+            message=rendered_body,
+            # Add other parameters as needed (e.g., auth, headers)
+        )
+        
+        _LOGGER.info(f"Sent email to {voter.email} for election {eid}")
+
+
+if __name__ == '__main__':
+    logging.basicConfig(level=logging.INFO)
+
+    parser = argparse.ArgumentParser(
+        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
+        description="Send emails to eligible voters for a given election."
+    )
+    parser.add_argument(
+        '--eid',
+        required=True,
+        help='Election ID to send emails for.'
+    )
+    parser.add_argument(
+        '--template',
+        required=True,
+        help='Path to the .ezt template file for email body.'
+    )
+    args = parser.parse_args()
+    
+    main(args.eid, args.template)


(steve) 03/05: fix: update sender email to voter@apache.org

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 12fe75b739a86572223c00685e6e7f32ca8f1d53
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Fri Feb 27 08:16:35 2026 -0600

    fix: update sender email to voter@apache.org
    
    Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <ai...@aider.chat>
---
 v3/server/bin/mail-voters.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/v3/server/bin/mail-voters.py b/v3/server/bin/mail-voters.py
index a85b40b..a1f2a8c 100644
--- a/v3/server/bin/mail-voters.py
+++ b/v3/server/bin/mail-voters.py
@@ -72,7 +72,7 @@ def main(eid, template_file):
         
         # Send the email
         asfpy.messaging.mail(
-            sender="Election System <no...@example.com>",  # Adjust sender
+            sender="<vo...@apache.org>",
             recipient=voter.email,
             subject=f"Vote in Election: {metadata.title}",
             message=rendered_body,


(steve) 02/05: feat: implement EZT template rendering for voter emails

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 1447c5e2aa0e1840188d5736656750c6f5efa923
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Fri Feb 27 08:14:22 2026 -0600

    feat: implement EZT template rendering for voter emails
    
    Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <ai...@aider.chat>
---
 v3/server/bin/mail-voters.py | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/v3/server/bin/mail-voters.py b/v3/server/bin/mail-voters.py
index 708cefa..a85b40b 100644
--- a/v3/server/bin/mail-voters.py
+++ b/v3/server/bin/mail-voters.py
@@ -19,13 +19,15 @@
 
 """
 Script to send emails to all eligible voters for a given election.
-Loads the election, renders an email template for each voter, and sends via asfpy.messaging.
+Loads the election, renders an email template for each voter using EZT, and sends via asfpy.messaging.
 """
 
 import argparse
 import pathlib
 import logging
+import io
 
+import ezt
 import asfpy.messaging
 import steve.election
 
@@ -53,14 +55,20 @@ def main(eid, template_file):
         return
     
     # Load the EZT template
-    template = asfpy.messaging.load_template(template_file)  # Assuming asfpy.messaging has a load_template method; adjust if needed
+    template = ezt.Template(template_file)
     
     # Send email to each voter
     for voter in voters:
-        # Render the template with voter data
-        # Note: This is a skeleton; implement template rendering as needed
-        # Example: rendered_body = template.render({'pid': voter.pid, 'name': voter.name, 'email': voter.email, 'election': metadata})
-        rendered_body = f"Dear {voter.name},\n\nThis is a test email for election {metadata.title}.\n\nRegards,\nElection System"
+        # Prepare data dictionary for template rendering
+        data = {
+            'voter': voter,  # edict with pid, name, email
+            'election': metadata,  # edict with eid, title, owner_pid, etc.
+        }
+        
+        # Render the template to a StringIO stream
+        output = io.StringIO()
+        template.generate(output, data)
+        rendered_body = output.getvalue()
         
         # Send the email
         asfpy.messaging.mail(


(steve) 05/05: switch shebang to "uv run"

Posted by gs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit b62561d0b896534a8618d52cdda7f310b589175a
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Fri Feb 27 08:49:44 2026 -0600

    switch shebang to "uv run"
---
 v3/server/bin/create-election.py | 2 +-
 v3/server/bin/mail-voters.py     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/v3/server/bin/create-election.py b/v3/server/bin/create-election.py
index b9c7497..edf2e0c 100755
--- a/v3/server/bin/create-election.py
+++ b/v3/server/bin/create-election.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env -S uv run --script
 
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/v3/server/bin/mail-voters.py b/v3/server/bin/mail-voters.py
old mode 100644
new mode 100755
index 78d0b60..b1a2ed2
--- a/v3/server/bin/mail-voters.py
+++ b/v3/server/bin/mail-voters.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env -S uv run --script
 
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file