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 dab4fc89 Add check for required items
dab4fc89 is described below
commit dab4fc89c62393f8db5020a986144da5881fa244
Author: Sebb <[email protected]>
AuthorDate: Wed Mar 22 23:34:12 2023 +0000
Add check for required items
---
www/roster/views/actions/memtext.json.rb | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/www/roster/views/actions/memtext.json.rb
b/www/roster/views/actions/memtext.json.rb
index fcacefdc..d05ac24e 100644
--- a/www/roster/views/actions/memtext.json.rb
+++ b/www/roster/views/actions/memtext.json.rb
@@ -1,6 +1,13 @@
-# get entry for @userid
-entry = ASF::Person.find(@userid).members_txt(true)
-raise Exception.new("unable to find member entry for #{userid}") unless entry
+# validate new entry
+new_entry = @entry.strip
+unless new_entry.include? "Forms on File: ASF Membership Application\n" and
+ new_entry.include? "Avail ID: #{@userid}\n"
+ raise Exception.new('Missing required item: Avail ID and/or Forms')
+end
+
+# get existing entry for @userid
+old_entry = ASF::Person.find(@userid).members_txt(true)
+raise Exception.new("unable to find member entry for #{userid}") unless
old_entry
# identify file to be updated
members_txt = File.join(ASF::SVN['foundation'], 'members.txt')
@@ -11,7 +18,7 @@ message = "Update entry for
#{ASF::Person.find(@userid).member_name}"
# update members.txt
_svn.update members_txt, message: message do |dir, text|
# replace entry
- unless text.sub! entry, " *) #{@entry.strip}\n\n" # e.g. if the workspace
was out of date
+ unless text.sub! old_entry, " *) #{new_entry}\n\n" # e.g. if the workspace
was out of date
raise Exception.new("Failed to replace existing entry -- try refreshing")
end