Stripe in Blender Studio #93018

Merged
Anna Sirota merged 9 commits from studio-to-stripe into main 2024-06-17 17:39:10 +02:00
Showing only changes of commit b0a34fa6f0 - Show all commits

View File

@ -4,6 +4,9 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
from django.contrib.auth import get_user_model
User = get_user_model()
user_table = User.objects.model._meta.db_table
dependencies = [ dependencies = [
('looper', '0077_revenueperplan'), ('looper', '0077_revenueperplan'),
@ -25,10 +28,20 @@ class Migration(migrations.Migration):
name='vat_number', name='vat_number',
field=models.CharField(blank=True, default='', max_length=255, verbose_name='VAT identification number'), field=models.CharField(blank=True, default='', max_length=255, verbose_name='VAT identification number'),
), ),
migrations.RunSQL('SET CONSTRAINTS ALL IMMEDIATE;'),
# Create customer records for each account that doesn't have a customer
migrations.RunSQL(
"insert into looper_customer (user_id, full_name, company, billing_email, tax_exempt, vat_number)"
"select u.id, '', '', '', false, '' "
f"from {user_table} as u left join looper_customer as cu on u.id = cu.user_id "
"where cu.user_id is null",
),
# Create address records for accounts without any # Create address records for accounts without any
migrations.RunSQL( migrations.RunSQL(
"insert into looper_address (category, user_id, full_name, company, country, tax_exempt, vat_number)" "insert into looper_address (category, user_id, full_name, company, country, tax_exempt, vat_number, "
"select 'billing', cu.user_id, cu.full_name, cu.company, '', false, '' " "street_address, extended_address, locality, postal_code, region)"
"select 'billing', cu.user_id, cu.full_name, cu.company, '', false, '', "
"'', '', '', '', '' "
"from looper_customer as cu left join looper_address as addr using(user_id) " "from looper_customer as cu left join looper_address as addr using(user_id) "
"where addr.user_id is null and cu.user_id is not null", "where addr.user_id is null and cu.user_id is not null",
), ),
@ -44,6 +57,7 @@ class Migration(migrations.Migration):
"full_name = addr.full_name, company = addr.company " "full_name = addr.full_name, company = addr.company "
"from looper_address as addr where cu.user_id = addr.user_id", "from looper_address as addr where cu.user_id = addr.user_id",
), ),
migrations.RunSQL('SET CONSTRAINTS ALL DEFERRED;'),
migrations.AlterField( migrations.AlterField(
model_name='address', model_name='address',
name='email', name='email',