From a9783367651f823d7cccd883c2a4e80f4d9ec373 Mon Sep 17 00:00:00 2001 From: Vishnu Ks Date: Sat, 13 Jan 2018 18:37:13 +0000 Subject: [PATCH] billing: Create model for customers paying with Stripe. [greg: reduced migration dependencies, revised commit message.] --- zilencer/migrations/0006_customer.py | 25 +++++++++++++++++++++++++ zilencer/models.py | 8 ++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 zilencer/migrations/0006_customer.py diff --git a/zilencer/migrations/0006_customer.py b/zilencer/migrations/0006_customer.py new file mode 100644 index 0000000000..0c3c3e37a6 --- /dev/null +++ b/zilencer/migrations/0006_customer.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.6 on 2018-01-13 11:54 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('zilencer', '0005_remotepushdevicetoken_fix_uniqueness'), + ('zerver', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Customer', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('stripe_customer_id', models.CharField(max_length=255, unique=True)), + ('realm', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='zerver.Realm')), + ], + ), + ] diff --git a/zilencer/models.py b/zilencer/models.py index a1b7f3295a..79c2ab5d8f 100644 --- a/zilencer/models.py +++ b/zilencer/models.py @@ -3,7 +3,7 @@ from typing import Text from django.db import models -import zerver.models +from zerver.models import AbstractPushDeviceToken, Realm def get_remote_server_by_uuid(uuid: Text) -> 'RemoteZulipServer': return RemoteZulipServer.objects.get(uuid=uuid) @@ -17,7 +17,7 @@ class RemoteZulipServer(models.Model): last_updated = models.DateTimeField('last updated', auto_now=True) # type: datetime.datetime # Variant of PushDeviceToken for a remote server. -class RemotePushDeviceToken(zerver.models.AbstractPushDeviceToken): +class RemotePushDeviceToken(AbstractPushDeviceToken): server = models.ForeignKey(RemoteZulipServer) # type: RemoteZulipServer # The user id on the remote server for this device device this is user_id = models.BigIntegerField(db_index=True) # type: int @@ -25,3 +25,7 @@ class RemotePushDeviceToken(zerver.models.AbstractPushDeviceToken): class Meta: unique_together = ("server", "token") + +class Customer(models.Model): + stripe_customer_id = models.CharField(max_length=255, unique=True) + realm = models.OneToOneField(Realm)