You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2019/03/24 22:32:30 UTC
[whimsy] branch master updated: Allow editing of email addresses
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 2597766 Allow editing of email addresses
2597766 is described below
commit 2597766b87cd3ab638e86621dc5acc5974515342
Author: Sebb <se...@apache.org>
AuthorDate: Sun Mar 24 22:32:26 2019 +0000
Allow editing of email addresses
---
www/roster/models/committer.rb | 5 +--
www/roster/views/actions/email_alt.json.rb | 35 ++++++++++++++++++++
www/roster/views/actions/email_forward.json.rb | 35 ++++++++++++++++++++
www/roster/views/app.js.rb | 4 ++-
www/roster/views/person/email.js.rb | 33 -------------------
www/roster/views/person/email_alt.js.rb | 44 ++++++++++++++++++++++++++
www/roster/views/person/email_forward.js.rb | 44 ++++++++++++++++++++++++++
www/roster/views/person/email_other.js.rb | 21 ++++++++++++
www/roster/views/person/main.js.rb | 13 ++++++--
9 files changed, 196 insertions(+), 38 deletions(-)
diff --git a/www/roster/models/committer.rb b/www/roster/models/committer.rb
index 6d3a232..8f1a855 100644
--- a/www/roster/models/committer.rb
+++ b/www/roster/models/committer.rb
@@ -44,8 +44,9 @@ class Committer
response[:name] = name
- response[:mail] = person.all_mail
- response[:mail_default] = person.mail # used for forwarding mails
+ response[:email_forward] = person.mail # forwarding
+ response[:email_alt] = person.alt_email # alternates
+ response[:email_other] = person.all_mail - person.mail - person.alt_email # others (ASF mail/ICLA mail if different)
unless person.pgp_key_fingerprints.empty?
response[:pgp] = person.pgp_key_fingerprints
diff --git a/www/roster/views/actions/email_alt.json.rb b/www/roster/views/actions/email_alt.json.rb
new file mode 100644
index 0000000..7266226
--- /dev/null
+++ b/www/roster/views/actions/email_alt.json.rb
@@ -0,0 +1,35 @@
+#
+# Update PGP keys attribute for a committer
+#
+
+person = ASF::Person.find(@userid)
+
+# report the previous value in the response
+_previous alt_email: person.attrs['alt_email']
+
+if @email_alt # must agree with email_alt.js.rb
+
+ # report the new values
+ _replacement alt_email: @email_alt
+
+ @email_alt.each do |mail|
+ unless mail.match(URI::MailTo::EMAIL_REGEXP)
+ _error "Invalid email address '#{mail}'"
+ return
+ end
+ if mail.end_with? 'apache.org'
+ _error "Invalid email address '#{mail}' (must not be apache.org)"
+ return
+ end
+ end
+
+ # update LDAP
+ unless @dryrun
+ _ldap.update do
+ person.modify 'alt_email', @email_alt
+ end
+ end
+end
+
+# return updated committer info
+_committer Committer.serialize(@userid, env)
diff --git a/www/roster/views/actions/email_forward.json.rb b/www/roster/views/actions/email_forward.json.rb
new file mode 100644
index 0000000..cb1a751
--- /dev/null
+++ b/www/roster/views/actions/email_forward.json.rb
@@ -0,0 +1,35 @@
+#
+# Update PGP keys attribute for a committer
+#
+
+person = ASF::Person.find(@userid)
+
+# report the previous value in the response
+_previous mail: person.attrs['mail']
+
+if @email_forward # must agree with email_forward.js.rb
+
+ # report the new values
+ _replacement mail: @email_forward
+
+ @email_forward.each do |mail|
+ unless mail.match(URI::MailTo::EMAIL_REGEXP)
+ _error "Invalid email address '#{mail}'"
+ return
+ end
+ if mail.end_with? 'apache.org'
+ _error "Invalid email address '#{mail}' (must not be apache.org)"
+ return
+ end
+ end
+
+ # update LDAP
+ unless @dryrun
+ _ldap.update do
+ person.modify 'alt_email', @email_forward
+ end
+ end
+end
+
+# return updated committer info
+_committer Committer.serialize(@userid, env)
diff --git a/www/roster/views/app.js.rb b/www/roster/views/app.js.rb
index c74cec2..796aa9b 100644
--- a/www/roster/views/app.js.rb
+++ b/www/roster/views/app.js.rb
@@ -19,7 +19,9 @@ require_relative 'nonpmc/mod'
require_relative 'person/main'
require_relative 'person/fullname'
require_relative 'person/urls'
-require_relative 'person/email'
+require_relative 'person/email_alt'
+require_relative 'person/email_forward'
+require_relative 'person/email_other'
require_relative 'person/pgpkeys'
require_relative 'person/sshkeys'
require_relative 'person/github'
diff --git a/www/roster/views/person/email.js.rb b/www/roster/views/person/email.js.rb
deleted file mode 100644
index e40e038..0000000
--- a/www/roster/views/person/email.js.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Render and edit a person's E-mail addresses
-#
-
-class PersonEmail < Vue
- def render
- committer = @@person.state.committer
-
- _div.row do
- _div.name do
- _ 'Email addresses '
- _b do
- _ '(forwards)'
- end
-
- end
-
- _div.value do
- _ul committer.mail do |url|
- _li do
- if committer.mail_default.include?(url)
- _b do
- _a url, href: 'mailto:' + url
- end
- else
- _a url, href: 'mailto:' + url
- end
- end
- end
- end
- end
- end
-end
diff --git a/www/roster/views/person/email_alt.js.rb b/www/roster/views/person/email_alt.js.rb
new file mode 100644
index 0000000..b0613c7
--- /dev/null
+++ b/www/roster/views/person/email_alt.js.rb
@@ -0,0 +1,44 @@
+#
+# Render and edit a person's alt E-mail addresses
+#
+
+class PersonEmailAlt < Vue
+ def render
+ committer = @@person.state.committer
+
+ _div.row data_edit: 'email_alt' do
+ _div.name 'Email addresses (alt)'
+
+ _div.value do
+
+ if @@edit == :email_alt
+
+ _form method: 'post' do
+ current = 1
+ prefix = 'email_alt' # must agree with email_alt.json.rb
+ _input type: 'hidden', name: 'array_prefix', value: prefix
+
+ _div committer.email_alt do |key|
+ _input name: prefix + current, value: key, size: 30
+ _br
+ current += 1
+ end
+ # Spare field to allow new entry to be added
+ _input name: prefix + current, placeholder: '<alternate email>', size: 30
+ _br
+
+ _input type: 'submit', value: 'submit'
+ end
+
+ else
+
+ _ul committer.email_alt do |mail|
+ _li do
+ _a mail, href: 'mailto:' + mail
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/www/roster/views/person/email_forward.js.rb b/www/roster/views/person/email_forward.js.rb
new file mode 100644
index 0000000..526c906
--- /dev/null
+++ b/www/roster/views/person/email_forward.js.rb
@@ -0,0 +1,44 @@
+#
+# Render and edit a person's forward E-mail addresses
+#
+
+class PersonEmailForwards < Vue
+ def render
+ committer = @@person.state.committer
+
+ _div.row data_edit: 'email_forward' do
+ _div.name 'Email forwarded to'
+
+ _div.value do
+
+ if @@edit == :email_forward
+
+ _form method: 'post' do
+ current = 1
+ prefix = 'email_forward' # must agree with email_forward.json.rb
+ _input type: 'hidden', name: 'array_prefix', value: prefix
+
+ _div committer.email_forward do |key|
+ _input name: prefix + current, value: key, size: 30
+ _br
+ current += 1
+ end
+ # Spare field to allow new entry to be added
+ _input name: prefix + current, placeholder: '<forwarding email>', size: 30
+ _br
+
+ _input type: 'submit', value: 'submit'
+ end
+
+ else
+
+ _ul committer.email_forward do |mail|
+ _li do
+ _a mail, href: 'mailto:' + mail
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/www/roster/views/person/email_other.js.rb b/www/roster/views/person/email_other.js.rb
new file mode 100644
index 0000000..08d12cb
--- /dev/null
+++ b/www/roster/views/person/email_other.js.rb
@@ -0,0 +1,21 @@
+#
+# Render a person's other E-mail address(es)
+#
+
+class PersonEmailOther < Vue
+ def render
+ committer = @@person.state.committer
+
+ _div.row do
+ _div.name 'Email addresses (other)'
+
+ _div.value do
+ _ul committer.email_other do |mail|
+ _li do
+ _a mail, href: 'mailto:' + mail
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/www/roster/views/person/main.js.rb b/www/roster/views/person/main.js.rb
index af88e8f..2cfc593 100644
--- a/www/roster/views/person/main.js.rb
+++ b/www/roster/views/person/main.js.rb
@@ -161,8 +161,17 @@ class Person < Vue
end
# Email addresses
- if @committer.mail
- _PersonEmail person: self
+ if @committer.email_forward # I expect this is always true
+ _PersonEmailForwards person: self, edit: @edit
+ end
+
+ if @committer.email_alt|| @auth
+ @committer.email_alt ||= ['<none defined>']
+ _PersonEmailAlt person: self, edit: @edit
+ end
+
+ if @committer.email_other
+ _PersonEmailOther person: self # not editable
end
# Moderates