whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject [whimsy.git] [1/1] Commit f5e3d17: add a dry run button
Date Thu, 28 Jan 2016 12:25:41 GMT
Commit f5e3d17f40f0db344e38489ef27c76f9fd5a2886:
    add a dry run button


Branch: refs/heads/master
Author: Sam Ruby <rubys@intertwingly.net>
Committer: Sam Ruby <rubys@intertwingly.net>
Pusher: rubys <rubys@apache.org>

------------------------------------------------------------
www/board/agenda/views/actions/send-reminders.json.rb        | +++++ ----
www/board/agenda/views/buttons/reminders.js.rb               | ++++++ 
------------------------------------------------------------
15 changes: 11 additions, 4 deletions.
------------------------------------------------------------


diff --git a/www/board/agenda/views/actions/send-reminders.json.rb b/www/board/agenda/views/actions/send-reminders.json.rb
index e0619d1..b243a7e 100644
--- a/www/board/agenda/views/actions/send-reminders.json.rb
+++ b/www/board/agenda/views/actions/send-reminders.json.rb
@@ -2,7 +2,7 @@
 # send reminders
 #
 
-sent = []
+sent = {}
 
 # utilize smtp without certificate verification
 Mail.defaults do
@@ -17,6 +17,7 @@
 # iterate over the agenda
 Agenda.parse(@agenda, :full).each do |item|
   next unless @pmcs.include? item['title']
+  next unless item['chair_email']
 
   # substitute [whoTo] values
   if item['to'] == 'president'
@@ -49,9 +50,9 @@
   end
 
   # deliver mail
-  mail.deliver!
-  sent << item['title']
+  mail.deliver! unless @dryrun
+  sent[item['title']] = mail.to_s
 end
 
 # provide a response to the request
-{count: sent.length, unsent: @pmcs - sent}
+{count: sent.length, unsent: @pmcs - sent.keys, sent: sent, dryrun: @dryrun}
diff --git a/www/board/agenda/views/buttons/reminders.js.rb b/www/board/agenda/views/buttons/reminders.js.rb
index d7493f9..cfd485c 100644
--- a/www/board/agenda/views/buttons/reminders.js.rb
+++ b/www/board/agenda/views/buttons/reminders.js.rb
@@ -60,6 +60,7 @@ def render
 
       # buttons
       _button.btn_default 'Close', data_dismiss: 'modal'
+      _button.btn_info 'Dry Run', onClick: self.click, disabled: @disabled
       _button.btn_primary 'Submit', onClick: self.click, disabled: @disabled
     end
   end
@@ -67,9 +68,11 @@ def render
   # on click, disable the input fields and buttons and submit
   def click(event)
     @disabled = true
+    dryrun = (event.target.textContent == 'Dry Run')
 
     # data to be sent to the server
     data = {
+      dryrun: dryrun,
       agenda: Agenda.file,
       subject: @subject,
       message: @message,
@@ -84,6 +87,9 @@ def click(event)
     post 'send-reminders', data do |response|
       if not response
         alert("Server error - check console log")
+      elsif dryrun
+        console.log response
+        alert("Dry run - check console log")
       elsif response.count == data.pmcs.length
         alert("Reminders have been sent to: #{data.pmcs.join(', ')}.")
       elsif response.count and response.unsent

Mime
View raw message