whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject [whimsy] branch coi updated: Update coi.cgi
Date Tue, 23 Jun 2020 23:20:16 GMT
This is an automated email from the ASF dual-hosted git repository.

clr pushed a commit to branch coi
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/coi by this push:
     new cc9e64b  Update coi.cgi
cc9e64b is described below

commit cc9e64be04c9add2e3839655d9a6e7b677df3dc5
Author: Craig L Russell <apache.clr@gmail.com>
AuthorDate: Tue Jun 23 16:20:09 2020 -0700

    Update coi.cgi
    
    Ready for user testing and feedback
---
 www/officers/coi.cgi | 124 +++++++++++++++++++++++++++------------------------
 1 file changed, 65 insertions(+), 59 deletions(-)

diff --git a/www/officers/coi.cgi b/www/officers/coi.cgi
index dcf920a..a247760 100755
--- a/www/officers/coi.cgi
+++ b/www/officers/coi.cgi
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-PAGETITLE = "Conflict of Interest"
+PAGETITLE = "Conflict of Interest Affirmations"
 $LOAD_PATH.unshift '/srv/whimsy/lib'
 require 'wunderbar'
 require 'wunderbar/bootstrap'
@@ -14,40 +14,43 @@ COI_CURRENT_URL = File.join(coi_url, YEAR)
 COI_CURRENT_TEMPLATE_URL = File.join(COI_CURRENT_URL, 'template.txt')
 
 user = ASF::Person.find($USER)
+USERID = user.id
+USERNAME = user.cn
 committees = ASF::Committee.officers + ASF::Committee.nonpmcs
 chairs = committees.map do |committee|
  committee.chairs.map {|chair| chair[:id]}
 end
-ids = (chairs.flatten + ASF::Service['board'].members.map(&:id)).uniq
+IDS = (chairs.flatten + ASF::Service['board'].members.map(&:id)).uniq
 
 # Get the list of files in this year's directory
 signerfileslist, err = ASF::SVN.svn('list', COI_CURRENT_URL, {user: $USER, password: $PASSWORD})
-signerfileslist = 'template.txt\nclr99.jpg\nfielding33.pdf\ncurcuru20.jpg'
 signerfiles = signerfileslist.split('\n')
-signers = Hash.new
 
-# Get the url for the user's affirmation
-user_affirmation_file = nil
+# Create the hash of {signer: signerurl} and remember user's affirmation file
+SIGNERS = Hash.new
+USER_AFFIRMATION_FILE = nil
 signerfiles.each do |signerfile|
   stem = signerfile[0..signerfile.index(".")-1]
-  user_affirmation_file = signerfile if stem == user.id
-  signers[stem] = signerfile unless stem == 'template'
+  USER_AFFIRMATION_FILE = signerfile if stem == USERID
+  SIGNERS[stem] = signerfile unless stem == 'template'
 end
 
 # Get the list of required users who have not yet signed
-nonsigners = []
-ids.each do |required|
-  nonsigners.push(required) unless signers.include? required
+NONSIGNERS = []
+IDS.each do |required|
+  NONSIGNERS.push(required) unless SIGNERS.include? required
 end
 
-# Decide if user should sign the affirmation form
-user_is_required = ids.include? user.id
+# Determine if user should sign the affirmation form
+user_is_required = IDS.include? USERID
 not_required_message = user_is_required ?' required':' not required'
-user_affirmation = signers.include? user.id
+user_affirmation = SIGNERS.include? USERID
 have_affirmed_message = user_affirmation ? ' have affirmed' : ' have not affirmed'
-user_is_required_but_not_affirmed = (user_is_required and not user_affirmation)
+USER_IS_REQUIRED_BUT_NOT_AFFIRMED = (user_is_required and not user_affirmation)
 current_timestamp = DateTime.now.strftime "%Y-%m-%d %H:%M:%S"
-panel_message = user_is_required_but_not_affirmed ? 'Register Your Conflict of Interest 
Affirmation':'Thank you for signing the Conflict of Interest Affirmation'
+PANEL_MESSAGE = USER_IS_REQUIRED_BUT_NOT_AFFIRMED ?
+  'Sign Your Conflict of Interest Affirmation':
+  'Thank you for signing the Conflict of Interest Affirmation'
 
 # Read the template and append the signature block
 def get_affirmed_template(user, password, name, timestamp)
@@ -58,14 +61,14 @@ def get_affirmed_template(user, password, name, timestamp)
          I understand that ASF is charitable and in order to maintain
          its federal tax exemption it must engage primarily in activities
          which accomplish one or more of its tax-exempt purposes.
-      Signed: __
-      Date: __
-      Metadata: __________Whimsy www/officers/coi.cgi___________'
+       Signed: __
+       Date: __
+       Metadata: __________Whimsy www/officers/coi.cgi___________'
   template, err =
     ASF::SVN.svn('cat', COI_CURRENT_TEMPLATE_URL, {user: user, password: password})
   affirmed = (template + signature_block)
     .gsub("Signed: __", "Signed: __________#{name}___________")
-    .gsub("Date: __",   "  Date: __________#{timestamp}______")
+    .gsub("Date: __",   "Date: __________#{timestamp}______")
 end
 
 _html do
