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: Add initial work on member emeritus request tool
Date Sun, 05 Apr 2020 00:05:37 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 c63de56  Add initial work on member emeritus request tool
     new 0875e6a  Merge pull request #89 from jvz/emeritus-request
c63de56 is described below

commit c63de56d8f9ff95d5ba3c5a882b489cfe5adffd2
Author: Matt Sicker <boards@gmail.com>
AuthorDate: Sat Apr 4 18:37:00 2020 -0500

    Add initial work on member emeritus request tool
---
 lib/whimsy/asf/documents.rb                        |  7 ++
 repository.yml                                     |  5 ++
 www/secretary/workbench/server.rb                  | 14 +++-
 .../views/actions/emeritus-request.json.rb         | 38 +++++++++
 www/secretary/workbench/views/app.js.rb            |  1 +
 .../workbench/views/forms/emeritus-request.js.rb   | 90 ++++++++++++++++++++++
 www/secretary/workbench/views/parts.js.rb          |  6 ++
 7 files changed, 160 insertions(+), 1 deletion(-)

diff --git a/lib/whimsy/asf/documents.rb b/lib/whimsy/asf/documents.rb
index f3b4978..25bf74d 100644
--- a/lib/whimsy/asf/documents.rb
+++ b/lib/whimsy/asf/documents.rb
@@ -74,4 +74,11 @@ module ASF
     end
   end
 
+  class EmeritusRequestFiles
+    def self.listnames
+      _, list = ASF::SVN.getlisting('emeritus-requests-received')
+      list
+    end
+  end
+
 end
diff --git a/repository.yml b/repository.yml
index 2826dda..c960b2f 100644
--- a/repository.yml
+++ b/repository.yml
@@ -95,6 +95,11 @@
     depth: delete
     list: true
 
+  emeritus-requests-received:
+    url: private/documents/emeritus-requests-received
+    depth: delete
+    list: true
+
   minutes:
     url: asf/infrastructure/site/trunk/content/foundation/records/minutes
 
diff --git a/www/secretary/workbench/server.rb b/www/secretary/workbench/server.rb
index c05dc30..7fd4768 100644
--- a/www/secretary/workbench/server.rb
+++ b/www/secretary/workbench/server.rb
@@ -32,7 +32,7 @@ module Mail
   module Utilities
     def self.safe_for_line_ending_conversion?(string)
       if RUBY_VERSION >= '1.9'
-        string.ascii_only? or 
+        string.ascii_only? or
           (string.encoding != Encoding::BINARY and string.valid_encoding?)
       else
         string.ascii_only?
@@ -235,6 +235,18 @@ get '/iclas.json' do
   list.to_json
 end
 
+# return a list of members
+get '/members.json' do
+  list = []
+  ASF::Member.list.each do |id, data|
+    list << {
+        id: id,
+        name: data[:name]
+    }
+  end
+  _json list
+end
+
 # redirect to an icla
 get %r{/icla/(.*)} do |filename|
   checkout = 'https://svn.apache.org/repos/private/documents/iclas'
diff --git a/www/secretary/workbench/views/actions/emeritus-request.json.rb b/www/secretary/workbench/views/actions/emeritus-request.json.rb
new file mode 100644
index 0000000..8d6b61e
--- /dev/null
+++ b/www/secretary/workbench/views/actions/emeritus-request.json.rb
@@ -0,0 +1,38 @@
+#
+# Files a member emeritus request
+# - add files to documents/emeritus-requests-received
+# - (?) add entry to some file
+# - respond to original email
+#
+
+# extract message
+message = Mailbox.find(@message)
+
+# extract file extension
+fileext = File.extname(@selected).downcase if @signature.empty?
+
+# verify that a membership emeritus request under that name stem doesn't already exist
+emeritus_request = "#{@filename}#{fileext}"
+if emeritus_request =~ /\A\w[-\w]*\.?\w*\z/ # check taint requirements
+  names = ASF::EmeritusRequestFiles.listnames
+  if names.include? @filename.untaint
+    _warn "documents/emeritus-requests-received/#{@filename} already exists"
+  elsif names.include? emeritus_request.untaint
+    _warn "documents/emeritus-requests-received/#{emeritus_request} already exists"
+  end
+else
+  _warn "#{emeritus_request} is not a valid file name"
+end
+
+# obtain per-user information
+_personalize_email(env.user)
+
+task 'hello, world!' do
+  form do
+    _message message.to_s
+  end
+
+  complete do
+    _message 'TODO'
+  end
+end
diff --git a/www/secretary/workbench/views/app.js.rb b/www/secretary/workbench/views/app.js.rb
index 92b2944..d5b70cf 100644
--- a/www/secretary/workbench/views/app.js.rb
+++ b/www/secretary/workbench/views/app.js.rb
@@ -16,3 +16,4 @@ require_relative 'forms/forward'
 require_relative 'forms/memapp'
 require_relative 'forms/nda'
 require_relative 'forms/note'
