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 a55d5cc6 Add error reporting for failed mailing
a55d5cc6 is described below

commit a55d5cc6b028d0a5e1a116124649b102b4159262
Author: Shane Curcuru <[email protected]>
AuthorDate: Tue Jan 28 13:33:50 2025 -0500

    Add error reporting for failed mailing
---
 www/members/nominate_board.cgi  | 35 ++++++++++++++++++++----
 www/members/nominate_member.cgi | 60 +++++++++++++++++++++++++++++++----------
 2 files changed, 76 insertions(+), 19 deletions(-)

diff --git a/www/members/nominate_board.cgi b/www/members/nominate_board.cgi
index dd638bc1..4f45fe33 100755
--- a/www/members/nominate_board.cgi
+++ b/www/members/nominate_board.cgi
@@ -85,13 +85,13 @@ def process_form(formdata: {}, wunderbar: {})
 end
 
 # Send email to members@ with this nomination's data
-# Return status string if we think mail was sent
+# Reports status to user in a _div
 def send_nomination_mail(formdata: {})
   uid = formdata['availid']
   nomby = formdata['nomby']
   public_name = ASF::Person.new(uid).public_name
   secby = formdata.fetch('secby', nil)
-  secby.nil? ? nomseconds = '' : nomseconds = "Nomination seconded by: 
#{secby}" unless secby.nil?
+  secby.nil? || secby.empty? ? nomseconds = '' : nomseconds = "Nomination 
seconded by: #{secby}"
   mail_body = <<-MAILBODY
 This nomination for #{public_name} (#{uid}) as a Director
 Nominee has been added:
