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

curcuru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new f5fc0c1f Enable sending a mail (test mode only for now)
f5fc0c1f is described below

commit f5fc0c1f20ad7bdc9b5fc10ef66d25cf72b59b64
Author: Shane Curcuru <[email protected]>
AuthorDate: Fri Jan 24 13:45:29 2025 -0500

    Enable sending a mail (test mode only for now)
---
 www/members/member_nominations.cgi | 62 +++++++++++++++++++++++++++++---------
 1 file changed, 48 insertions(+), 14 deletions(-)

diff --git a/www/members/member_nominations.cgi 
b/www/members/member_nominations.cgi
index 77a70783..1183ca8c 100755
--- a/www/members/member_nominations.cgi
+++ b/www/members/member_nominations.cgi
@@ -10,6 +10,7 @@ require 'whimsy/asf/member-files'
 require 'whimsy/asf/wunderbar_updates'
 require 'whimsy/asf/meeting-util'
 require 'whimsy/asf/time-utils'
+require 'mail'
 
 # Countdown until nominations for current meeting close
 t_now = Time.now.to_i
@@ -57,14 +58,6 @@ def process_form(formdata: {}, wunderbar: {})
   statement = formdata['statement']
   uid = formdata['availid']
 
-  _h3 'Copy of statement to put in an email (if necessary)'
-  _pre do
-    _ "[MEMBER NOMINATION] #{ASF::Person.new(uid).public_name} (#{uid})\n"
-    _ statement
-  end
-
-  _hr
-
   _h3 'Transcript of update to nomination file'
   entry = ASF::MemberFiles.make_member_nomination({
     availid: uid,
@@ -78,6 +71,45 @@ def process_form(formdata: {}, wunderbar: {})
   return true
 end
 
+# Send email to members@ with this nomination's data
+# Return true if we think mail was sent
+def send_nomination_mail(formdata: {})
+  uid = formdata['availid']
+  public_name = ASF::Person.new(uid).public_name
+  secby = formdata.fetch('secby', nil)
+  nomseconds = ''
+  if secby
+    nomseconds = "Nomination seconded by: #{secby}"
+  end
+  mail_body = <<-MAILBODY
+The following nomination for #{ASF::Person.new(uid).public_name} (#{uid}) as a 
New Member Candidate
+has been added:
+
+#{formdata['statement']}
+
+#{nomseconds}
+
+--
+- #{$USER}"
+  Sent by Whimsy; see data in Meetings: #{NOMINATED_MEMBERS}
+
+MAILBODY
+
+  ASF::Mail.configure
+  mail = Mail.new do
+    to "[email protected]" # FIXME TESTING
+    from $USER
+    subject "[MEMBER NOMINATION] #{ASF::Person.new(uid).public_name} 
(#{uid})\n"
+    text_part do
+      body mail_body
+    end
+  end
+    mail.deliver!
+    return "The following email was just sent on your behalf:\n\n#{mail_body}"
+  end
+  return "WARNING: mail not sent!"
+end
+
 # Produce HTML
 _html do
   _body? do # The ? traps errors inside this block
@@ -94,10 +126,10 @@ _html do
       helpblock: -> {
         _h3 'BETA - please report any errors to the Whimsy PMC!'
         _p %{
-          This form can be used to ADD entries to the nominated-members.txt 
file.
-          This is currently for use by the Nominator only, and does not yet 
send a copy
-          of the nomination to the members list.
-          There is currently no support for updating an existing entry.
+          This form can be used to nominate new candidates for ASF Membership 
if they are already committers.
+          It automatically adds an entry to to the nominated-members.txt file,
+          and then will send an email to the members@ list with your 
nomination.
+          There is currently no support for updating an existing entry or for 
adding seconds.
         }
       }
     ) do
@@ -120,8 +152,10 @@ _html do
             end
           elsif valid == 'OK'
             if process_form(formdata: submission, wunderbar: _)
-              _p.lead "Your nomination was submitted to svn."
-              # TODO Also send mail to members@ with this data (to complete 
process)
+              _p.lead "Your nomination was submitted to svn; now sending 
email."
+              mailval = send_nomination_mail(formdata: submission)
+              _p mailval
+              end
             else
               _div.alert.alert_warning role: 'alert' do
                 _p "SORRY! Your submitted form data failed process_form, 
please try again."

Reply via email to