Changeset - ebbf8f079c67
[Not reviewed]
0 2 1
Tobias - 6 years ago 2018-09-29 05:31:16
tobias@localhost.localdomain
Change models for 2019, closes #135
3 files changed with 23 insertions and 2 deletions:
0 comments (0 inline, 0 general)
pinaxcon/registrasion/migrations/0001_initial.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# Generated by Django 1.9.7 on 2016-09-22 06:25
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 
import django.db.models.deletion
 
import django_countries.fields
 

	
 

	
 
_PAST_EVENTS = (
 
    (1999, "1999 Melbourne (CALU)"),
 
    (2001, "2001 Sydney"),
 
    (2002, "2002 Brisbane"),
 
    (2003, "2003 Perth"),
 
    (2004, "2004 Adelaide"),
 
    (2005, "2005 Canberra"),
 
    (2006, "2006 Dunedin"),
 
    (2007, "2007 Sydney"),
 
    (2008, "2008 Melbourne"),
 
    (2009, "2009 Hobart"),
 
    (2010, "2010 Wellington"),
 
    (2011, "2011 Brisbane"),
 
    (2012, "2012 Ballarat"),
 
    (2013, "2013 Canberra"),
 
    (2014, "2014 Perth"),
 
    (2015, "2015 Auckland"),
 
    (2016, "2016 Geelong"),
 
    (2017, "2017 Hobart"),
 
    (2018, "2018 Sydney"),
 
)
 

	
 

	
 
def populate(apps, schema_editor):
 
    PastEvent = apps.get_model("pinaxcon_registrasion","PastEvent")
 

	
 
    all_such = PastEvent.objects.all()
 
    by_year = dict((event.year, event) for event in all_such)
 

	
 
    events = []
 
    for past_event in _PAST_EVENTS:
 
        if past_event[0] in by_year:
 
            continue
 
        events.append(PastEvent(
 
            year=past_event[0],
 
            name=past_event[1],
 
        ))
 

	
 
    PastEvent.objects.bulk_create(events)
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    initial = True
 

	
 
    dependencies = [
 
        ('registrasion', '0005_auto_20160905_0945'),
 
    ]
 

	
 
    operations = [
 
        migrations.CreateModel(
 
            name='AttendeeProfile',
 
            fields=[
 
                ('attendeeprofilebase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='registrasion.AttendeeProfileBase')),
 
                ('name', models.CharField(help_text=b"Your name, as you'd like it to appear on your badge. ", max_length=64, verbose_name=b'Your name (for your conference nametag)')),
 
                ('company', models.CharField(blank=True, help_text=b"The name of your company, as you'd like it on your badge", max_length=64)),
 
                ('state', models.CharField(choices=[(b'', b'Not in Australia'), (b'TAS', b'Tasmania'), (b'ACT', b'Australian Capital Territory'), (b'NSW', b'New South Wales'), (b'NT', b'Northern Territory'), (b'QLD', b'Queensland'), (b'SA', b'South Australia'), (b'VIC', b'Victoria'), (b'WA', b'Western Australia')], max_length=4, verbose_name=b'Australian State/Territory')),
 
                ('country', django_countries.fields.CountryField(max_length=2)),
 
                ('free_text_1', models.CharField(blank=True, help_text=b"A line of free text that will appear on your badge. Use this for your Twitter handle, IRC nick, your preferred pronouns or anything else you'd like people to see on your badge.", max_length=64, verbose_name=b'Free text line 1')),
 
                ('free_text_2', models.CharField(blank=True, max_length=64, verbose_name=b'Free text line 2')),
 
                ('name_per_invoice', models.CharField(blank=True, help_text=b"If your legal name is different to the name on your badge, fill this in, and we'll put it on your invoice. Otherwise, leave it blank.", max_length=256, verbose_name=b'Your legal name (for invoicing purposes)')),
 
                ('address', models.TextField(blank=True, help_text=b'This address, if provided, will appear on your invoices.', verbose_name=b'Invoicing address')),
 
                ('of_legal_age', models.BooleanField(help_text=b'Being under 18 will not stop you from attending the conference. We need to know whether you are over 18 to allow us to cater for you at venues that serve alcohol.', verbose_name=b'Are you over 18?')),
 
                ('dietary_restrictions', models.TextField(blank=True, max_length=256, verbose_name=b'Food allergies, intolerances, or dietary restrictions')),
 
                ('accessibility_requirements', models.TextField(blank=True, verbose_name=b'Accessibility-related requirements')),
 
                ('gender', models.CharField(blank=True, help_text=b'Gender data will only be used for demographic purposes.', max_length=64)),
 
                ('linux_australia', models.BooleanField(help_text=b"Select this field to register for free <a href='http://www.linux.org.au/'>Linux Australia</a> membership.", verbose_name=b'Linux Australia membership')),
 
                ('lca_announce', models.BooleanField(help_text=b'Select to be subscribed to the low-traffic lca-announce mailing list', verbose_name=b'Subscribe to lca-announce list')),
 
                ('lca_chat', models.BooleanField(help_text=b'lca2017-chat is a high-traffic mailing list used by attendees during the week of the conference for general discussion.', verbose_name=b'Subscribe to the lca2017-chat list')),
 
            ],
 
            bases=('registrasion.attendeeprofilebase',),
 
        ),
 
        migrations.CreateModel(
 
            name='PastEvent',
 
            fields=[
 
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
 
                ('year', models.IntegerField(unique=True)),
 
                ('name', models.CharField(max_length=255, unique=True)),
 
            ],
 
        ),
 
        migrations.AddField(
 
            model_name='attendeeprofile',
 
            name='past_lca',
 
            field=models.ManyToManyField(blank=True, to='pinaxcon_registrasion.PastEvent', verbose_name=b'Which past linux.conf.au events have you attended?'),
 
        ),
 
        migrations.RunPython(populate),
 
    ]
pinaxcon/registrasion/migrations/0010_auto_20180929_1530.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
# Generated by Django 1.11.15 on 2018-09-29 05:30
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('pinaxcon_registrasion', '0009_attendeeprofile_children'),
 
    ]
 

	
 
    operations = [
 
        migrations.AlterField(
 
            model_name='attendeeprofile',
 
            name='lca_chat',
 
            field=models.BooleanField(help_text='lca2019-chat is a high-traffic mailing list used by attendees during the week of the conference for general discussion.', verbose_name='Subscribe to the lca2019-chat list'),
 
        ),
 
    ]
