Link a sponsorship contract to a specific conference
authorMagnus Hagander <magnus@hagander.net>
Sat, 16 Jun 2018 20:19:58 +0000 (22:19 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 20 Jun 2018 11:47:59 +0000 (13:47 +0200)
The list is getting long enough that it's getting annoying.

In passing, also properly set verbose_name for a number of fields on the
sponsorship models.

postgresqleu/confsponsor/migrations/0001_initial.py
postgresqleu/confsponsor/migrations/0007_contract_per_conference.py [new file with mode: 0644]
postgresqleu/confsponsor/models.py

index fba7922910a3cd38c617a0f487ce97e47c0b51de..484d7d4c23bdc38ba48e52378ae10cea025b5372 100644 (file)
@@ -72,7 +72,7 @@ class Migration(migrations.Migration):
                 ('benefitdescription', models.TextField(blank=True)),
                 ('claimprompt', models.TextField(blank=True)),
                 ('benefit_class', models.IntegerField(default=None, null=True, blank=True, choices=[(1, b'Require uploaded image'), (2, b'Requires explicit claiming'), (3, b'Claim entry vouchers'), (4, b'Provide text string'), (5, b'List of attendee email addresses')])),
-                ('class_parameters', models.TextField(max_length=500, blank=True)),
+                ('class_parameters', models.TextField(max_length=500, blank=True, default='{}')),
             ],
             options={
                 'ordering': ('sortkey', 'benefitname'),
@@ -82,8 +82,8 @@ class Migration(migrations.Migration):
             name='SponsorshipContract',
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
-                ('contractname', models.CharField(max_length=100)),
-                ('contractpdf', models.FileField(storage=postgresqleu.util.storage.InlineEncodedStorage(b'sponsorcontract'), upload_to=postgresqleu.util.storage.inlineencoded_upload_path, blank=True)),
+                ('contractname', models.CharField(max_length=100, verbose_name='Contract name')),
+                ('contractpdf', models.FileField(storage=postgresqleu.util.storage.InlineEncodedStorage(b'sponsorcontract'), upload_to=postgresqleu.util.storage.inlineencoded_upload_path, blank=True, verbose_name='Contract PDF')),
             ],
         ),
         migrations.CreateModel(
@@ -94,9 +94,9 @@ class Migration(migrations.Migration):
                 ('urlname', models.CharField(max_length=100, validators=[postgresqleu.util.validators.validate_lowercase])),
                 ('levelcost', models.IntegerField()),
                 ('available', models.BooleanField(default=True, verbose_name=b'Available for signup')),
-                ('instantbuy', models.BooleanField(default=False)),
-                ('canbuyvoucher', models.BooleanField(default=True)),
-                ('canbuydiscountcode', models.BooleanField(default=True)),
+                ('instantbuy', models.BooleanField(default=False, verbose_name="Instant buy available")),
+                ('canbuyvoucher', models.BooleanField(default=True, verbose_name="Can buy vouchers")),
+                ('canbuydiscountcode', models.BooleanField(default=True, verbose_name="Can buy discount codes")),
                 ('conference', models.ForeignKey(to='confreg.Conference')),
                 ('contract', models.ForeignKey(blank=True, to='confsponsor.SponsorshipContract', null=True)),
                 ('paymentmethods', models.ManyToManyField(to='invoices.InvoicePaymentMethod', verbose_name=b'Payment methods for generated invoices')),
diff --git a/postgresqleu/confsponsor/migrations/0007_contract_per_conference.py b/postgresqleu/confsponsor/migrations/0007_contract_per_conference.py
new file mode 100644 (file)
index 0000000..4455532
--- /dev/null
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('confreg', '0025_edit_registrations'),
+        ('confsponsor', '0006_track_sponsor_signup_time'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='sponsorshipcontract',
+            name='conference',
+            field=models.ForeignKey(to='confreg.Conference', null=True),
+        ),
+        migrations.RunSQL("UPDATE confsponsor_sponsorshipcontract c SET conference_id=(SELECT conference_id FROM confsponsor_sponsorshiplevel l WHERE l.contract_id=c.id LIMIT 1)"),
+        migrations.AlterField(
+            model_name='sponsorshipcontract',
+            name='conference',
+            field=models.ForeignKey(to='confreg.Conference', null=False),
+        ),
+    ]
index 32b91eb1ab35f2544e3a0eb95f841977554b4f1a..d75366fbfe9372bd4227ef3b5558fd7befe0a954 100644 (file)
@@ -20,8 +20,9 @@ vat_status_choices = (
 )
 
 class SponsorshipContract(models.Model):
-       contractname = models.CharField(max_length=100, null=False, blank=False)
-       contractpdf = FileField(null=False, blank=True, storage=InlineEncodedStorage('sponsorcontract'), upload_to=inlineencoded_upload_path)
+       conference = models.ForeignKey(Conference, null=False, blank=False)
+       contractname = models.CharField(max_length=100, null=False, blank=False, verbose_name='Contract name')
+       contractpdf = FileField(null=False, blank=True, storage=InlineEncodedStorage('sponsorcontract'), upload_to=inlineencoded_upload_path, verbose_name='Contract PDF')
 
        def __unicode__(self):
                return self.contractname
@@ -44,11 +45,11 @@ class SponsorshipLevel(models.Model):
        urlname = models.CharField(max_length=100, null=False, blank=False, validators=[validate_lowercase,])
        levelcost = models.IntegerField(null=False, blank=False)
        available = models.BooleanField(null=False, blank=False, default=True, verbose_name="Available for signup")
-       instantbuy = models.BooleanField(null=False, blank=False, default=False)
+       instantbuy = models.BooleanField(null=False, blank=False, default=False, verbose_name="Instant buy available")
        paymentmethods = models.ManyToManyField(InvoicePaymentMethod, blank=False, verbose_name="Payment methods for generated invoices")
        contract = models.ForeignKey(SponsorshipContract, blank=True, null=True)
-       canbuyvoucher = models.BooleanField(null=False, blank=False, default=True)
-       canbuydiscountcode = models.BooleanField(null=False, blank=False, default=True)
+       canbuyvoucher = models.BooleanField(null=False, blank=False, default=True, verbose_name="Can buy vouchers")
+       canbuydiscountcode = models.BooleanField(null=False, blank=False, default=True, verbose_name="Can buy discount codes")
 
        def __unicode__(self):
                return self.levelname
@@ -64,7 +65,7 @@ class SponsorshipBenefit(models.Model):
        benefitdescription = models.TextField(null=False, blank=True)
        claimprompt = models.TextField(null=False, blank=True)
        benefit_class = models.IntegerField(null=True, blank=True, default=None, choices=benefit_choices)
-       class_parameters = models.TextField(max_length=500, blank=True, null=False)
+       class_parameters = models.TextField(max_length=500, blank=True, null=False, default='{}')
 
        def __unicode__(self):
                return self.benefitname