+require_relative 'forms/emeritus-request'
diff --git a/www/secretary/workbench/views/forms/emeritus-request.js.rb b/www/secretary/workbench/views/forms/emeritus-request.js.rb
new file mode 100644
index 0000000..99a319b
--- /dev/null
+++ b/www/secretary/workbench/views/forms/emeritus-request.js.rb
@@ -0,0 +1,90 @@
+class EmeritusRequest < Vue
+  def initialize
+    @filed = false
+    @filename = ''
+    @disabled = false
+    @search = ''
+    @members = []
+    @member = nil
+  end
+
+  def mounted
+    if not @members.empty?
+      @disabled = false
+    else
+      @disabled = true
+      fetch('../../members.json', {method: 'get', credentials: 'include', headers: {accept:
'application/json'}})
+          .then do |response|
+        response.json().then do |json|
+          @members = json
+          @disabled = true
+        end
+      end
+    end
+
+    name = @@headers.name || ''
+    # reorder name if there is a single comma present
+    parts = name.split(',')
+    if parts.length == 2 and parts[1] !~ /^\s*(jr|ph\.d)\.?$/i
+      name = "#{parts[1].strip()} #{parts[0]}"
+    end
+    @search = name
+    @filename = self.gen_file_name(name)
+  end
+
+  def render
+    _h4 'Member Emeritus Request'
+
+    _form.form do
+      _h5 'Search'
+      _table.form do
+        _tr do
+          _input value: @search
+        end
+      end
+    end
+
+    if @search.length >= 3 and not @members.empty?
+      search = @search.downcase().split(' ')
+      _ul.icla_search do
+        @members.each do |member|
+          if search.all? { |part| member.id.include? part or member.name.downcase().include?
part }
+            _li do
+              _input type: :radio, name: 'member', value: member.id, id: member.id, onClick:
lambda {
+                @member = member
+                @filename = self.gen_file_name(member.name)
+              }
+              _label member.name, for: member.id
+            end
+          end
+        end
+      end
+    end
+
+    _form method: 'post', action: '../../tasklist/emeritus-request', target: 'content' do
+      _input type: :hidden, name: 'message'
+      _input type: :hidden, name: 'selected'
+      _input type: :hidden, name: 'signature', value: @@signature
+
+      _table.form do
+        _tr do
+          _th 'File Name'
+          _td do
+            _input type: :text, name: 'filename', value: @filename, required: true, disabled:
@filed,
+                   pattern: '[a-zA-Z][-\w]+(\.[a-z]+)?'
+          end
+        end
+      end
+
+      _input.btn.btn_primary value: 'File', type: :submit, disabled: @disabled
+    end
+  end
+
+  def updated
+    jQuery('input[name=selected]').val(decodeURI(@@selected))
+  end
+
+  def gen_file_name(name)
+    asciize(name.strip()).downcase().gsub(/\W+/, '-')
+  end
+end
\ No newline at end of file
diff --git a/www/secretary/workbench/views/parts.js.rb b/www/secretary/workbench/views/parts.js.rb
index c40521c..a773dd2 100644
--- a/www/secretary/workbench/views/parts.js.rb
+++ b/www/secretary/workbench/views/parts.js.rb
@@ -139,6 +139,12 @@ class Parts < Vue
             end
           end
 
+          _label do
+            _input type: :radio, name: 'doctype', value: 'emeritus-request',
+                   onClick: -> {@form = EmeritusRequest}
+            _span 'emeritus request'
+          end
+
           _hr
 
           # reject message with message


Mime
View raw message