pinaxcon/registrasion/models.py
Show inline comments
...
 
@@ -2,212 +2,212 @@ from django.core.exceptions import ValidationError
 
from django.db import models
 
from django.utils.encoding import python_2_unicode_compatible
 
from django_countries.fields import CountryField
 
from registrasion import models as rego
 

	
 

	
 
@python_2_unicode_compatible
 
class PastEvent(models.Model):
 
    ''' This is populated in 0001_initial.py '''
 

	
 
    def __str__(self):
 
        return self.name
 

	
 
    year = models.IntegerField(unique=True,)
 
    name = models.CharField(max_length=255, unique=True,)
 

	
 

	
 
class AttendeeProfile(rego.AttendeeProfileBase):
 

	
 
    @classmethod
 
    def name_field(cls):
 
        ''' This is used to pre-fill the attendee's name from the
 
        speaker profile. If it's None, that functionality is disabled. '''
 
        return "name"
 

	
 
    def invoice_recipient(self):
 

	
 
        lines = [
 
            self.name_per_invoice,
 
        ]
 

	
 
        if self.company:
 
            lines.append("C/- " + self.company)
 

	
 
        if self.address_line_1:
 
            lines.append(self.address_line_1)
 

	
 
        if self.address_line_2:
 
            lines.append(self.address_line_2)
 

	
 
        if self.address_suburb or self.address_postcode:
 
            lines.append("%s %s" % (
 
                self.address_suburb or "",
 
                self.address_postcode or "",
 
            ))
 

	
 
        if self.state:
 
            lines.append(self.state)
 

	
 
        if self.country:
 
            lines.append(self.country.name)
 

	
 
        return "\n".join(lines)
 

	
 
    def clean(self):
 
        errors = []
 
        if self.country == "AU" and not self.state:
 
            errors.append(
 
                ("state", "Australians must list their state"),
 
            )
 

	
 
        if self.address_line_2 and not self.address_line_1:
 
            errors.append((
 
                "address_line_1",
 
                "Please fill in line 1 before filling line 2",
 
            ))
 

	
 
        if errors:
 
            raise ValidationError(dict(errors))
 

	
 
    def save(self):
 
        if not self.name_per_invoice:
 
            self.name_per_invoice = self.name
 
        super(AttendeeProfile, self).save()
 

	
 
    # Things that appear on badge
 
    name = models.CharField(
 
        verbose_name="Your name (for your conference nametag)",
 
        max_length=64,
 
        help_text="Your name, as you'd like it to appear on your badge. ",
 
    )
 
    company = models.CharField(
 
        max_length=64,
 
        help_text="The name of your company, as you'd like it on your badge",
 
        blank=True,
 
    )
 

	
 
    free_text_1 = models.CharField(
 
        max_length=64,
 
        verbose_name="Free text line 1",
 
        help_text="A line of free text that will appear on your badge. Use "
 
                  "this for your Twitter handle, IRC nick, your preferred "
 
                  "pronouns or anything else you'd like people to see on "
 
                  "your badge.",
 
        blank=True,
 
    )
 
    free_text_2 = models.CharField(
 
        max_length=64,
 
        verbose_name="Free text line 2",
 
        blank=True,
 
    )
 

	
 
    # Other important Information
 
    name_per_invoice = models.CharField(
 
        verbose_name="Your legal name (for invoicing purposes)",
 
        max_length=256,
 
        help_text="If your legal name is different to the name on your badge, "
 
                  "fill this in, and we'll put it on your invoice. Otherwise, "
 
                  "leave it blank.",
 
        blank=True,
 
        )
 

	
 
    address_line_1 = models.CharField(
 
        verbose_name="Address line 1",
 
        help_text="This address, if provided, will appear on your invoices.",
 
        max_length=1024,
 
        blank=True,
 
    )
 
    address_line_2 = models.CharField(
 
        verbose_name="Address line 2",
 
        max_length=1024,
 
        blank=True,
 
    )
 
    address_suburb = models.CharField(
 
        verbose_name="City/Town/Suburb",
 
        max_length=1024,
 
        blank=True,
 
    )
 
    address_postcode = models.CharField(
 
        verbose_name="Postal/Zip code",
 
        max_length=1024,
 
        blank=True,
 
    )
 
    country = CountryField(
 
        default="AU",
 
    )
 
    state = models.CharField(
 
        max_length=256,
 
        verbose_name="State/Territory/Province",
 
        help_text="If your Country is Australia, you must list a state.",
 
        blank=True,
 
    )
 

	
 
    of_legal_age = models.BooleanField(
 
        verbose_name="Are you over 18?",
 
        help_text="Being under 18 will not stop you from attending the "
 
                  "conference. We need to know whether you are over 18 to "
 
                  "allow us to cater for you at venues that serve alcohol.",
 
    )
 
    dietary_restrictions = models.CharField(
 
        verbose_name="Food allergies, intolerances, or dietary restrictions",
 
        max_length=256,
 
        blank=True,
 
    )
 
    accessibility_requirements = models.CharField(
 
        verbose_name="Accessibility-related requirements",
 
        max_length=256,
 
        blank=True,
 
    )
 
    gender = models.CharField(
 
        help_text="Gender data will only be used for demographic purposes.",
 
        max_length=64,
 
        blank=True,
 
    )
 

	
 
    children = models.CharField(
 
        max_length=256,
 
        help_text="Linux.conf.au 2019 is a family friendly conference and provides "
 
            "free child-care for pre-school children from 6 months up to 5 years. We "
 
            "hope to also provide a programme for older children and will let you "
 
            "know closer to the conference. If you're wanting to bring your children "
 
            "to LCA2019, please let us know their age(s) so we can ensure we have "
 
            "enough spaces available.",
 
        blank=True
 
    )
 

	
 
    linux_australia = models.BooleanField(
 
        verbose_name="Linux Australia membership",
 
        help_text="Select this field to register for free "
 
                  "<a href='http://www.linux.org.au/'>Linux Australia</a> "
 
                  "membership.",
 
        blank=True,
 
    )
 

	
 
    lca_announce = models.BooleanField(
 
        verbose_name="Subscribe to lca-announce list",
 
        help_text="Select to be subscribed to the low-traffic lca-announce "
 
                  "mailing list",
 
        blank=True,
 
    )
 

	
 
    lca_chat = models.BooleanField(
 
        verbose_name="Subscribe to the lca2018-chat list",
 
        help_text="lca2018-chat is a high-traffic mailing list used by "
 
        verbose_name="Subscribe to the lca2019-chat list",
 
        help_text="lca2019-chat is a high-traffic mailing list used by "
 
                  "attendees during the week of the conference for general "
 
                  "discussion.",
 
        blank=True,
 
    )
 

	
 
    future_conference = models.BooleanField(
 
        verbose_name = "Reuse my login for future Linux Australia conferences?",
 
        help_text="Select to have your login details made available to future "
 
                  "Linux Australia conferences who share the same Single Sign "
 
                  "On system.",
 
        blank=True,
 
    )
 

	
 
    past_lca = models.ManyToManyField(
 
        PastEvent,
 
        verbose_name="Which past linux.conf.au events have you attended?",
 
        blank=True,
 
    )
0 comments (0 inline, 0 general)