billing: Change do_change_plan_type to take a realm instead of a user.

More often than not, changes in plan type are not directly due to user
action.
This commit is contained in:
Rishi Gupta
2018-12-12 22:54:43 -08:00
committed by Tim Abbott
parent e7746809d2
commit b245c661da
4 changed files with 12 additions and 13 deletions

View File

@@ -3084,13 +3084,12 @@ def do_change_icon_source(realm: Realm, icon_source: str, log: bool=True) -> Non
icon_url=realm_icon_url(realm))),
active_user_ids(realm.id))
def do_change_plan_type(user: UserProfile, plan_type: int) -> None:
realm = user.realm
def do_change_plan_type(realm: Realm, plan_type: int) -> None:
old_value = realm.plan_type
realm.plan_type = plan_type
realm.save(update_fields=['plan_type'])
RealmAuditLog.objects.create(event_type=RealmAuditLog.REALM_PLAN_TYPE_CHANGED,
realm=realm, acting_user=user, event_time=timezone_now(),
realm=realm, event_time=timezone_now(),
extra_data={'old_value': old_value, 'new_value': plan_type})
if plan_type == Realm.STANDARD: