whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: Start the move of user info from Server to Pending
Date Mon, 13 Nov 2017 18:44:29 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys 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 4920c9e  Start the move of user info from Server to Pending
4920c9e is described below

commit 4920c9ec6d68bd144cfab65843a4acf4d597847d
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Mon Nov 13 13:44:11 2017 -0500

    Start the move of user info from Server to Pending
---
 www/board/agenda/models/pending.rb          | 20 ++++++++++++++++++++
 www/board/agenda/routes.rb                  | 11 ++++-------
 www/board/agenda/views/models/agenda.js.rb  |  4 ++--
 www/board/agenda/views/models/pending.js.rb | 14 +++++++++++++-
 4 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/www/board/agenda/models/pending.rb b/www/board/agenda/models/pending.rb
index 7288465..1b3c107 100644
--- a/www/board/agenda/models/pending.rb
+++ b/www/board/agenda/models/pending.rb
@@ -23,6 +23,26 @@ class Pending
     response['comments'] ||= {} 
     response['seen']     ||= {}
 
+    # extract user information
+    response['userid'] ||= user
+
+    if user == 'test' and ENV['RACK_ENV'] == 'test'
+      username = 'Joe Tester'
+    else
+      username = ASF::Person.new(user).public_name
+      begin
+        username ||= Etc.getpwnam(userid)[4].split(',')[0].
+          force_encoding('utf-8')
+      rescue ArgumentError
+        username = 'Anonymous'
+      end
+    end
+
+    response['username'] ||= username
+    response['initials'] ||= username.gsub(/[^A-Z]/, '').downcase
+    response['firstname'] ||= username.split(' ').first.downcase
+
+    # return response
     response
   end
 
diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index 4c70149..ecfd710 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -94,9 +94,7 @@ end
 
 # pending items
 get %r{/(\d\d\d\d-\d\d-\d\d)/pending\.json} do |date|
-  userid = env.user
-  pending = Pending.get(userid)
-  pending[:userid] = userid
+  pending = Pending.get(env.user)
   _json pending
 end
 
@@ -126,7 +124,6 @@ get %r{/(\d\d\d\d-\d\d-\d\d)/(.*)} do |date, path|
   end
 
   pending = Pending.get(userid)
-  initials = pending['initials'] || username.gsub(/[^A-Z]/, '').downcase
 
   if userid == 'test' or ASF::Service['board'].members.map(&:id).include? userid
     role = :director
@@ -157,9 +154,9 @@ get %r{/(\d\d\d\d-\d\d-\d\d)/(.*)} do |date, path|
     agendas: dir('board_agenda_*.txt').sort,
     drafts: dir('board_minutes_*.txt').sort,
     pending: pending,
-    username: username,
-    firstname: username.split(' ').first.downcase,
-    initials: initials,
+    username: pending['username'],
+    firstname: pending['firstname'],
+    initials: pending['initials'],
     online: @present,
     session: Session.user(userid),
     role: role,
diff --git a/www/board/agenda/views/models/agenda.js.rb b/www/board/agenda/views/models/agenda.js.rb
index 5c9d38b..b152a0e 100644
--- a/www/board/agenda/views/models/agenda.js.rb
+++ b/www/board/agenda/views/models/agenda.js.rb
@@ -322,7 +322,7 @@ class Agenda
   def self.shepherd
     shepherd = nil
 
-    firstname = Server.firstname.downcase()
+    firstname = Pending.firstname.downcase()
     Agenda.index.each do |item|
       if 
         item.shepherd and 
@@ -480,7 +480,7 @@ class Agenda
     return true if Minutes.started and self.missing
     return false unless @flagged_by
     return false if @flagged_by.length == 1 and 
-      @flagged_by.first == Server.initials and 
+      @flagged_by.first == Pending.initials and 
       Pending.unflagged.include?(@attach)
     return ! @flagged_by.empty?
   end
diff --git a/www/board/agenda/views/models/pending.js.rb b/www/board/agenda/views/models/pending.js.rb
index 1d54ea6..e933cd2 100644
--- a/www/board/agenda/views/models/pending.js.rb
+++ b/www/board/agenda/views/models/pending.js.rb
@@ -12,7 +12,11 @@ class Pending
       if response.ok
         response.json().then do |json|
           Pending.load(json)
-          Server.userid = json.userid if json and json.userid
+          if json
+            Server.userid = json.userid if json.userid
+            Server.initials = json.initials if json.initials
+            Server.firstname = json.firstname if json.firstname
+          end
         end
       end
     end
@@ -58,10 +62,18 @@ class Pending
     Server.pending.seen || {}
   end
 
+  def self.userid
+    Server.pending.userid || Server.userid
+  end
+
   def self.initials
     Server.pending.initials || Server.initials
   end
 
+  def self.firstname
+    Server.pending.firstname || Server.firstname
+  end
+
   def self.status
     Server.pending.status || []
   end

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message