Browse Source

Handle approvals with no name

Gertty currently handles change owners or review comments from
folks with missing account information (or even missing accounts).
This adds similar logic for approvals.

Change-Id: I368807eac131cdfddb9eaf97efdf217af10ea33b
James E. Blair 1 year ago
parent
commit
3b97166127
2 changed files with 16 additions and 4 deletions
  1. 12
    0
      gertty/db.py
  2. 4
    4
      gertty/view/change.py

+ 12
- 0
gertty/db.py View File

@@ -537,6 +537,18 @@ class Approval(object):
537 537
         self.value = value
538 538
         self.draft = draft
539 539
 
540
+    @property
541
+    def reviewer_name(self):
542
+        reviewer_name = 'Anonymous Coward'
543
+        if self.reviewer:
544
+            if self.reviewer.name:
545
+                reviewer_name = self.reviewer.name
546
+            elif self.reviewer.username:
547
+                reviewer_name = self.reviewer.username
548
+            elif self.reviewer.email:
549
+                reviewer_name = self.reviewer.email
550
+        return reviewer_name
551
+
540 552
 class PendingCherryPick(object):
541 553
     def __init__(self, revision, branch, message):
542 554
         self.revision_key = revision.key

+ 4
- 4
gertty/view/change.py View File

@@ -682,13 +682,13 @@ class ChangeView(urwid.WidgetWrap):
682 682
                 approval_headers.append(urwid.Text(('table-header', label.category)))
683 683
                 categories.append(label.category)
684 684
             votes = mywid.Table(approval_headers)
685
-            approvals_for_name = {}
685
+            approvals_for_account = {}
686 686
             pending_message = change.revisions[-1].getPendingMessage()
687 687
             for approval in change.approvals:
688 688
                 # Don't display draft approvals unless they are pending-upload
689 689
                 if approval.draft and not pending_message:
690 690
                     continue
691
-                approvals = approvals_for_name.get(approval.reviewer.name)
691
+                approvals = approvals_for_account.get(approval.reviewer.id)
692 692
                 if not approvals:
693 693
                     approvals = {}
694 694
                     row = []
@@ -696,12 +696,12 @@ class ChangeView(urwid.WidgetWrap):
696 696
                         style = 'reviewer-own-name'
697 697
                     else:
698 698
                         style = 'reviewer-name'
699
-                    row.append(urwid.Text((style, approval.reviewer.name)))
699
+                    row.append(urwid.Text((style, approval.reviewer_name)))
700 700
                     for i, category in enumerate(categories):
701 701
                         w = urwid.Text(u'', align=urwid.CENTER)
702 702
                         approvals[category] = w
703 703
                         row.append(w)
704
-                    approvals_for_name[approval.reviewer.name] = approvals
704
+                    approvals_for_account[approval.reviewer.id] = approvals
705 705
                     votes.addRow(row)
706 706
                 if str(approval.value) != '0':
707 707
                     cat_min, cat_max = change.getMinMaxPermittedForCategory(approval.category)

Loading…
Cancel
Save