mirror of https://github.com/zulip/zulip.git
python: Prefer kwargs form of dict.update.
For less inflation by Black. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
75c59a820d
commit
bef46dab3c
|
@ -311,9 +311,10 @@ class StripeTestCase(ZulipTestCase):
|
|||
'signed_seat_count': self.get_signed_seat_count_from_response(response),
|
||||
'salt': self.get_salt_from_response(response)}
|
||||
if invoice: # send_invoice
|
||||
params.update({
|
||||
'billing_modality': 'send_invoice',
|
||||
'licenses': 123})
|
||||
params.update(
|
||||
billing_modality='send_invoice',
|
||||
licenses=123,
|
||||
)
|
||||
else: # charge_automatically
|
||||
stripe_token = None
|
||||
if not talk_to_stripe:
|
||||
|
@ -321,11 +322,11 @@ class StripeTestCase(ZulipTestCase):
|
|||
stripe_token = kwargs.get('stripe_token', stripe_token)
|
||||
if stripe_token is None:
|
||||
stripe_token = stripe_create_token().id
|
||||
params.update({
|
||||
'billing_modality': 'charge_automatically',
|
||||
'license_management': 'automatic',
|
||||
'stripe_token': stripe_token,
|
||||
})
|
||||
params.update(
|
||||
billing_modality='charge_automatically',
|
||||
license_management='automatic',
|
||||
stripe_token=stripe_token,
|
||||
)
|
||||
|
||||
params.update(kwargs)
|
||||
for key in del_args:
|
||||
|
|
|
@ -281,24 +281,24 @@ def billing_home(request: HttpRequest) -> HttpResponse:
|
|||
else:
|
||||
payment_method = 'Billed by invoice'
|
||||
|
||||
context.update({
|
||||
'plan_name': plan.name,
|
||||
'has_active_plan': True,
|
||||
'free_trial': free_trial,
|
||||
'downgrade_at_end_of_cycle': downgrade_at_end_of_cycle,
|
||||
'automanage_licenses': plan.automanage_licenses,
|
||||
'switch_to_annual_at_end_of_cycle': switch_to_annual_at_end_of_cycle,
|
||||
'licenses': licenses,
|
||||
'licenses_used': licenses_used,
|
||||
'renewal_date': renewal_date,
|
||||
'renewal_amount': f'{renewal_cents / 100.:,.2f}',
|
||||
'payment_method': payment_method,
|
||||
'charge_automatically': charge_automatically,
|
||||
'publishable_key': STRIPE_PUBLISHABLE_KEY,
|
||||
'stripe_email': stripe_customer.email,
|
||||
'CustomerPlan': CustomerPlan,
|
||||
'onboarding': request.GET.get("onboarding") is not None,
|
||||
})
|
||||
context.update(
|
||||
plan_name=plan.name,
|
||||
has_active_plan=True,
|
||||
free_trial=free_trial,
|
||||
downgrade_at_end_of_cycle=downgrade_at_end_of_cycle,
|
||||
automanage_licenses=plan.automanage_licenses,
|
||||
switch_to_annual_at_end_of_cycle=switch_to_annual_at_end_of_cycle,
|
||||
licenses=licenses,
|
||||
licenses_used=licenses_used,
|
||||
renewal_date=renewal_date,
|
||||
renewal_amount=f'{renewal_cents / 100.:,.2f}',
|
||||
payment_method=payment_method,
|
||||
charge_automatically=charge_automatically,
|
||||
publishable_key=STRIPE_PUBLISHABLE_KEY,
|
||||
stripe_email=stripe_customer.email,
|
||||
CustomerPlan=CustomerPlan,
|
||||
onboarding=request.GET.get("onboarding") is not None,
|
||||
)
|
||||
|
||||
return render(request, 'corporate/billing.html', context=context)
|
||||
|
||||
|
|
|
@ -1027,11 +1027,11 @@ def do_start_email_change_process(user_profile: UserProfile, new_email: str) ->
|
|||
activation_url = create_confirmation_link(obj, Confirmation.EMAIL_CHANGE)
|
||||
from zerver.context_processors import common_context
|
||||
context = common_context(user_profile)
|
||||
context.update({
|
||||
'old_email': old_email,
|
||||
'new_email': new_email,
|
||||
'activate_url': activation_url,
|
||||
})
|
||||
context.update(
|
||||
old_email=old_email,
|
||||
new_email=new_email,
|
||||
activate_url=activation_url,
|
||||
)
|
||||
language = user_profile.default_language
|
||||
send_email('zerver/emails/confirm_new_email', to_emails=[new_email],
|
||||
from_name=FromAddress.security_email_from_name(language=language),
|
||||
|
@ -5997,7 +5997,7 @@ def do_delete_realm_export(user_profile: UserProfile, export: RealmAuditLog) ->
|
|||
# Allow removal even if the export failed.
|
||||
delete_export_tarball(export_path)
|
||||
|
||||
export_data.update({'deleted_timestamp': timezone_now().timestamp()})
|
||||
export_data.update(deleted_timestamp=timezone_now().timestamp())
|
||||
export.extra_data = orjson.dumps(export_data).decode()
|
||||
export.save(update_fields=['extra_data'])
|
||||
notify_realm_export(user_profile)
|
||||
|
|
|
@ -180,9 +180,9 @@ def handle_digest_email(user_profile_id: int, cutoff: float,
|
|||
context = common_context(user_profile)
|
||||
|
||||
# Start building email template data.
|
||||
context.update({
|
||||
'unsubscribe_link': one_click_unsubscribe_link(user_profile, "digest"),
|
||||
})
|
||||
context.update(
|
||||
unsubscribe_link=one_click_unsubscribe_link(user_profile, "digest"),
|
||||
)
|
||||
|
||||
home_view_streams = Subscription.objects.filter(
|
||||
user_profile=user_profile,
|
||||
|
|
|
@ -367,32 +367,32 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile,
|
|||
# we find a clean way to add it back in the future
|
||||
unsubscribe_link = one_click_unsubscribe_link(user_profile, "missed_messages")
|
||||
context = common_context(user_profile)
|
||||
context.update({
|
||||
'name': user_profile.full_name,
|
||||
'message_count': message_count,
|
||||
'unsubscribe_link': unsubscribe_link,
|
||||
'realm_name_in_notifications': user_profile.realm_name_in_notifications,
|
||||
})
|
||||
context.update(
|
||||
name=user_profile.full_name,
|
||||
message_count=message_count,
|
||||
unsubscribe_link=unsubscribe_link,
|
||||
realm_name_in_notifications=user_profile.realm_name_in_notifications,
|
||||
)
|
||||
|
||||
triggers = [message['trigger'] for message in missed_messages]
|
||||
unique_triggers = set(triggers)
|
||||
context.update({
|
||||
'mention': 'mentioned' in unique_triggers or 'wildcard_mentioned' in unique_triggers,
|
||||
'stream_email_notify': 'stream_email_notify' in unique_triggers,
|
||||
'mention_count': triggers.count('mentioned') + triggers.count("wildcard_mentioned"),
|
||||
})
|
||||
context.update(
|
||||
mention='mentioned' in unique_triggers or 'wildcard_mentioned' in unique_triggers,
|
||||
stream_email_notify='stream_email_notify' in unique_triggers,
|
||||
mention_count=triggers.count('mentioned') + triggers.count("wildcard_mentioned"),
|
||||
)
|
||||
|
||||
# If this setting (email mirroring integration) is enabled, only then
|
||||
# can users reply to email to send message to Zulip. Thus, one must
|
||||
# ensure to display warning in the template.
|
||||
if settings.EMAIL_GATEWAY_PATTERN:
|
||||
context.update({
|
||||
'reply_to_zulip': True,
|
||||
})
|
||||
context.update(
|
||||
reply_to_zulip=True,
|
||||
)
|
||||
else:
|
||||
context.update({
|
||||
'reply_to_zulip': False,
|
||||
})
|
||||
context.update(
|
||||
reply_to_zulip=False,
|
||||
)
|
||||
|
||||
from zerver.lib.email_mirror import create_missed_message_address
|
||||
reply_to_address = create_missed_message_address(user_profile, missed_messages[0]['message'])
|
||||
|
@ -402,9 +402,9 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile,
|
|||
reply_to_name = "Zulip"
|
||||
|
||||
narrow_url = get_narrow_url(user_profile, missed_messages[0]['message'])
|
||||
context.update({
|
||||
'narrow_url': narrow_url,
|
||||
})
|
||||
context.update(
|
||||
narrow_url=narrow_url,
|
||||
)
|
||||
|
||||
senders = list({m['message'].sender for m in missed_messages})
|
||||
if (missed_messages[0]['message'].recipient.type == Recipient.HUDDLE):
|
||||
|
@ -413,19 +413,19 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile,
|
|||
assert not isinstance(display_recipient, str)
|
||||
other_recipients = [r['full_name'] for r in display_recipient
|
||||
if r['id'] != user_profile.id]
|
||||
context.update({'group_pm': True})
|
||||
context.update(group_pm=True)
|
||||
if len(other_recipients) == 2:
|
||||
huddle_display_name = " and ".join(other_recipients)
|
||||
context.update({'huddle_display_name': huddle_display_name})
|
||||
context.update(huddle_display_name=huddle_display_name)
|
||||
elif len(other_recipients) == 3:
|
||||
huddle_display_name = f"{other_recipients[0]}, {other_recipients[1]}, and {other_recipients[2]}"
|
||||
context.update({'huddle_display_name': huddle_display_name})
|
||||
context.update(huddle_display_name=huddle_display_name)
|
||||
else:
|
||||
huddle_display_name = "{}, and {} others".format(
|
||||
', '.join(other_recipients[:2]), len(other_recipients) - 2)
|
||||
context.update({'huddle_display_name': huddle_display_name})
|
||||
context.update(huddle_display_name=huddle_display_name)
|
||||
elif (missed_messages[0]['message'].recipient.type == Recipient.PERSONAL):
|
||||
context.update({'private_message': True})
|
||||
context.update(private_message=True)
|
||||
elif (context['mention'] or context['stream_email_notify']):
|
||||
# Keep only the senders who actually mentioned the user
|
||||
if context['mention']:
|
||||
|
@ -435,32 +435,32 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile,
|
|||
message = missed_messages[0]['message']
|
||||
stream = Stream.objects.only('id', 'name').get(id=message.recipient.type_id)
|
||||
stream_header = f"{stream.name} > {message.topic_name()}"
|
||||
context.update({
|
||||
'stream_header': stream_header,
|
||||
})
|
||||
context.update(
|
||||
stream_header=stream_header,
|
||||
)
|
||||
else:
|
||||
raise AssertionError("Invalid messages!")
|
||||
|
||||
# If message content is disabled, then flush all information we pass to email.
|
||||
if not message_content_allowed_in_missedmessage_emails(user_profile):
|
||||
realm = user_profile.realm
|
||||
context.update({
|
||||
'reply_to_zulip': False,
|
||||
'messages': [],
|
||||
'sender_str': "",
|
||||
'realm_str': realm.name,
|
||||
'huddle_display_name': "",
|
||||
'show_message_content': False,
|
||||
'message_content_disabled_by_user': not user_profile.message_content_in_email_notifications,
|
||||
'message_content_disabled_by_realm': not realm.message_content_allowed_in_email_notifications,
|
||||
})
|
||||
context.update(
|
||||
reply_to_zulip=False,
|
||||
messages=[],
|
||||
sender_str="",
|
||||
realm_str=realm.name,
|
||||
huddle_display_name="",
|
||||
show_message_content=False,
|
||||
message_content_disabled_by_user=not user_profile.message_content_in_email_notifications,
|
||||
message_content_disabled_by_realm=not realm.message_content_allowed_in_email_notifications,
|
||||
)
|
||||
else:
|
||||
context.update({
|
||||
'messages': build_message_list(user_profile, [m['message'] for m in missed_messages]),
|
||||
'sender_str': ", ".join(sender.full_name for sender in senders),
|
||||
'realm_str': user_profile.realm.name,
|
||||
'show_message_content': True,
|
||||
})
|
||||
context.update(
|
||||
messages=build_message_list(user_profile, [m['message'] for m in missed_messages]),
|
||||
sender_str=", ".join(sender.full_name for sender in senders),
|
||||
realm_str=user_profile.realm.name,
|
||||
show_message_content=True,
|
||||
)
|
||||
|
||||
with override_language(user_profile.default_language):
|
||||
from_name: str = _("Zulip missed messages")
|
||||
|
@ -476,9 +476,9 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile,
|
|||
# EMAIL_ADDRESS_VISIBILITY_ADMINS.
|
||||
sender = senders[0]
|
||||
from_name, from_address = (sender.full_name, sender.email)
|
||||
context.update({
|
||||
'reply_to_zulip': False,
|
||||
})
|
||||
context.update(
|
||||
reply_to_zulip=False,
|
||||
)
|
||||
|
||||
email_dict = {
|
||||
'template_prefix': 'zerver/emails/missed_message',
|
||||
|
@ -598,14 +598,14 @@ def enqueue_welcome_emails(user: UserProfile, realm_creation: bool=False) -> Non
|
|||
delivery_email__iexact=user.delivery_email).exclude(id=user.id).count()
|
||||
unsubscribe_link = one_click_unsubscribe_link(user, "welcome")
|
||||
context = common_context(user)
|
||||
context.update({
|
||||
'unsubscribe_link': unsubscribe_link,
|
||||
'keyboard_shortcuts_link': user.realm.uri + '/help/keyboard-shortcuts',
|
||||
'realm_name': user.realm.name,
|
||||
'realm_creation': realm_creation,
|
||||
'email': user.delivery_email,
|
||||
'is_realm_admin': user.role == UserProfile.ROLE_REALM_ADMINISTRATOR,
|
||||
})
|
||||
context.update(
|
||||
unsubscribe_link=unsubscribe_link,
|
||||
keyboard_shortcuts_link=user.realm.uri + '/help/keyboard-shortcuts',
|
||||
realm_name=user.realm.name,
|
||||
realm_creation=realm_creation,
|
||||
email=user.delivery_email,
|
||||
is_realm_admin=user.role == UserProfile.ROLE_REALM_ADMINISTRATOR,
|
||||
)
|
||||
if user.is_realm_admin:
|
||||
context['getting_started_link'] = (user.realm.uri +
|
||||
'/help/getting-your-organization-started-with-zulip')
|
||||
|
|
|
@ -107,7 +107,7 @@ def messages_for_ids(message_ids: List[int],
|
|||
|
||||
for message_id in message_ids:
|
||||
msg_dict = message_dicts[message_id]
|
||||
msg_dict.update({"flags": user_message_flags[message_id]})
|
||||
msg_dict.update(flags=user_message_flags[message_id])
|
||||
if message_id in search_fields:
|
||||
msg_dict.update(search_fields[message_id])
|
||||
# Make sure that we never send message edit history to clients
|
||||
|
|
|
@ -661,9 +661,9 @@ def get_apns_badge_count_future(user_profile: UserProfile, read_messages_ids: Op
|
|||
def get_message_payload_apns(user_profile: UserProfile, message: Message) -> Dict[str, Any]:
|
||||
'''A `message` payload for iOS, via APNs.'''
|
||||
zulip_data = get_message_payload(user_profile, message)
|
||||
zulip_data.update({
|
||||
'message_ids': [message.id],
|
||||
})
|
||||
zulip_data.update(
|
||||
message_ids=[message.id],
|
||||
)
|
||||
|
||||
assert message.rendered_content is not None
|
||||
content, _ = truncate_content(get_mobile_push_content(message.rendered_content))
|
||||
|
@ -686,16 +686,16 @@ def get_message_payload_gcm(
|
|||
data = get_message_payload(user_profile, message)
|
||||
assert message.rendered_content is not None
|
||||
content, truncated = truncate_content(get_mobile_push_content(message.rendered_content))
|
||||
data.update({
|
||||
'event': 'message',
|
||||
'alert': get_gcm_alert(message),
|
||||
'zulip_message_id': message.id, # message_id is reserved for CCS
|
||||
'time': datetime_to_timestamp(message.date_sent),
|
||||
'content': content,
|
||||
'content_truncated': truncated,
|
||||
'sender_full_name': message.sender.full_name,
|
||||
'sender_avatar_url': absolute_avatar_url(message.sender),
|
||||
})
|
||||
data.update(
|
||||
event='message',
|
||||
alert=get_gcm_alert(message),
|
||||
zulip_message_id=message.id, # message_id is reserved for CCS
|
||||
time=datetime_to_timestamp(message.date_sent),
|
||||
content=content,
|
||||
content_truncated=truncated,
|
||||
sender_full_name=message.sender.full_name,
|
||||
sender_avatar_url=absolute_avatar_url(message.sender),
|
||||
)
|
||||
gcm_options = {'priority': 'high'}
|
||||
return data, gcm_options
|
||||
|
||||
|
@ -704,22 +704,22 @@ def get_remove_payload_gcm(
|
|||
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
|
||||
'''A `remove` payload + options, for Android via GCM/FCM.'''
|
||||
gcm_payload = get_base_payload(user_profile)
|
||||
gcm_payload.update({
|
||||
'event': 'remove',
|
||||
'zulip_message_ids': ','.join(str(id) for id in message_ids),
|
||||
gcm_payload.update(
|
||||
event='remove',
|
||||
zulip_message_ids=','.join(str(id) for id in message_ids),
|
||||
# Older clients (all clients older than 2019-02-13) look only at
|
||||
# `zulip_message_id` and ignore `zulip_message_ids`. Do our best.
|
||||
'zulip_message_id': message_ids[0],
|
||||
})
|
||||
zulip_message_id=message_ids[0],
|
||||
)
|
||||
gcm_options = {'priority': 'normal'}
|
||||
return gcm_payload, gcm_options
|
||||
|
||||
def get_remove_payload_apns(user_profile: UserProfile, message_ids: List[int]) -> Dict[str, Any]:
|
||||
zulip_data = get_base_payload(user_profile)
|
||||
zulip_data.update({
|
||||
'event': 'remove',
|
||||
'zulip_message_ids': ','.join(str(id) for id in message_ids),
|
||||
})
|
||||
zulip_data.update(
|
||||
event='remove',
|
||||
zulip_message_ids=','.join(str(id) for id in message_ids),
|
||||
)
|
||||
apns_data = {
|
||||
'badge': get_apns_badge_count(user_profile, message_ids),
|
||||
'custom': {'zulip': zulip_data},
|
||||
|
|
|
@ -221,7 +221,7 @@ class MatterMostImporter(ZulipTestCase):
|
|||
self.assertEqual(subscriber_handler.get_users(stream_id=stream_id_mapper.get("dumbledores-army")), {ron_id, harry_id})
|
||||
|
||||
# Converting channel data when a user's `teams` value is `null`.
|
||||
username_to_user["ron"].update({"teams": None})
|
||||
username_to_user["ron"].update(teams=None)
|
||||
zerver_stream = convert_channel_data(
|
||||
channel_data=mattermost_data["channel"],
|
||||
user_data_map=username_to_user,
|
||||
|
@ -417,7 +417,7 @@ class MatterMostImporter(ZulipTestCase):
|
|||
self.assertFalse(check_user_in_team(snape, "gryffindor"))
|
||||
self.assertTrue(check_user_in_team(snape, "slytherin"))
|
||||
|
||||
snape.update({"teams": None})
|
||||
snape.update(teams=None)
|
||||
self.assertFalse(check_user_in_team(snape, "slytherin"))
|
||||
|
||||
def test_label_mirror_dummy_users(self) -> None:
|
||||
|
|
|
@ -1094,7 +1094,7 @@ class GetOldMessagesTest(ZulipTestCase):
|
|||
for message in result["messages"]:
|
||||
assert(message["id"] in message_ids)
|
||||
|
||||
post_params.update({"num_before": len(message_ids[pivot_index:])})
|
||||
post_params.update(num_before=len(message_ids[pivot_index:]))
|
||||
|
||||
with first_visible_id_as(message_ids[pivot_index]):
|
||||
payload = self.client_get("/json/messages", dict(post_params))
|
||||
|
|
|
@ -1476,12 +1476,12 @@ so we didn't send them an invitation. We did send invitations to everyone else!"
|
|||
referrer = self.example_user(referrer_name)
|
||||
link = create_confirmation_link(invitee, Confirmation.INVITATION)
|
||||
context = common_context(referrer)
|
||||
context.update({
|
||||
'activate_url': link,
|
||||
'referrer_name': referrer.full_name,
|
||||
'referrer_email': referrer.email,
|
||||
'referrer_realm_name': referrer.realm.name,
|
||||
})
|
||||
context.update(
|
||||
activate_url=link,
|
||||
referrer_name=referrer.full_name,
|
||||
referrer_email=referrer.email,
|
||||
referrer_realm_name=referrer.realm.name,
|
||||
)
|
||||
with self.settings(EMAIL_BACKEND='django.core.mail.backends.console.EmailBackend'):
|
||||
email = data["email"]
|
||||
send_future_email(
|
||||
|
|
|
@ -16,5 +16,5 @@ def digest_page(request: HttpRequest) -> HttpResponse:
|
|||
cutoff = time.mktime((timezone_now() - timedelta(days=DIGEST_CUTOFF)).timetuple())
|
||||
context = handle_digest_email(user_profile_id, cutoff, render_to_web=True)
|
||||
if context:
|
||||
context.update({'physical_address': settings.PHYSICAL_ADDRESS})
|
||||
context.update(physical_address=settings.PHYSICAL_ADDRESS)
|
||||
return render(request, 'zerver/digest_base.html', context=context)
|
||||
|
|
|
@ -258,7 +258,7 @@ def accounts_register(request: HttpRequest) -> HttpResponse:
|
|||
# verified name from you on file, use that. Otherwise, fall
|
||||
# back to the full name in the request.
|
||||
try:
|
||||
postdata.update({'full_name': request.session['authenticated_full_name']})
|
||||
postdata.update(full_name=request.session['authenticated_full_name'])
|
||||
name_validated = True
|
||||
except KeyError:
|
||||
pass
|
||||
|
@ -573,9 +573,9 @@ def accounts_home(request: HttpRequest, multiuse_object_key: str="",
|
|||
else:
|
||||
form = HomepageForm(realm=realm)
|
||||
context = login_context(request)
|
||||
context.update({'form': form, 'current_url': request.get_full_path,
|
||||
'multiuse_object_key': multiuse_object_key,
|
||||
'from_multiuse_invite': from_multiuse_invite})
|
||||
context.update(form=form, current_url=request.get_full_path,
|
||||
multiuse_object_key=multiuse_object_key,
|
||||
from_multiuse_invite=from_multiuse_invite)
|
||||
return render(request, 'zerver/accounts_home.html', context=context)
|
||||
|
||||
def accounts_home_from_multiuse_invite(request: HttpRequest, confirmation_key: str) -> HttpResponse:
|
||||
|
@ -613,9 +613,9 @@ def find_account(request: HttpRequest) -> HttpResponse:
|
|||
emails_q, is_active=True, is_bot=False,
|
||||
realm__deactivated=False):
|
||||
context = common_context(user)
|
||||
context.update({
|
||||
'email': user.delivery_email,
|
||||
})
|
||||
context.update(
|
||||
email=user.delivery_email,
|
||||
)
|
||||
send_email('zerver/emails/find_team', to_user_ids=[user.id], context=context,
|
||||
from_address=FromAddress.SUPPORT)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ def process_unsubscribe(request: HttpRequest, confirmation_key: str, subscriptio
|
|||
|
||||
unsubscribe_function(user_profile)
|
||||
context = common_context(user_profile)
|
||||
context.update({"subscription_type": subscription_type})
|
||||
context.update(subscription_type=subscription_type)
|
||||
return render(request, 'zerver/unsubscribe_success.html', context=context)
|
||||
|
||||
# Email unsubscribe functions. All have the function signature
|
||||
|
|
|
@ -367,10 +367,10 @@ def get_story_update_attachment_body(payload: Dict[str, Any]) -> Optional[str]:
|
|||
file_id = file_ids_added[0]
|
||||
for ref in payload["references"]:
|
||||
if ref["id"] == file_id:
|
||||
kwargs.update({
|
||||
"type": ref["entity_type"],
|
||||
"file_name": ref["name"],
|
||||
})
|
||||
kwargs.update(
|
||||
type=ref["entity_type"],
|
||||
file_name=ref["name"],
|
||||
)
|
||||
|
||||
return FILE_ATTACHMENT_TEMPLATE.format(**kwargs)
|
||||
|
||||
|
@ -401,7 +401,7 @@ def get_story_label_body(payload: Dict[str, Any]) -> Optional[str]:
|
|||
if reference["id"] == label_id:
|
||||
label_name = reference.get('name', '')
|
||||
|
||||
kwargs.update({"label_name": label_name})
|
||||
kwargs.update(label_name=label_name)
|
||||
|
||||
return STORY_LABEL_TEMPLATE.format(**kwargs)
|
||||
|
||||
|
@ -418,9 +418,9 @@ def get_story_update_project_body(payload: Dict[str, Any]) -> str:
|
|||
old_project_id = action["changes"]["project_id"]["old"]
|
||||
for ref in payload["references"]:
|
||||
if ref["id"] == new_project_id:
|
||||
kwargs.update({"new": ref["name"]})
|
||||
kwargs.update(new=ref["name"])
|
||||
if ref["id"] == old_project_id:
|
||||
kwargs.update({"old": ref["name"]})
|
||||
kwargs.update(old=ref["name"])
|
||||
|
||||
return STORY_UPDATE_PROJECT_TEMPLATE.format(**kwargs)
|
||||
|
||||
|
|
|
@ -133,18 +133,18 @@ def handle_event_payload(event: Dict[str, Any]) -> Tuple[str, str]:
|
|||
|
||||
post_context = convert_lines_to_traceback_string(exception_frame["post_context"])
|
||||
|
||||
context.update({
|
||||
"syntax_highlight_as": syntax_highlight_as,
|
||||
"filename": filename,
|
||||
"pre_context": pre_context,
|
||||
"context_line": context_line,
|
||||
"post_context": post_context,
|
||||
})
|
||||
context.update(
|
||||
syntax_highlight_as=syntax_highlight_as,
|
||||
filename=filename,
|
||||
pre_context=pre_context,
|
||||
context_line=context_line,
|
||||
post_context=post_context,
|
||||
)
|
||||
|
||||
body = EXCEPTION_EVENT_TEMPLATE_WITH_TRACEBACK.format(**context)
|
||||
return (subject, body)
|
||||
|
||||
context.update({"filename": filename}) # nocoverage
|
||||
context.update(filename=filename) # nocoverage
|
||||
body = EXCEPTION_EVENT_TEMPLATE.format(**context) # nocoverage
|
||||
return (subject, body) # nocoverage
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ def parse_change_event(change_type: str, message: Mapping[str, Any]) -> Optional
|
|||
values["old"] = old
|
||||
else:
|
||||
event_type = "changed_" + change_type
|
||||
values.update({'old': old, 'new': new})
|
||||
values.update(old=old, new=new)
|
||||
|
||||
elif change_type == "is_blocked":
|
||||
if message["change"]["diff"]["is_blocked"]["to"]:
|
||||
|
@ -233,12 +233,12 @@ def parse_change_event(change_type: str, message: Mapping[str, Any]) -> Optional
|
|||
elif change_type == "user_story":
|
||||
old, new = get_old_and_new_values(change_type, message)
|
||||
event_type = "changed_us"
|
||||
values.update({'old': old, 'new': new})
|
||||
values.update(old=old, new=new)
|
||||
|
||||
elif change_type in ["subject", 'name']:
|
||||
event_type = 'renamed'
|
||||
old, new = get_old_and_new_values(change_type, message)
|
||||
values.update({'old': old, 'new': new})
|
||||
values.update(old=old, new=new)
|
||||
|
||||
elif change_type in ["estimated_finish", "estimated_start", "due_date"]:
|
||||
old, new = get_old_and_new_values(change_type, message)
|
||||
|
@ -247,7 +247,7 @@ def parse_change_event(change_type: str, message: Mapping[str, Any]) -> Optional
|
|||
values["new"] = new
|
||||
elif not old == new:
|
||||
event_type = change_type
|
||||
values.update({'old': old, 'new': new})
|
||||
values.update(old=old, new=new)
|
||||
else:
|
||||
# date hasn't changed
|
||||
return None
|
||||
|
@ -255,13 +255,13 @@ def parse_change_event(change_type: str, message: Mapping[str, Any]) -> Optional
|
|||
elif change_type in ["priority", "severity", "type", "status"]:
|
||||
event_type = 'changed_' + change_type
|
||||
old, new = get_old_and_new_values(change_type, message)
|
||||
values.update({'old': old, 'new': new})
|
||||
values.update(old=old, new=new)
|
||||
|
||||
else:
|
||||
# we are not supporting this type of event
|
||||
return None
|
||||
|
||||
evt.update({"type": message["type"], "event": event_type, "values": values})
|
||||
evt.update(type=message["type"], event=event_type, values=values)
|
||||
return evt
|
||||
|
||||
def parse_webhook_test(message: Mapping[str, Any]) -> Dict[str, Any]:
|
||||
|
|
|
@ -352,12 +352,12 @@ class ConfirmationEmailWorker(QueueProcessingWorker):
|
|||
# queue invitation reminder
|
||||
if settings.INVITATION_LINK_VALIDITY_DAYS >= 4:
|
||||
context = common_context(referrer)
|
||||
context.update({
|
||||
'activate_url': activate_url,
|
||||
'referrer_name': referrer.full_name,
|
||||
'referrer_email': referrer.delivery_email,
|
||||
'referrer_realm_name': referrer.realm.name,
|
||||
})
|
||||
context.update(
|
||||
activate_url=activate_url,
|
||||
referrer_name=referrer.full_name,
|
||||
referrer_email=referrer.delivery_email,
|
||||
referrer_realm_name=referrer.realm.name,
|
||||
)
|
||||
send_future_email(
|
||||
"zerver/emails/invitation_reminder",
|
||||
referrer.realm,
|
||||
|
|
|
@ -296,19 +296,19 @@ DATABASES: Dict[str, Dict[str, Any]] = {"default": {
|
|||
|
||||
if DEVELOPMENT:
|
||||
LOCAL_DATABASE_PASSWORD = get_secret("local_database_password")
|
||||
DATABASES["default"].update({
|
||||
'PASSWORD': LOCAL_DATABASE_PASSWORD,
|
||||
'HOST': 'localhost',
|
||||
})
|
||||
DATABASES["default"].update(
|
||||
PASSWORD=LOCAL_DATABASE_PASSWORD,
|
||||
HOST='localhost',
|
||||
)
|
||||
elif REMOTE_POSTGRES_HOST != '':
|
||||
DATABASES['default'].update({
|
||||
'HOST': REMOTE_POSTGRES_HOST,
|
||||
'PORT': REMOTE_POSTGRES_PORT,
|
||||
})
|
||||
DATABASES['default'].update(
|
||||
HOST=REMOTE_POSTGRES_HOST,
|
||||
PORT=REMOTE_POSTGRES_PORT,
|
||||
)
|
||||
if get_secret("postgres_password") is not None:
|
||||
DATABASES['default'].update({
|
||||
'PASSWORD': get_secret("postgres_password"),
|
||||
})
|
||||
DATABASES['default'].update(
|
||||
PASSWORD=get_secret("postgres_password"),
|
||||
)
|
||||
if REMOTE_POSTGRES_SSLMODE != '':
|
||||
DATABASES['default']['OPTIONS']['sslmode'] = REMOTE_POSTGRES_SSLMODE
|
||||
else:
|
||||
|
@ -599,9 +599,9 @@ base_template_engine_settings: Dict[str, Any] = {
|
|||
}
|
||||
|
||||
default_template_engine_settings = deepcopy(base_template_engine_settings)
|
||||
default_template_engine_settings.update({
|
||||
'NAME': 'Jinja2',
|
||||
'DIRS': [
|
||||
default_template_engine_settings.update(
|
||||
NAME='Jinja2',
|
||||
DIRS=[
|
||||
# The main templates directory
|
||||
os.path.join(DEPLOY_ROOT, 'templates'),
|
||||
# The webhook integration templates
|
||||
|
@ -609,20 +609,20 @@ default_template_engine_settings.update({
|
|||
# The python-zulip-api:zulip_bots package templates
|
||||
os.path.join('static' if DEBUG else STATIC_ROOT, 'generated', 'bots'),
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
})
|
||||
APP_DIRS=True,
|
||||
)
|
||||
|
||||
non_html_template_engine_settings = deepcopy(base_template_engine_settings)
|
||||
non_html_template_engine_settings.update({
|
||||
'NAME': 'Jinja2_plaintext',
|
||||
'DIRS': [os.path.join(DEPLOY_ROOT, 'templates')],
|
||||
'APP_DIRS': False,
|
||||
})
|
||||
non_html_template_engine_settings['OPTIONS'].update({
|
||||
'autoescape': False,
|
||||
'trim_blocks': True,
|
||||
'lstrip_blocks': True,
|
||||
})
|
||||
non_html_template_engine_settings.update(
|
||||
NAME='Jinja2_plaintext',
|
||||
DIRS=[os.path.join(DEPLOY_ROOT, 'templates')],
|
||||
APP_DIRS=False,
|
||||
)
|
||||
non_html_template_engine_settings['OPTIONS'].update(
|
||||
autoescape=False,
|
||||
trim_blocks=True,
|
||||
lstrip_blocks=True,
|
||||
)
|
||||
|
||||
# django-two-factor uses the default Django template engine (not Jinja2), so we
|
||||
# need to add config for it here.
|
||||
|
|
|
@ -14,17 +14,17 @@ from zerver.templatetags.app_filters import display_list, render_markdown_path
|
|||
|
||||
def environment(**options: Any) -> Environment:
|
||||
env = Environment(**options)
|
||||
env.globals.update({
|
||||
'default_page_params': {
|
||||
env.globals.update(
|
||||
default_page_params={
|
||||
'debug_mode': False,
|
||||
'webpack_public_path': staticfiles_storage.url(
|
||||
settings.WEBPACK_LOADER['DEFAULT']['BUNDLE_DIR_NAME'],
|
||||
),
|
||||
},
|
||||
'static': staticfiles_storage.url,
|
||||
'url': reverse,
|
||||
'render_markdown_path': render_markdown_path,
|
||||
})
|
||||
static=staticfiles_storage.url,
|
||||
url=reverse,
|
||||
render_markdown_path=render_markdown_path,
|
||||
)
|
||||
|
||||
env.install_gettext_translations(translation, True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue