mirror of
https://github.com/zulip/zulip.git
synced 2025-11-22 07:21:23 +00:00
lint: Ban general use of user_profile.save().
This often can cause minor caching problems. Obviously, it'd be better if we had access to the AST and thus could do this rule for UserProfile objects in general.
This commit is contained in:
@@ -241,6 +241,14 @@ def build_custom_checkers(by_lang):
|
||||
'description': '@login_required is unsupported; use @zulip_login_required',
|
||||
'good_lines': ['@zulip_login_required', '# foo @login_required'],
|
||||
'bad_lines': ['@login_required', ' @login_required']},
|
||||
{'pattern': '^user_profile[.]save[(][)]',
|
||||
'description': 'Always pass update_fields when saving user_profile objects',
|
||||
'exclude_line': set([
|
||||
('zerver/lib/actions.py', "user_profile.save() # Can't use update_fields because of how the foreign key works."),
|
||||
]),
|
||||
'exclude': set(['zerver/tests', 'zerver/lib/create_user.py']),
|
||||
'good_lines': ['user_profile.save(update_fields=["pointer"])'],
|
||||
'bad_lines': ['user_profile.save()']},
|
||||
{'pattern': '^[^"]*"[^"]*"%\(',
|
||||
'description': 'Missing space around "%"',
|
||||
'good_lines': ['"%s" % ("foo")', '"%s" % (foo)'],
|
||||
|
||||
@@ -2529,7 +2529,7 @@ def check_change_full_name(user_profile, full_name_raw, acting_user):
|
||||
def do_change_bot_owner(user_profile, bot_owner, acting_user):
|
||||
# type: (UserProfile, UserProfile, UserProfile) -> None
|
||||
user_profile.bot_owner = bot_owner
|
||||
user_profile.save()
|
||||
user_profile.save() # Can't use update_fields because of how the foreign key works.
|
||||
event_time = timezone_now()
|
||||
RealmAuditLog.objects.create(realm=user_profile.realm, acting_user=acting_user,
|
||||
modified_user=user_profile, event_type='bot_owner_changed',
|
||||
|
||||
@@ -88,9 +88,10 @@ def generate_all_emails(request):
|
||||
user_profile = get_user(registered_email, realm)
|
||||
result = client.get(url)
|
||||
assert result.status_code == 200
|
||||
# Reset the email value
|
||||
|
||||
# Reset the email value so we can run this again
|
||||
user_profile.email = registered_email
|
||||
user_profile.save()
|
||||
user_profile.save(update_fields=['email'])
|
||||
|
||||
# Follow up day1 day2 emails
|
||||
enqueue_welcome_emails(user_profile)
|
||||
|
||||
Reference in New Issue
Block a user