diff --git a/gittip/models/__init__.py b/gittip/models/__init__.py index c2f2c8d821..3c57435146 100644 --- a/gittip/models/__init__.py +++ b/gittip/models/__init__.py @@ -3,7 +3,7 @@ # .metadata, and thus aren't cleaned up properly during teardown.) from gittip.models.absorption import Absorption -from gittip.models.deletion import Deletion +from gittip.models.deactivation import Deactivation # The rest we actually use. diff --git a/gittip/models/deletion.py b/gittip/models/deactivation.py similarity index 81% rename from gittip/models/deletion.py rename to gittip/models/deactivation.py index 1d467f084a..e5178da6d7 100644 --- a/gittip/models/deletion.py +++ b/gittip/models/deactivation.py @@ -3,13 +3,13 @@ from gittip.orm import db -class Deletion(db.Model): - __tablename__ = 'deletions' +class Deactivation(db.Model): + __tablename__ = 'deactivations' id = Column(Integer, nullable=False, primary_key=True) timestamp = Column(TIMESTAMP(timezone=True), nullable=False, default="now()") - deleted_was = Column(Text, nullable=False) + deactivated_was = Column(Text, nullable=False) archived_as = Column(Text, ForeignKey("participants.id", onupdate="RESTRICT", ondelete="RESTRICT"), nullable=False) diff --git a/gittip/participant.py b/gittip/participant.py index f01ee9b718..77261c80a7 100644 --- a/gittip/participant.py +++ b/gittip/participant.py @@ -842,14 +842,17 @@ def deactivate(self): """Deactivate this account. """ with gittip.db.get_transaction() as txn: - deleted_was = self.id - archived_as = self.archive(txn, deleted_was) + deactivated_was = self.id + archived_as = self.archive(txn, deactivated_was) txn.execute(""" - INSERT INTO deletions (deleted_was, archived_as) - VALUES (%s, %s) + INSERT + INTO deactivations + (deactivated_was, archived_as) + VALUES + (%s, %s) - """, (deleted_was, archived_as)) + """, (deactivated_was, archived_as)) return archived_as diff --git a/tests/test_participant.py b/tests/test_participant.py index 4aa29b9f6b..a750041b8e 100644 --- a/tests/test_participant.py +++ b/tests/test_participant.py @@ -5,7 +5,7 @@ from aspen.utils import utcnow from nose.tools import assert_raises, assert_equals -from gittip.models import Absorption, Deletion, User, Tip +from gittip.models import Absorption, Deactivation, User, Tip from gittip.orm import db from gittip.participant import Participant, NeedConfirmation from gittip.testing import Harness, looks_random @@ -135,22 +135,22 @@ def test_deleting_a_non_existent_user_assertion_errors(self): def test_no_deactivations_to_start_with(self): self.make_participant('alice') - actual = Deletion.query.filter_by().count() + actual = Deactivation.query.filter_by().count() assert actual == 0, actual def test_deactivate_records_one_deactivation(self): self.make_participant('alice').deactivate() - actual = Deletion.query.filter_by().count() + actual = Deactivation.query.filter_by().count() assert actual == 1, actual def test_deactivation_records_deactivated_was(self): self.make_participant('alice').deactivate() - actual = Deletion.query.filter_by()[0].deactivated_was + actual = Deactivation.query.filter_by()[0].deactivated_was assert actual == 'alice', actual def test_deactivation_records_archived_as(self): self.make_participant('alice').deactivate() - actual = Deletion.query.filter_by()[0].archived_as + actual = Deactivation.query.filter_by()[0].archived_as assert looks_random(actual)