@@ -79,74 +82,75 @@ _html do
     },
     helpblock: -> {
       _p do
-        _ 'This page allows officers to register their Conflict of Interest annual affirmation.'
+        _ 'This page allows officers to sign their Conflict of Interest annual affirmation.'
       end
       if _.get?
       _p 'The following are currently required to affirm the Conflict of Interest:'
-      ids.each do |id|
+      IDS.each do |id|
        affirmer = ASF::Person.find(id)
        _ "#{affirmer.cn} (#{affirmer.id}) "
       end
       _p
-      _p "You are signed in as #{user.cn} (#{user.id}) at #{current_timestamp}."
-      _p {_ "You are ";_b "#{not_required_message}";_ " to affirm the Conflict of Interest
policy for this year."}
-      _p {_ "You ";_b "#{have_affirmed_message}";_  "the Conflict of Interest policy for
this year."}
-      _p 'Signers for this year:'
-      signers.each do |signer, signerfile|
+      _b 'Signers for this year:'
+      SIGNERS.each do |signer, signerfile|
         _a signer, href: "#{COI_CURRENT_URL}/#{signerfile}"
       end
-      _p 'Nonsigners for this year:'
-      nonsigners.each do |nonsigner|
+      _p
+      _b 'Nonsigners for this year:'
+      NONSIGNERS.each do |nonsigner|
         _ nonsigner
       end
       _p
-      if  user_affirmation_file
+      _p "You are signed in as #{USERNAME} (#{USERID}) at #{current_timestamp}."
+      _p {_ "You are ";_b "#{not_required_message}";_ " to affirm the Conflict of Interest
policy for this year."}
+      _p {_ "You ";_b "#{have_affirmed_message}";_  "the Conflict of Interest policy for
this year."}
+      if  USER_AFFIRMATION_FILE
         _a "Your Conflict of Interest affirmation",
-          href: "#{COI_CURRENT_URL}/#{user_affirmation_file}"
+          href: "#{COI_CURRENT_URL}/#{USER_AFFIRMATION_FILE}"
       end
-      if user_is_required_but_not_affirmed
+      if USER_IS_REQUIRED_BUT_NOT_AFFIRMED
         _p {_b "You are invited to sign the affirmation below"}
       end
-      end
+    end
     }
     ) do
-        if _.get?
-          if user_is_required_but_not_affirmed
-            _whimsy_panel(panel_message, style: 'panel-success') do
-              affirmed = get_affirmed_template($USER, $PASSWORD, user.cn,  current_timestamp)
-              affirmed.each_line do |line|
-                _p line
-              end
-              _form.form_horizontal method: 'post' do
-                _div.form_group do
-                  _div.col_sm_offset_2.col_sm_10 do
-                    _input.btn.btn_default type: 'submit', value: 'Affirm Conflict of Interest
policy'
-                  end
+      if _.get?
+        if USER_IS_REQUIRED_BUT_NOT_AFFIRMED
+          _whimsy_panel(PANEL_MESSAGE, style: 'panel-success') do
+            affirmed = get_affirmed_template($USER, $PASSWORD, USERNAME,  current_timestamp)
+            affirmed.each_line do |line|
+              _p line
+            end
+            _form.form_horizontal method: 'post' do
+              _div.form_group do
+                _div.col_sm_offset_1.col_sm_10 do
+                  _input.btn.btn_default type: 'submit',
+                    value: 'Sign your Conflict of Interest Affirmation'
                 end
               end
             end
           end
-        else # POST
-          _whimsy_panel('Affirm Conflict of Interest - Session Transcript',
-              style: 'panel-success') do
-            _div.transcript do
-              emit_post(_)
-            end
+        end
+      else # POST
+        _whimsy_panel('Sign Conflict of Interest Affirmation - Session Transcript',
+            style: 'panel-success') do
+          _div.transcript do
+            emit_post(_)
           end
         end
-#      end
+      end
     end
   end
 end
 
 # Emit a record of a user's submission - POST
 def emit_post(_)
-  # collect data
+  # The only information in the POST is $USER and $PASSWORD
   user = ASF::Person.find($USER)
   current_timestamp = DateTime.now.strftime "%Y-%m-%d %H:%M:%S"
 
-  affirmed = get_affirmed_template($USER, $PASSWORD, user.cn, current_timestamp)
-  user_filename = "#{user.id}.txt"
+  affirmed = get_affirmed_template($USER, $PASSWORD, USERNAME, current_timestamp)
+  user_filename = "#{USERID}.txt"
 
   # report on commit
   _div.transcript do
@@ -161,20 +165,23 @@ def emit_post(_)
         ASF::SVN.svn_('propset', ['svn:mime-type', 'text/plain; charset=utf-8', filename],
_)
 
         # commit
+        # TODO enable commit of affirmation
 #        ASF::SVN.svn_('commit',[filename], _,
- #         {msg: "Affirm Conflict of Interest Policy for #{$USER}", user: $USER, password:
$PASSWORD})
-# TODO: send email to $USER, secretary@
+#         {msg: "Affirm Conflict of Interest Policy for #{USERNAME}",
+#           user: $USER, password: $PASSWORD})
       end
     end
+    # Send email to $USER, secretary@
     ASF::Mail.configure
     mail = Mail.new do
       to "#{user.public_name}<#{user.mail.first}>"
+      # TODO enable cc: secretary
  #     cc "secretary@apache.org"
       from "#{user.mail.first}"
       subject "Conflict of Interest affirmation from #{user.public_name}"
       body "This year's Conflict of Interest affirmation is attached."
     end
-    mail.attachments["#{user.id}.txt"] = affirmed
+    mail.attachments["#{USERID}.txt"] = affirmed
     mail.deliver!
   end
 
@@ -186,6 +193,5 @@ def emit_post(_)
     _span " as now checked in to svn."
     _p {_ "Reload ";_a "this page",href: "coi.cgi";_span " to see the results."}
   end
-#  _pre proxyform
 end
 


Mime
View raw message