billing: Create model for customers paying with Stripe.

[greg: reduced migration dependencies, revised commit message.]
This commit is contained in:
Vishnu Ks 2018-01-13 18:37:13 +00:00 committed by Greg Price
parent 167a712922
commit a978336765
2 changed files with 31 additions and 2 deletions

View File

@ -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')),
],
),
]

View File

@ -3,7 +3,7 @@ from typing import Text
from django.db import models from django.db import models
import zerver.models from zerver.models import AbstractPushDeviceToken, Realm
def get_remote_server_by_uuid(uuid: Text) -> 'RemoteZulipServer': def get_remote_server_by_uuid(uuid: Text) -> 'RemoteZulipServer':
return RemoteZulipServer.objects.get(uuid=uuid) 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 last_updated = models.DateTimeField('last updated', auto_now=True) # type: datetime.datetime
# Variant of PushDeviceToken for a remote server. # Variant of PushDeviceToken for a remote server.
class RemotePushDeviceToken(zerver.models.AbstractPushDeviceToken): class RemotePushDeviceToken(AbstractPushDeviceToken):
server = models.ForeignKey(RemoteZulipServer) # type: RemoteZulipServer server = models.ForeignKey(RemoteZulipServer) # type: RemoteZulipServer
# The user id on the remote server for this device device this is # The user id on the remote server for this device device this is
user_id = models.BigIntegerField(db_index=True) # type: int user_id = models.BigIntegerField(db_index=True) # type: int
@ -25,3 +25,7 @@ class RemotePushDeviceToken(zerver.models.AbstractPushDeviceToken):
class Meta: class Meta:
unique_together = ("server", "token") unique_together = ("server", "token")
class Customer(models.Model):
stripe_customer_id = models.CharField(max_length=255, unique=True)
realm = models.OneToOneField(Realm)