2017-10-03 14:06:39 +00:00
|
|
|
from django.core.exceptions import ValidationError
|
2016-03-30 04:13:50 +00:00
|
|
|
from django.db import models
|
2016-10-06 17:53:38 +00:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2017-10-03 00:23:05 +00:00
|
|
|
from django_countries.fields import CountryField
|
2016-03-30 04:13:50 +00:00
|
|
|
from registrasion import models as rego
|
|
|
|
|
2016-10-06 17:53:38 +00:00
|
|
|
|
2016-03-30 04:13:50 +00:00
|
|
|
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):
|
2017-10-03 00:23:05 +00:00
|
|
|
|
|
|
|
lines = [
|
|
|
|
self.name_per_invoice,
|
|
|
|
]
|
|
|
|
|
2016-03-30 04:13:50 +00:00
|
|
|
if self.company:
|
2017-10-03 00:23:05 +00:00
|
|
|
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(unicode(line) for line in lines)
|
|
|
|
|
|
|
|
def clean(self):
|
|
|
|
errors = []
|
|
|
|
if self.country == "US" and not self.state:
|
|
|
|
errors.append(
|
|
|
|
("state", "US-based attendees 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",
|
|
|
|
))
|
|
|
|
|
2017-10-04 13:26:00 +00:00
|
|
|
if not self.agreement:
|
|
|
|
errors.append((
|
|
|
|
"agreement",
|
|
|
|
"You must accept the agreement.",
|
|
|
|
))
|
|
|
|
|
2017-10-03 00:23:05 +00:00
|
|
|
if errors:
|
|
|
|
raise ValidationError(dict(errors))
|
2016-03-30 04:13:50 +00:00
|
|
|
|
|
|
|
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,
|
2017-10-03 00:23:05 +00:00
|
|
|
help_text="The name of your company, as you'd like it on your badge and receipt",
|
2016-03-30 04:13:50 +00:00
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
name_per_invoice = models.CharField(
|
2017-10-03 00:23:05 +00:00
|
|
|
verbose_name="Your legal name (for your receipt)",
|
|
|
|
max_length=256,
|
2016-03-30 04:13:50 +00:00
|
|
|
help_text="If your legal name is different to the name on your badge, "
|
2017-10-03 00:23:05 +00:00
|
|
|
"fill this in, and we'll put it on your receipt. Otherwise, "
|
2016-03-30 04:13:50 +00:00
|
|
|
"leave it blank.",
|
|
|
|
blank=True,
|
|
|
|
)
|
2017-10-03 00:23:05 +00:00
|
|
|
|
|
|
|
address_line_1 = models.CharField(
|
|
|
|
verbose_name="Address line 1",
|
|
|
|
help_text="This address, if provided, will appear on your receipt.",
|
|
|
|
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,
|
2016-03-30 04:13:50 +00:00
|
|
|
blank=True,
|
|
|
|
)
|
2017-10-03 00:23:05 +00:00
|
|
|
country = CountryField(
|
|
|
|
default="US",
|
|
|
|
)
|
|
|
|
state = models.CharField(
|
|
|
|
max_length=256,
|
|
|
|
verbose_name="State/Territory/Province",
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
dietary_restrictions = models.CharField(
|
|
|
|
verbose_name="Food allergies, intolerances, or dietary restrictions",
|
2016-03-30 04:13:50 +00:00
|
|
|
max_length=256,
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
accessibility_requirements = models.CharField(
|
2017-10-03 00:23:05 +00:00
|
|
|
verbose_name="Accessibility-related requirements",
|
2016-03-30 04:13:50 +00:00
|
|
|
max_length=256,
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
gender = models.CharField(
|
2017-10-03 00:23:05 +00:00
|
|
|
help_text="Gender data will only be used for demographic purposes.",
|
2016-03-30 04:13:50 +00:00
|
|
|
max_length=64,
|
|
|
|
blank=True,
|
|
|
|
)
|
|
|
|
|
2017-10-03 00:23:05 +00:00
|
|
|
newsletter = models.BooleanField(
|
|
|
|
verbose_name="Subscribe to North Bay Python newsletter",
|
|
|
|
help_text="Select to be subscribed to the low-volume North Bay Python "
|
|
|
|
"announcements newsletter",
|
|
|
|
blank=True,
|
|
|
|
)
|
2017-10-04 13:26:00 +00:00
|
|
|
|
|
|
|
agreement = models.BooleanField(
|
|
|
|
verbose_name="Agreement",
|
|
|
|
help_text="I agree to act according to the <a href='/code-of-conduct'> "
|
|
|
|
"North Bay Python Code of Conduct</a>. I also agree with the "
|
|
|
|
"North Bay Python <a href='/terms'>Terms and Conditions</a>.",
|
|
|
|
blank=False,
|
|
|
|
default=False,
|
|
|
|
)
|