mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user