Skip to content

Commit

Permalink
confirmation: Set confirmation object realm attribute in realm reacti…
Browse files Browse the repository at this point in the history
…vation.

The value of realm attribute in confirmation object used to be empty
before. We are not currently using the realm attribute of reactivation
links anywhere. The value of realm stored in content_object is currently
used.
  • Loading branch information
hackerkid authored and timabbott committed Oct 21, 2019
1 parent 139ebf3 commit 23036a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions confirmation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def create_confirmation_link(obj: ContentType, host: str,
realm = None
if hasattr(obj, 'realm'):
realm = obj.realm
elif isinstance(obj, Realm):
realm = obj

Confirmation.objects.create(content_object=obj, date_sent=timezone_now(), confirmation_key=key,
realm=realm, type=confirmation_type)
return confirmation_url(key, host, confirmation_type, url_args)
Expand Down
9 changes: 9 additions & 0 deletions zerver/tests/test_realm.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ def test_realm_reactivation_link(self) -> None:
realm = get_realm('zulip')
self.assertFalse(realm.deactivated)

def test_realm_reactivation_confirmation_object(self) -> None:
realm = get_realm('zulip')
do_deactivate_realm(realm)
self.assertTrue(realm.deactivated)
create_confirmation_link(realm, realm.host, Confirmation.REALM_REACTIVATION)
confirmation = Confirmation.objects.last()
self.assertEqual(confirmation.content_object, realm)
self.assertEqual(confirmation.realm, realm)

def test_do_send_realm_reactivation_email(self) -> None:
realm = get_realm('zulip')
do_send_realm_reactivation_email(realm)
Expand Down

0 comments on commit 23036a9

Please sign in to comment.