django-2.0: Don't assign directly to Many-to-Many field.

The old pattern of setting the value and then using .save() here has
been deprecated.  set() also saves the record.
This commit is contained in:
rht
2018-01-31 12:22:07 +05:00
committed by Tim Abbott
parent e4a62aa778
commit 71ff8c370e
6 changed files with 7 additions and 14 deletions

View File

@@ -3053,8 +3053,7 @@ def do_create_default_stream_group(realm: Realm, group_name: Text,
raise JsonableError(_("Default stream group '%(group_name)s' already exists")
% {'group_name': group_name})
group.streams = streams
group.save()
group.streams.set(streams)
notify_default_stream_groups(realm)
def do_add_streams_to_default_stream_group(realm: Realm, group: DefaultStreamGroup,
@@ -4092,8 +4091,7 @@ def do_create_multiuse_invite_link(referred_by: UserProfile, streams: Optional[L
realm = referred_by.realm
invite = MultiuseInvite.objects.create(realm=realm, referred_by=referred_by)
if streams:
invite.streams = streams
invite.save()
invite.streams.set(streams)
return create_confirmation_link(invite, realm.host, Confirmation.MULTIUSE_INVITE)