@@ -105,19 +105,44 @@ Nominee has been added:
   Email generated by Whimsy (#{File.basename(__FILE__)})
 
 MAILBODY
+mailsubject = "[BOARD NOMINATION] #{ASF::Person.new(uid).public_name} (#{uid})"
 
   ASF::Mail.configure
   mail = Mail.new do
     to MAILING_LIST
     bcc '[email protected]'
     from "#{ASF::Person[nomby].public_name} <#{nomby}@apache.org>"
-    subject "[BOARD NOMINATION] #{ASF::Person.new(uid).public_name} (#{uid})"
+    subject mailsubject
     text_part do
       body mail_body
     end
   end
-  mail.deliver!
-  return "The following email was sent to #{MAILING_LIST}:\n\n#{mail_body}"
+  begin
+    mail.deliver!
+  rescue StandardError => e
+    _div.alert.alert_danger role: 'alert' do
+      _p.strong "ERROR: email was NOT sent due to: #{e.message} 
#{e.backtrace[0]}"
+      _p do
+        _ "To: #{MAILING_LIST}"
+        _br
+        _ "Subject: #{mailsubject}"
+        _br
+        _ "#{mail_body}"
+      end
+    end
+    return
+  end
+  _div.alert.alert_success role: 'alert' do
+    _p "The following email was sent:"
+    _p do
+      _ "To: #{MAILING_LIST}"
+      _br
+      _ "Subject: #{mailsubject}"
+      _br
+      _ "#{mail_body}"
+    end
+  end
+  return
 end
 
 # Produce HTML
diff --git a/www/members/nominate_member.cgi b/www/members/nominate_member.cgi
index 074ea887..2c658d12 100755
--- a/www/members/nominate_member.cgi
+++ b/www/members/nominate_member.cgi
@@ -18,7 +18,6 @@ NOMINATION_FILE = 'nominated-members.txt'
 def emit_form(title, prev_data)
   _whimsy_panel(title, style: 'panel-success') do
     _form.form_horizontal method: 'post' do
-      _whimsy_forms_subhead(label: 'New Member Nomination Form')
       field = 'availid'
       _whimsy_forms_input(label: 'Nominee availid', name: field,
         value: prev_data[field], helptext: 'Enter the availid of the committer 
you are nominating for ASF Membership'
@@ -68,13 +67,13 @@ def process_form(formdata: {}, wunderbar: {})
 end
 
 # Send email to members@ with this nomination's data
-# Return status string if we think mail was sent
+# Reports status to user in a _div
 def send_nomination_mail(formdata: {})
   uid = formdata['availid']
   nomby = formdata['nomby']
   public_name = ASF::Person.new(uid).public_name
   secby = formdata.fetch('secby', nil)
-  secby.nil? ? nomseconds = '' : nomseconds = "Nomination seconded by: 
#{secby}" unless secby.nil?
+  secby.nil? || secby.empty? ? nomseconds = '' : nomseconds = "Nomination 
seconded by: #{secby}"
   mail_body = <<-MAILBODY
 This nomination for #{public_name} (#{uid}) as a New Member
 Candidate has been added:
@@ -88,19 +87,44 @@ Candidate has been added:
   Email generated by Whimsy (#{File.basename(__FILE__)})
 
 MAILBODY
+mailsubject = "[MEMBER NOMINATION] #{ASF::Person.new(uid).public_name} 
(#{uid})"
 
   ASF::Mail.configure
   mail = Mail.new do
     to MAILING_LIST
     bcc '[email protected]'
     from "#{ASF::Person[nomby].public_name} <#{nomby}@apache.org>"
-    subject "[MEMBER NOMINATION] #{ASF::Person.new(uid).public_name} (#{uid})"
+    subject mailsubject
     text_part do
       body mail_body
     end
   end
-  mail.deliver!
-  return "The following email was sent to #{MAILING_LIST}:\n\n#{mail_body}"
+  begin
+    mail.deliver!
+  rescue StandardError => e
+    _div.alert.alert_danger role: 'alert' do
+      _p.strong "ERROR: email was NOT sent due to: #{e.message} 
#{e.backtrace[0]}"
+      _p do
+        _ "To: #{MAILING_LIST}"
+        _br
+        _ "Subject: #{mailsubject}"
+        _br
+        _ "#{mail_body}"
+      end
+    end
+    return
+  end
+  _div.alert.alert_success role: 'alert' do
+    _p "The following email was sent:"
+    _p do
+      _ "To: #{MAILING_LIST}"
+      _br
+      _ "Subject: #{mailsubject}"
+      _br
+      _ "#{mail_body}"
+    end
+  end
+  return
 end
 
 # Produce HTML
@@ -117,25 +141,33 @@ _html do
       subtitle: 'About This Script',
       related: {
         'meeting.cgi' => 'Member Meeting FAQ and info',
+        '/roster/committer/' => 'Lookup any committer availID',
         'memberless-pmcs.cgi' => 'PMCs with no/few ASF Members',
         'watch.cgi' => 'Watch list for potential Member candidates',
-        'check_membernoms.cgi' => "Member nominations cross-check - ensuring 
nominations get on the ballot, etc.",
+        'check_membernoms.cgi' => 'Cross-check existing Member nominations',
         ASF::SVN.svnpath!('Meetings') => 'Official Meeting Agenda Directory'
       },
       helpblock: -> {
         _h3 'TESTING - please report any errors at private@whimsical!'
         _b "For: #{timelines['meeting_type']} Meeting on: 
#{timelines['meeting_iso']}"
-        _p %Q{
-          This form can be used to nominate new candidates for ASF Membership 
if they are already committers.
-          It automatically adds an entry to the #{NOMINATION_FILE} 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; use SVN for that.
-        }
+        _p do
+          _ %Q{
+            Use this form to nominate any Committer the new ASF Membership 
election.
+            It automatically adds a properly formatted nomination to the 
#{NOMINATION_FILE} file,
+            and will then 
+          }
+          _strong 'send an email to the members@ list'
+          _ ' from you with the nomination, '
+          _a 'as is tradition.', href: 
'https://lists.apache.org/[email protected]:2023-2:%22BOARD%20NOMINATION%22'
+          _ ' This form only supports adding new nominations of existing 
committers; to add seconds or comments, please use SVN.  To nominate a 
non-committer, add them manually and use use n/a for the id. '
+          _a 'Lookup committer availIDs', href: '/roster/committer/'
+        end
       }
     ) do
 
       if nomclosed
         _h1 'Nominations are now closed!'
+        _p 'Sorry, no futher nominations will be accepted for ballots at this 
meeting.'
       else
         _h3 "Nominations close in #{ASFTime.secs2text(t_end - t_now)} at 
#{Time.at(t_end).utc} for Meeting: #{timelines['meeting_iso']}"
       end
@@ -176,7 +208,7 @@ _html do
             end
           end
         else # if _.post?
-          emit_form('Enter one New Member nomination', {})
+          emit_form('Enter your New Member nomination', {})
         end
       end
     end

Reply via email to