mirror of https://github.com/zulip/zulip.git
billing: Remove Customer.billing_user.
This commit is contained in:
parent
dcb7b15069
commit
98dac0f0a9
|
@ -164,10 +164,7 @@ def do_create_customer(user: UserProfile, stripe_token: Optional[str]=None,
|
||||||
RealmAuditLog.objects.create(
|
RealmAuditLog.objects.create(
|
||||||
realm=user.realm, acting_user=user, event_type=RealmAuditLog.STRIPE_CARD_ADDED,
|
realm=user.realm, acting_user=user, event_type=RealmAuditLog.STRIPE_CARD_ADDED,
|
||||||
event_time=event_time)
|
event_time=event_time)
|
||||||
Customer.objects.create(
|
Customer.objects.create(realm=realm, stripe_customer_id=stripe_customer.id)
|
||||||
realm=realm,
|
|
||||||
stripe_customer_id=stripe_customer.id,
|
|
||||||
billing_user=user)
|
|
||||||
user.is_billing_admin = True
|
user.is_billing_admin = True
|
||||||
user.save(update_fields=["is_billing_admin"])
|
user.save(update_fields=["is_billing_admin"])
|
||||||
return stripe_customer
|
return stripe_customer
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.14 on 2018-08-22 06:31
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('zilencer', '0012_coupon'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='customer',
|
||||||
|
name='billing_user',
|
||||||
|
),
|
||||||
|
]
|
|
@ -43,8 +43,6 @@ class Customer(models.Model):
|
||||||
# goes back to being False
|
# goes back to being False
|
||||||
has_billing_relationship = models.BooleanField(default=False) # type: bool
|
has_billing_relationship = models.BooleanField(default=False) # type: bool
|
||||||
|
|
||||||
billing_user = models.ForeignKey(UserProfile, on_delete=models.SET_NULL, null=True)
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return "<Customer %s %s>" % (self.realm, self.stripe_customer_id)
|
return "<Customer %s %s>" % (self.realm, self.stripe_customer_id)
|
||||||
|
|
||||||
|
|
|
@ -136,9 +136,8 @@ class StripeTest(ZulipTestCase):
|
||||||
prorate=True,
|
prorate=True,
|
||||||
tax_percent=0)
|
tax_percent=0)
|
||||||
# Check that we correctly populated Customer and RealmAuditLog in Zulip
|
# Check that we correctly populated Customer and RealmAuditLog in Zulip
|
||||||
self.assertEqual(1, Customer.objects.filter(realm=user.realm,
|
self.assertEqual(1, Customer.objects.filter(stripe_customer_id=self.stripe_customer_id,
|
||||||
stripe_customer_id=self.stripe_customer_id,
|
realm=user.realm).count())
|
||||||
billing_user=user).count())
|
|
||||||
audit_log_entries = list(RealmAuditLog.objects.filter(acting_user=user)
|
audit_log_entries = list(RealmAuditLog.objects.filter(acting_user=user)
|
||||||
.values_list('event_type', 'event_time').order_by('id'))
|
.values_list('event_type', 'event_time').order_by('id'))
|
||||||
self.assertEqual(audit_log_entries, [
|
self.assertEqual(audit_log_entries, [
|
||||||
|
@ -318,7 +317,7 @@ class StripeTest(ZulipTestCase):
|
||||||
self.assertEqual('/upgrade/', response.url)
|
self.assertEqual('/upgrade/', response.url)
|
||||||
|
|
||||||
Customer.objects.create(
|
Customer.objects.create(
|
||||||
realm=user.realm, stripe_customer_id=self.stripe_customer_id, billing_user=user,
|
realm=user.realm, stripe_customer_id=self.stripe_customer_id,
|
||||||
has_billing_relationship=True)
|
has_billing_relationship=True)
|
||||||
|
|
||||||
response = self.client_get("/billing/")
|
response = self.client_get("/billing/")
|
||||||
|
|
Loading…
Reference in New Issue