support: Pass various realm functions as template context.

We currently have code to calculate the value of realm_icon_url,
admin_emails and default_discount in two diffrent places. With
the addition of showing confirmation links it would become three.
The easiest way to deduplicate the code and make the view cleaner
is by doing the calculations in template. Alternatively one can
write a function that takes users, realms and confirmations as
arguments and sets the value of realm_icon_url, admin_emails and
default_discount appropriately in realm object according to the
type of the confirmation. But that seems more messy than passing
the functions directly to template approach.
This commit is contained in:
Vishnu KS
2019-09-13 17:05:28 +05:30
committed by Tim Abbott
parent 62a8e378a6
commit 139ebf387b
4 changed files with 19 additions and 23 deletions

View File

@@ -154,6 +154,7 @@ of syntax errors. There are two common causes for this test failing:
"""
user_profile = self.example_user('hamlet')
realm = user_profile.realm
email = user_profile.email
context = dict(
@@ -194,6 +195,10 @@ of syntax errors. There are two common causes for this test failing:
invite_as={"MEMBER": 1},
max_file_upload_size = 25,
avatar_urls={"john@gmail.com": "www.zulip.com"},
realm_admin_emails=lambda _: "admin emails",
get_discount_for_realm=lambda _: 0,
realm_icon_url=lambda _: "url",
realm=realm,
)
context.update(kwargs)