Repository: gratipay/gratipay.com

Issue:
remove `participants.number`
#3647 takes it out of the UI.



Discussion:
Quick search finds it at https://github.com/gratipay/gratipay.com/blob/master/gratipay/models/account_elsewhere.py#L127, but I'm not sure what that section even does.


Resolving patch:
diff --git a/gratipay/models/account_elsewhere.py b/gratipay/models/account_elsewhere.py
--- a/gratipay/models/account_elsewhere.py
+++ b/gratipay/models/account_elsewhere.py
@@ -124,13 +124,6 @@ def upsert(cls, i):
                                 (participant, {0})
                          VALUES (%s, {1})
                 """.format(cols, placeholders), (username,)+vals)
-                # Propagate elsewhere.is_team to participants.number
-                if i.is_team:
-                    cursor.execute("""
-                        UPDATE participants
-                           SET number = 'plural'::participant_number
-                         WHERE username = %s
-                    """, (username,))
         except IntegrityError:
             # The account is already in the DB, update it instead
             username = cls.db.one("""
diff --git a/gratipay/models/participant.py b/gratipay/models/participant.py
--- a/gratipay/models/participant.py
+++ b/gratipay/models/participant.py
@@ -176,29 +176,6 @@ def closed_time(self):
         """, (str(self.id),))
 
 
-    # Number
-    # ======
-
-    @property
-    def IS_SINGULAR(self):
-        return self.number == 'singular'
-
-    @property
-    def IS_PLURAL(self):
-        return self.number == 'plural'
-
-    def update_number(self, number):
-        with self.db.get_cursor() as c:
-            add_event(c, 'participant', dict(action='set', id=self.id, values=dict(number=number)))
-            self.remove_all_members(c)
-            c.execute("""
-                UPDATE participants
-                   SET number=%s
-                 WHERE id=%s
-            """, (number, self.id))
-        self.set_attributes(number=number)
-
-
     # Statement
     # =========
 
@@ -373,7 +350,6 @@ def clear_personal_information(self, cursor):
 
             UPDATE participants
                SET anonymous_giving=False
-                 , number='singular'
                  , avatar_url=NULL
                  , email_address=NULL
                  , claimed_time=NULL
@@ -1564,7 +1540,6 @@ def to_dict(self, details=False, inquirer=None):
         output = { 'id': self.id
                  , 'username': self.username
                  , 'avatar': self.avatar_url
-                 , 'number': self.number
                  , 'on': 'gratipay'
                   }
 
diff --git a/gratipay/utils/fake_data.py b/gratipay/utils/fake_data.py
--- a/gratipay/utils/fake_data.py
+++ b/gratipay/utils/fake_data.py
@@ -48,7 +48,7 @@ def fake_sentence(start=1, stop=100):
     return faker.sentence(random.randrange(start,stop))
 
 
-def fake_participant(db, number="singular", is_admin=False):
+def fake_participant(db, is_admin=False):
     """Create a fake User.
     """
     username = faker.first_name() + fake_text_id(3)
@@ -64,10 +64,9 @@ def fake_participant(db, number="singular", is_admin=False):
                    , balanced_customer_href=faker.uri()
                    , is_suspicious=False
                    , claimed_time=faker.date_time_this_year()
-                   , number=number
                     )
     except IntegrityError:
-      return fake_participant(db, number, is_admin)
+      return fake_participant(db, is_admin)
 
     #Call participant constructor to perform other DB initialization
     return Participant.from_username(username)


Test patch:
diff --git a/tests/py/test_close.py b/tests/py/test_close.py
--- a/tests/py/test_close.py
+++ b/tests/py/test_close.py
@@ -152,7 +152,6 @@ def test_cpi_clears_personal_information(self, mailer):
 
         assert alice.get_statement(['en']) == (None, None)
         assert alice.anonymous_giving == new_alice.anonymous_giving == False
-        assert alice.number == new_alice.number == 'singular'
         assert alice.avatar_url == new_alice.avatar_url == None
         assert alice.email_address == new_alice.email_address == None
         assert alice.claimed_time == new_alice.claimed_time == None
@@ -162,12 +161,6 @@ def test_cpi_clears_personal_information(self, mailer):
         assert alice.session_expires.year == new_alice.session_expires.year == date.today().year
         assert not alice.get_emails()
 
-        team = self.make_participant('team', number='plural')
-        with self.db.get_cursor() as cursor:
-            team.clear_personal_information(cursor)
-        team2 = Participant.from_username('team')
-        assert team.number == team2.number == 'singular'
-
     def test_cpi_clears_communities(self):
         alice = self.make_participant('alice')
         alice.insert_into_communities(True, 'test', 'test')
diff --git a/tests/py/test_membername_json.py b/tests/py/test_membername_json.py
--- a/tests/py/test_membername_json.py
+++ b/tests/py/test_membername_json.py
@@ -9,7 +9,7 @@ class TestMembernameJson(Harness):
 
     def setUp(self):
         Harness.setUp(self)
-        self.make_participant("team", claimed_time=utcnow(), number='plural')
+        self.make_participant("team", claimed_time=utcnow())
         self.make_participant("alice", claimed_time=utcnow())
 
     def test_post_team_is_not_team_returns_404(self):
diff --git a/tests/py/test_participant.py b/tests/py/test_participant.py
--- a/tests/py/test_participant.py
+++ b/tests/py/test_participant.py
@@ -288,17 +288,6 @@ def setUp(self):
             p = self.make_participant(username, claimed_time=now, elsewhere='twitter')
             setattr(self, username, p)
 
-    def test_bob_is_singular(self):
-        expected = True
-        actual = self.bob.IS_SINGULAR
-        assert actual == expected
-
-    def test_john_is_plural(self):
-        expected = True
-        self.make_participant('john', number='plural')
-        actual = Participant.from_username('john').IS_PLURAL
-        assert actual == expected
-
     def test_comparison(self):
         assert self.alice == self.alice
         assert not (self.alice != self.alice)
diff --git a/tests/py/test_public_json.py b/tests/py/test_public_json.py
--- a/tests/py/test_public_json.py
+++ b/tests/py/test_public_json.py
@@ -65,7 +65,6 @@ def test_jsonp_works(self):
     "id": %(user_id)s,
     "ngiving_to": 0,
     "ntaking_from": 1,
-    "number": "singular",
     "on": "gratipay",
     "taking": "3.00",
     "username": "picard"