whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Add ICLA PDF parsing
Date Tue, 26 Nov 2019 21:54:15 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb 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 0ea78a8  Add ICLA PDF parsing
0ea78a8 is described below

commit 0ea78a8cf4e2040f6c72ea007285bd36ab94affb
Author: Sebb <sebb@apache.org>
AuthorDate: Tue Nov 26 21:54:09 2019 +0000

    Add ICLA PDF parsing
---
 .../workbench/views/actions/parse-icla.json.rb     | 16 +++++++++++++
 www/secretary/workbench/views/forms/icla.js.rb     | 28 +++++++++++++++++-----
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/www/secretary/workbench/views/actions/parse-icla.json.rb b/www/secretary/workbench/views/actions/parse-icla.json.rb
new file mode 100644
index 0000000..d07162f
--- /dev/null
+++ b/www/secretary/workbench/views/actions/parse-icla.json.rb
@@ -0,0 +1,16 @@
+# parse an icla from a PDF
+
+require_relative '../../../iclaparser'
+require_relative '../../models/mailbox'
+
+if @attachment.end_with? '.pdf'
+  message = Mailbox.find(@message)
+  
+  path = message.find(@attachment).as_file.path
+  
+  parsed = ICLAParser.parse(path)
+else
+  parsed = {}
+end
+
+{parsed: parsed}
\ No newline at end of file
diff --git a/www/secretary/workbench/views/forms/icla.js.rb b/www/secretary/workbench/views/forms/icla.js.rb
index 1f500ef..fa4e2ac 100644
--- a/www/secretary/workbench/views/forms/icla.js.rb
+++ b/www/secretary/workbench/views/forms/icla.js.rb
@@ -11,6 +11,8 @@ class ICLA < Vue
     _div.buttons do
       _button 'clear form', disabled: @filed,
         onClick: -> {@pubname = @realname = @email = @filename = ''}
+      _button 'revert to mail data', disabled: @filed,
+        onClick: -> {process_response({})}
     end
 
     _form method: 'post', action: '../../tasklist/icla', target: 'content' do
@@ -87,10 +89,9 @@ class ICLA < Vue
     end
   end
 
-  # on initial display, default various fields based on headers, and update
-  # state 
-  def mounted()
-    name = @@headers.name || ''
+  # needs to be called even if post fails
+  def process_response(parsed)
+    name = parsed.FullName || @@headers.name || ''
 
     # reorder name if there is a single comma present
     parts = name.split(',')
@@ -99,9 +100,24 @@ class ICLA < Vue
     end
 
     @realname = name
-    @pubname = name
+    @pubname = parsed.PublicName || name
     @filename = self.genfilename(name)
-    @email = @@headers.from
+    @email = parsed.EMail || @@headers.from
+    @user = parsed.ApacheID || ''
+    @project = parsed.Project
+  end
+
+  # on initial display, default various fields based on headers, and update
+  # state 
+  def mounted()
+    # Parse the ICLA if possible
+    data = {message: window.parent.location.pathname, attachment: @@selected}
+    HTTP.post('../../actions/parse-icla', data).then {|result|
+          process_response(result.parsed)
+        }.catch {|message|
+          process_response({})
+          alert message
+        }
 
     # watch for status updates
     window.addEventListener 'message', self.status_update


Mime
View raw message