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 8b4cf5f Enable non-PMC updates
8b4cf5f is described below
commit 8b4cf5f2064ba00b78bcdbdcceaf8f531416706c
Author: Sebb <[email protected]>
AuthorDate: Sat Jun 1 23:22:48 2019 +0100
Enable non-PMC updates
---
www/roster/views/actions/nonpmc.json.rb | 139 ++++++++++++++++++++++++++++++++
www/roster/views/nonpmc/add.js.rb | 15 ----
www/roster/views/nonpmc/main.js.rb | 8 +-
www/roster/views/nonpmc/mod.js.rb | 15 ----
4 files changed, 142 insertions(+), 35 deletions(-)
diff --git a/www/roster/views/actions/nonpmc.json.rb
b/www/roster/views/actions/nonpmc.json.rb
new file mode 100644
index 0000000..bb8737b
--- /dev/null
+++ b/www/roster/views/actions/nonpmc.json.rb
@@ -0,0 +1,139 @@
+if env.password
+ pmc = ASF::Committee[@project]
+
+ # validate arguments
+ if @action == 'remove'
+ people = @ids.split(',').map {|id| ASF::Person.find(id)}
+ else
+ people = @ids.split(',').map {|id| ASF::Person[id]}
+ raise ArgumentError.new("One or more null entries found: '#{@ids}'") if
people.any? {|person| person.nil?}
+ end
+
+ # Don't allow empty list
+ raise ArgumentError.new("No valid entries found: '#{@ids}'") unless
people.length > 0
+
+ raise ArgumentError.new("project=#{@project}") unless pmc
+
+ # update LDAP
+ if @targets.include? 'pmc' or @targets.include? 'commit'
+ ASF::LDAP.bind(env.user, env.password) do
+ if @action == 'add'
+ pmc.add_owners(people) if @targets.include? 'pmc'
+ pmc.add_committers(people) if @targets.include? 'commit'
+ elsif @action == 'remove'
+ pmc.remove_owners(people) if @targets.include? 'pmc'
+ pmc.remove_committers(people) if @targets.include? 'commit'
+ end
+ end
+ end
+
+ # extract people's names (for short lists) or ids (for longer lists)
+ if people.length <= 2
+ who = people.map {|person| person.public_name || person.id}.join(' and ')
+ else
+ who = people[0..-2].map {|person| person.id}.join(', ') +
+ ', and ' + people.last.id
+ end
+
+ # update committee-info.txt
+ if @targets.include? 'info'
+ Dir.mktmpdir do |tmpdir|
+ # checkout committers/board
+ Kernel.system 'svn', 'checkout', '--quiet',
+ '--no-auth-cache', '--non-interactive',
+ '--username', env.user.untaint, '--password', env.password.untaint,
+ 'https://svn.apache.org/repos/private/committers/board', tmpdir.untaint
+
+ # read in committee-info.txt
+ file = File.join(tmpdir, 'committee-info.txt')
+ info = File.read(file)
+
+ info.scan(/^\* (?:.|\n)*?\n\s*?\n/).each do |block|
+ # find committee
+ next unless ASF::Committee.find(block[/\* (.*?)\s+\(/, 1]).id==@project
+
+ # split block into lines
+ lines = block.strip.split("\n")
+
+ # add or remove people
+ people.each do |person|
+ id = person.id
+ if @action == 'add'
+ unless lines.any? {|line| line.include? "<#{id}@apache.org>"}
+ name = "#{person.public_name.ljust(26)} <#{id}@apache.org>"
+ time = Time.new.gmtime.strftime('%Y-%m-%d')
+ lines << " #{name.ljust(59)} [#{time}]"
+ end
+ else
+ lines.reject! {|line| line.include? "<#{id}@apache.org>"}
+ end
+ end
+
+ # replace committee block with new information
+ info.sub! block, ([lines.shift] + lines.sort).join("\n") + "\n\n"
+ break
+ end
+
+ # write file out to disk
+ File.write(file, info)
+
+ # commit changes
+ rc = Kernel.system 'svn', 'commit', '--quiet',
+ '--no-auth-cache', '--non-interactive',
+ '--username', env.user.untaint, '--password', env.password.untaint,
+ tmpdir.untaint, '--message',
+ "#{@project} #{@action == 'add' ? '+' : '-'}= #{who}".untaint
+
+ if rc
+ # update cache
+ ASF::Committee.parse_committee_info(info)
+ else
+ # die
+ raise Exception.new('Update committee-info.txt failed')
+ end
+ end
+ end
+
+ # compose E-mail
+ action = (@action == 'add' ? 'added to' : 'removed from')
+ if @targets.include? 'pmc'
+ # must use () to enclose method parameter below as ? binds tighter
+ list = @targets.include?('commit') ? 'PMC and committers list' : 'PMC list'
+ elsif @targets.include? 'info'
+ list = 'in committee-info.txt'
+ else
+ list = 'committers list'
+ end
+
+ details = people.map {|person| person.dn}
+ details << "#{pmc.dn};attr=owner" if @targets.include? 'pmc'
+ details << "#{pmc.dn};attr=member" if @targets.include? 'commit'
+
+ cc = people.map do |person|
+ "#{person.public_name.inspect} <#{person.id}@apache.org>".untaint
+ end
+
+ from = ASF::Person.find(env.user)
+
+ # draft email
+ mail = Mail.new do
+ from "#{from.public_name} <#{from.id}@apache.org>".untaint
+ # TODO the email may need fixing
+ to "private@#{pmc.mail_list}.apache.org".untaint
+ cc cc
+ bcc "[email protected]"
+ subject "#{who} #{action} #{pmc.display_name} #{list}"
+ body "Current roster can be found at:\n\n" +
+ " https://whimsy.apache.org/roster/committee/#{pmc.id}\n\n" +
+ "LDAP details:\n\n #{details.join("\n ")}"
+ end
+
+ # Header for root@'s lovely email filters
+ mail.header['X-For-Root'] = 'yes'
+
+ # deliver email
+ mail.deliver!
+end
+
+# return updated nonPMC info to the client
+NonPMC.serialize(@project, env)
diff --git a/www/roster/views/nonpmc/add.js.rb
b/www/roster/views/nonpmc/add.js.rb
index 918d73a..320bf65 100644
--- a/www/roster/views/nonpmc/add.js.rb
+++ b/www/roster/views/nonpmc/add.js.rb
@@ -18,21 +18,6 @@ class NonPMCAdd < Vue
_button.close 'x', data_dismiss: 'modal'
_h4.modal_title 'Add People to the ' + @@project.display_name +
' Project'
- _br
- _p '***Not currently implemented***'
- end
- end
- end
- end
- end
- def norender
- _div.modal.fade id: $options.add_tag, tabindex: -1 do
- _div.modal_dialog do
- _div.modal_content do
- _div.modal_header.bg_info do
- _button.close 'x', data_dismiss: 'modal'
- _h4.modal_title 'Add People to the ' + @@project.display_name +
- ' Project'
_p {
_br
_b 'N.B'
diff --git a/www/roster/views/nonpmc/main.js.rb
b/www/roster/views/nonpmc/main.js.rb
index 2f6f161..e53336e 100644
--- a/www/roster/views/nonpmc/main.js.rb
+++ b/www/roster/views/nonpmc/main.js.rb
@@ -8,11 +8,9 @@ class NonPMC < Vue
end
def render
- # TODO establish the correct auth for non-PMCs - may not have LDAP
-# auth = (@@auth.secretary or @@auth.root or
-# @nonpmc.members.include? @@auth.id)
-
- auth = nil # The modules have not been checked
+ # Allow auth if the group uses standard LDAP
+ auth = @nonpmc.hasLDAP and (@@auth.secretary or @@auth.root or
+ @nonpmc.members.include? @@auth.id)
# add jump links to main sections of page using Bootstrap nav element
_ul.nav.nav_pills do
diff --git a/www/roster/views/nonpmc/mod.js.rb
b/www/roster/views/nonpmc/mod.js.rb
index 2c0182c..73692f5 100644
--- a/www/roster/views/nonpmc/mod.js.rb
+++ b/www/roster/views/nonpmc/mod.js.rb
@@ -18,21 +18,6 @@ class NonPMCMod < Vue
_button.close 'x', data_dismiss: 'modal'
_h4.modal_title "Modify People's Roles in the " +
@@project.display_name + ' Project'
- _br
- _p '***Not currently implemented***'
- end
- end
- end
- end
- end
- def norender
- _div.modal.fade.pmcmod! tabindex: -1 do
- _div.modal_dialog do
- _div.modal_content do
- _div.modal_header.bg_info do
- _button.close 'x', data_dismiss: 'modal'
- _h4.modal_title "Modify People's Roles in the " +
- @@project.display_name + ' Project'
end
_div.modal_body do