mirror of https://github.com/zulip/zulip.git
stripe: Create make_user_billing_admin helper function.
This commit is contained in:
parent
d5ba94082a
commit
3d5ee69b21
|
@ -299,8 +299,9 @@ def do_create_stripe_customer(user: UserProfile, stripe_token: Optional[str] = N
|
|||
customer, created = Customer.objects.update_or_create(
|
||||
realm=realm, defaults={"stripe_customer_id": stripe_customer.id}
|
||||
)
|
||||
user.is_billing_admin = True
|
||||
user.save(update_fields=["is_billing_admin"])
|
||||
from zerver.lib.actions import do_make_user_billing_admin
|
||||
|
||||
do_make_user_billing_admin(user)
|
||||
return customer
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ from zerver.decorator import (
|
|||
require_organization_member,
|
||||
zulip_login_required,
|
||||
)
|
||||
from zerver.lib.actions import do_make_user_billing_admin
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.send_email import FromAddress, send_email
|
||||
|
@ -260,8 +261,7 @@ def sponsorship(
|
|||
)
|
||||
|
||||
update_sponsorship_status(realm, True, acting_user=user)
|
||||
user.is_billing_admin = True
|
||||
user.save(update_fields=["is_billing_admin"])
|
||||
do_make_user_billing_admin(user)
|
||||
|
||||
return json_success()
|
||||
|
||||
|
|
|
@ -4559,6 +4559,11 @@ def do_change_user_role(
|
|||
send_event(user_profile.realm, event, active_user_ids(user_profile.realm_id))
|
||||
|
||||
|
||||
def do_make_user_billing_admin(user_profile: UserProfile) -> None:
|
||||
user_profile.is_billing_admin = True
|
||||
user_profile.save(update_fields=["is_billing_admin"])
|
||||
|
||||
|
||||
def do_change_can_forge_sender(user_profile: UserProfile, value: bool) -> None:
|
||||
user_profile.can_forge_sender = value
|
||||
user_profile.save(update_fields=["can_forge_sender"])
|
||||
|
|
Loading…
Reference in New Issue