whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: rough in additional ICLA support
Date Wed, 14 Jun 2017 01:25:36 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys 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 7489002  rough in additional ICLA support
7489002 is described below

commit 748900267de3f132609ecee77a7fd59c24941eeb
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Tue Jun 13 21:25:08 2017 -0400

    rough in additional ICLA support
---
 www/secretary/workbench/templates/icla2.erb        |  10 +++
 .../workbench/views/actions/icla2.json.rb          | 100 +++++++++++++++------
 www/secretary/workbench/views/forms/icla2.js.rb    |   3 +-
 3 files changed, 87 insertions(+), 26 deletions(-)

diff --git a/www/secretary/workbench/templates/icla2.erb b/www/secretary/workbench/templates/icla2.erb
new file mode 100644
index 0000000..27afc5c
--- /dev/null
+++ b/www/secretary/workbench/templates/icla2.erb
@@ -0,0 +1,10 @@
+Dear <%= @pubname %>,
+
+This message acknowledges receipt of your additional ICLA, which has been filed in the Apache
Software Foundation records.
+
+You can change your password using https://id.apache.org .
+
+Warm Regards,
+
+<%= @sig %>
+
diff --git a/www/secretary/workbench/views/actions/icla2.json.rb b/www/secretary/workbench/views/actions/icla2.json.rb
index e02a279..cc3bd9f 100644
--- a/www/secretary/workbench/views/actions/icla2.json.rb
+++ b/www/secretary/workbench/views/actions/icla2.json.rb
@@ -9,6 +9,9 @@
 # extract message
 message = Mailbox.find(@message)
 
+# find person
+person = ASF::Person.find(@id)
+
 # extract file extension
 fileext = File.extname(@selected).downcase if @signature.empty?
 
@@ -57,8 +60,8 @@ end
 
 # determine initial value for the counter
 svndir = ASF::SVN['https://svn.apache.org/repos/private/documents/iclas']
-count = Dir["#{svndir}/#@filename/*"].
-      map {|name| name[/.*(\d+)\./, 1] || 1}.map(&:to_i).max + 1
+count = (Dir["#{svndir}/#@filename/*"].
+      map {|name| name[/.*(\d+)\./, 1] || 1}.map(&:to_i).max || 1) + 1
 
 # write attachment (+ signature, if present) to the documents/iclas directory
 task "svn commit documents/iclas/icla#{count}#{fileext}" do
@@ -100,13 +103,15 @@ end
 
 # insert line into iclas.txt
 task "svn commit foundation/officers/iclas.txt" do
+  icla = ASF::ICLA.find_by_id(@id)
+
   # construct line to be inserted
   @iclaline ||= [
-    'notinavail',
-    @realname.to_s.strip,
+    @id,
+    icla.legal_name,
     @pubname.strip,
     @email.strip,
-    "Signed CLA;#{@filename}"
+    icla.form
   ].join(':')
 
   form do
@@ -124,8 +129,9 @@ task "svn commit foundation/officers/iclas.txt" do
     svn 'update', dest
 
     # update iclas.txt
-    iclas_txt = ASF::ICLA.sort(File.read(dest) + @iclaline + "\n")
-    File.write dest, iclas_txt
+    iclas_txt = File.read(dest)
+    iclas_txt[/^#{@id}:.*/] = @iclaline
+    File.write dest, ASF::ICLA.sort(iclas_txt)
 
     # show the changes
     svn 'diff', dest
@@ -136,35 +142,51 @@ task "svn commit foundation/officers/iclas.txt" do
 end
 
 ########################################################################
-#                           email submitter                            #
+#                      update public name in LDAP                      #
 ########################################################################
 
-# send confirmation email
-task "email #@email" do
-  # chose reply based on whether or not the project/userid info was provided
-  if @user and not @user.empty?
-    reply = 'icla-account-requested.erb'
-  elsif @pmc
-    @notify = "the #{@pmc.display_name} PMC has"
-
-    if @podling
-      @notify.sub! /has$/, "and the #{@podling.display_name} podling have"
+if person.public_name != @pubname
+  task "change public name in LDAP" do
+    form do
+      _input value: @pubname, name: 'pubname'
     end
 
-    reply = 'icla-pmc-notified.erb'
-  else
-    reply = 'icla.erb'
+    complete do
+      ldap = ASF.init_ldap(true)
+
+      ldap.bind("uid=#{env.user.untaint},ou=people,dc=apache,dc=org",
+        env.password.untaint)
+
+      ldap.modify person.dn, [ASF::Base.mod_replace('cn', @pubname.strip)]
+
+      log = ["LDAP modify: #{ldap.err2string(ldap.err)} (#{ldap.err})"]
+      if ldap.err == 0
+        _transcript log
+      else
+        _backtrace log
+      end
+
+      ldap.unbind
+    end
   end
+end
+
+########################################################################
+#                           email submitter                            #
+########################################################################
+
+# send confirmation email
+task "email #@email" do
+  cc = person.all_mail.map {|email| "#{@pubname.inspect} <#{email}>"}
+  cc << 'secretary@apache.org'
 
   # build mail from template
   mail = message.reply(
     subject: "ICLA for #{@pubname}",
     from: @from,
     to: "#{@pubname.inspect} <#{@email}>",
-    cc: [
-      'secretary@apache.org',
-    ],
-    body: template(reply)
+    cc: cc,
+    body: template('icla2.erb')
   )
 
   # echo email
@@ -177,3 +199,31 @@ task "email #@email" do
     mail.deliver!
   end
 end
+
+########################################################################
+#                     update email address in LDAP                     #
+########################################################################
+
+task "change email address in LDAP" do
+  form do
+    _input value: @email, name: 'email'
+  end
+
+  complete do
+    ldap = ASF.init_ldap(true)
+
+    ldap.bind("uid=#{env.user.untaint},ou=people,dc=apache,dc=org",
+      env.password.untaint)
+
+    ldap.modify person.dn, [ASF::Base.mod_replace('mail', @email.strip)]
+
+    log = ["LDAP modify: #{ldap.err2string(ldap.err)} (#{ldap.err})"]
+    if ldap.err == 0
+      _transcript log
+    else
+      _backtrace log
+    end
+
+    ldap.unbind
+  end
+end
diff --git a/www/secretary/workbench/views/forms/icla2.js.rb b/www/secretary/workbench/views/forms/icla2.js.rb
index 7f36650..d0a798b 100644
--- a/www/secretary/workbench/views/forms/icla2.js.rb
+++ b/www/secretary/workbench/views/forms/icla2.js.rb
@@ -49,6 +49,7 @@ class ICLA2 < React
       _input type: 'hidden', name: 'selected'
       _input type: 'hidden', name: 'signature', value: @@signature
       _input type: 'hidden', name: 'filename', value: @icla && @icla.filename
+      _input type: 'hidden', name: 'id', value: @icla && @icla.id
 
       _h5 'Current values'
 
@@ -94,7 +95,7 @@ class ICLA2 < React
       end
 
       _input.btn.btn_primary value: 'File', type: 'submit', ref: 'file',
-        disabled: true
+        disabled: @submitted
     end
   end
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message