confirmation: Set confirmation object realm attribute in realm reactivation.

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.
This commit is contained in:
Vishnu KS 2019-09-17 17:34:48 +05:30 committed by Tim Abbott
parent 139ebf387b
commit 23036a9f40
2 changed files with 12 additions and 0 deletions

View File

@ -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)

View File

@ -223,6 +223,15 @@ class RealmTest(ZulipTestCase):
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)