This is an automated email from the ASF dual-hosted git repository.

clr 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 304a024  Add validation on client for vote and notice links
304a024 is described below

commit 304a02435d3f83c90dab85b0692e548a95e99b9b
Author: Craig L Russell <[email protected]>
AuthorDate: Sat Nov 18 15:43:07 2017 -0800

    Add validation on client for vote and notice links
---
 www/project/icla/main.rb                        |  5 +++
 www/project/icla/views/actions/validate.json.rb | 17 ++++++----
 www/project/icla/views/app.html.rb              |  2 +-
 www/project/icla/views/pages/invite.js.rb       | 44 ++++++++++++++++++++++++-
 4 files changed, 59 insertions(+), 9 deletions(-)

diff --git a/www/project/icla/main.rb b/www/project/icla/main.rb
index 4ba16fb..26a6cf6 100755
--- a/www/project/icla/main.rb
+++ b/www/project/icla/main.rb
@@ -37,6 +37,11 @@ get '/invite' do
   @pmcs.select! {|pmc| committees.include?(pmc)}
   @ppmcs.select! {|ppmc| committees.include?('incubator') | 
committees.include?(ppmc)}
 
+  # make a map of pmc name to pmc mail_list for validation of votes
+  @pmc_mail = {}
+  ASF::Committee.pmcs.each { |pmc| @pmc_mail[pmc.name] = pmc.mail_list}
+  ASF::Podling.list.each { |ppmc| @pmc_mail[ppmc.name] = ppmc.mail_list}
+
   # render the HTML for the application
   _html :app
 end
diff --git a/www/project/icla/views/actions/validate.json.rb 
b/www/project/icla/views/actions/validate.json.rb
index 87483bf..a146c4d 100644
--- a/www/project/icla/views/actions/validate.json.rb
+++ b/www/project/icla/views/actions/validate.json.rb
@@ -35,6 +35,7 @@ go through the patch submission process.
 Being a committer does not require you to participate any more than you already
 do, but it does tend to make one even more committed ;-) You will probably find
 that you spend more time here.
+
 "
 
 prototype_pmc =
@@ -53,6 +54,13 @@ https://incubator.apache.org/guides/ppmc.html
 
 "
 
+prototype_committer_or_pmc =
+"Of course, you can decline and instead remain as a contributor, participating
+as you do now.
+
+This personal invitation is a chance for you to accept or decline in private.
+Either way, please let us know in reply to the private@ address only.
+"
 # validate email address
 begin
   Socket.getaddrinfo(@iclaemail[/@(.*)/, 1].untaint, 'smtp')
@@ -147,15 +155,10 @@ _token token
 _invitation %{Dear #{@iclaname},
 
 #{prototype_contributor if @votelink.empty?}\
-#{prototype_committer if not @votelink.empty?}
+#{prototype_committer if not @votelink.empty?}\
 #{prototype_pmc if not @noticelink.empty? and (pmc_type == 'PMC')}\
 #{prototype_ppmc if not @noticelink.empty? and (pmc_type == 'PPMC')}\
-Of course, you can decline and instead remain as a contributor, participating
-as you do now.
-
-This personal invitation is a chance for you to accept or decline in private.
-Either way, please let us know in reply to the private@ address only.
-
+#{prototype_committer_or_pmc if not @votelink.empty?}
 Click on this link to accept:
 #{link}
 
diff --git a/www/project/icla/views/app.html.rb 
b/www/project/icla/views/app.html.rb
index b357df9..74a7fd7 100755
--- a/www/project/icla/views/app.html.rb
+++ b/www/project/icla/views/app.html.rb
@@ -373,7 +373,7 @@ _html lang: 'en', _width: '80' do
     _script src: 'app.js'
 
     _.render '#main' do
-      _Main data: {pmcs: @pmcs, ppmcs: @ppmcs}, view: @view
+      _Main data: {pmcs: @pmcs, ppmcs: @ppmcs, pmc_mail: @pmc_mail}, view: 
@view
     end
   end
 end
diff --git a/www/project/icla/views/pages/invite.js.rb 
b/www/project/icla/views/pages/invite.js.rb
index 40135fe..c983d39 100644
--- a/www/project/icla/views/pages/invite.js.rb
+++ b/www/project/icla/views/pages/invite.js.rb
@@ -13,8 +13,12 @@ class Invite < Vue
 # initialize conditional text
     @showPMCVoteLink = false;
     @showPPMCVoteLink = false;
+    @voteErrorMessage = '';
+    @showVoteErrorMessage = false;
     @showPMCNoticeLink = false;
     @showPPMCNoticeLink = false;
+    @noticeErrorMessage = '';
+    @showNoticeErrorMessage = false;
 
   end
 
@@ -93,6 +97,10 @@ class Invite < Vue
         _input.form_control.votelink! type: 'url', onChange: self.setVoteLink,
         value: @votelink
       end
+      if @showVoteErrorMessage
+        _p "#@voteErrorMessage"
+      end
+
     end
     if @showPMCNoticeLink
       _p %{
@@ -117,6 +125,9 @@ class Invite < Vue
         value: @noticelink
       end
     end
+    if @showNoticeErrorMessage
+      _p "#@noticeErrorMessage"
+    end
     #
     # Submission button
     #
@@ -196,16 +207,47 @@ class Invite < Vue
     @showPPMCVoteLink = Server.data.ppmcs.include? @pmc
     @showPMCNoticeLink = Server.data.pmcs.include? @pmc
     @showPPMCNoticeLink = Server.data.ppmcs.include? @pmc
+    @showVoteErrorMessage = false;
+    @showNoticeErrorMessage = false;
     self.checkValidity()
   end
 
   def setVoteLink(event)
     @votelink = event.target.value
+    @showVoteErrorMessage = false
+    # verify that the link refers to lists.apache.org message on the project 
list
+    if not @votelink=~ /.*lists\.apache\.org.*/
+      @voteErrorMessage = "Error: Please link to\
+      a message via lists.apache.org"
+      @showVoteErrorMessage = true;
+    end
+    if not @votelink=~ 
/.*#{Server.data.pmc_mail[@pmc]}(\.incubator)?\.apache\.org.*/
+      @voteErrorMessage = "Error: Please link to\
+      the [RESULT][VOTE] message sent to the private list."
+      @showVoteErrorMessage = true;
+    end
     self.checkValidity()
   end
 
   def setNoticeLink(event)
     @noticelink = event.target.value
+    @showNoticeErrorMessage = false;
+    # verify that the link refers to lists.apache.org message on the proper 
list
+    if not @noticelink=~ /.*lists\.apache\.org.*/
+      @noticeErrorMessage = "Error: please link to\
+      a message via lists.apache.org"
+      @showNoticeErrorMessage = true;
+    end
+    if @showPMCNoticeLink and not @noticelink=~ /.*board@apache\.org.*/
+      @noticeErrorMessage = "Error: please link to\
+      the NOTICE message sent to the board list."
+      @showNoticeErrorMessage = true;
+    end
+    if @showPPMCNoticeLink and not @noticelink=~ 
/.*private@incubator\.apache\.org.*/
+      @noticeErrorMessage = "Error: please link to\
+      the NOTICE message sent to the incubator private list."
+      @showNoticeErrorMessage = true;
+    end
     self.checkValidity()
   end
 
@@ -220,7 +262,7 @@ class Invite < Vue
 
   # client side field validations
   def checkValidity()
-    @disabled = !%w(iclaname iclaemail pmc).all? do |id|
+    @disabled = !%w(iclaname iclaemail pmc votelink noticelink).all? do |id|
       document.getElementById(id).checkValidity()
     end
   end

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to