Amends Registrasion user profile

This commit is contained in:
Christopher Neugebauer 2017-10-02 17:23:05 -07:00
parent 41ba224759
commit ca6edb8706
4 changed files with 191 additions and 49 deletions

View file

@ -7,7 +7,3 @@ from django.utils.translation import ugettext_lazy as _
class UserProfileAdmin(admin.ModelAdmin):
model = models.AttendeeProfile
list_display = ("name", "company", "name_per_invoice")
@admin.register(models.DynamicValues)
class DynamicValuesAdmin(admin.ModelAdmin):
pass

View file

@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-03 00:19
from __future__ import unicode_literals
from django.db import migrations, models
import django_countries.fields
class Migration(migrations.Migration):
dependencies = [
('pinaxcon_registrasion', '0002_auto_20161005_1823'),
]
operations = [
migrations.RemoveField(
model_name='attendeeprofile',
name='db_defined_values',
),
migrations.RemoveField(
model_name='attendeeprofile',
name='dietary_requirements',
),
migrations.RemoveField(
model_name='attendeeprofile',
name='free_text_1',
),
migrations.RemoveField(
model_name='attendeeprofile',
name='free_text_2',
),
migrations.RemoveField(
model_name='attendeeprofile',
name='of_legal_age',
),
migrations.AddField(
model_name='attendeeprofile',
name='address_line_1',
field=models.CharField(blank=True, help_text=b'This address, if provided, will appear on your receipt.', max_length=1024, verbose_name=b'Address line 1'),
),
migrations.AddField(
model_name='attendeeprofile',
name='address_line_2',
field=models.CharField(blank=True, max_length=1024, verbose_name=b'Address line 2'),
),
migrations.AddField(
model_name='attendeeprofile',
name='address_postcode',
field=models.CharField(blank=True, max_length=1024, verbose_name=b'Postal/Zip code'),
),
migrations.AddField(
model_name='attendeeprofile',
name='address_suburb',
field=models.CharField(blank=True, max_length=1024, verbose_name=b'City/Town/Suburb'),
),
migrations.AddField(
model_name='attendeeprofile',
name='country',
field=django_countries.fields.CountryField(default=b'US', max_length=2),
),
migrations.AddField(
model_name='attendeeprofile',
name='dietary_restrictions',
field=models.CharField(blank=True, max_length=256, verbose_name=b'Food allergies, intolerances, or dietary restrictions'),
),
migrations.AddField(
model_name='attendeeprofile',
name='newsletter',
field=models.BooleanField(default=False, help_text=b'Select to be subscribed to the low-volume North Bay Python announcements newsletter', verbose_name=b'Subscribe to North Bay Python newsletter'),
preserve_default=False,
),
migrations.AddField(
model_name='attendeeprofile',
name='state',
field=models.CharField(blank=True, max_length=256, verbose_name=b'State/Territory/Province'),
),
migrations.AlterField(
model_name='attendeeprofile',
name='accessibility_requirements',
field=models.CharField(blank=True, max_length=256, verbose_name=b'Accessibility-related requirements'),
),
migrations.AlterField(
model_name='attendeeprofile',
name='company',
field=models.CharField(blank=True, help_text=b"The name of your company, as you'd like it on your badge and receipt", max_length=64),
),
migrations.AlterField(
model_name='attendeeprofile',
name='gender',
field=models.CharField(blank=True, help_text=b'Gender data will only be used for demographic purposes.', max_length=64),
),
migrations.AlterField(
model_name='attendeeprofile',
name='name_per_invoice',
field=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 receipt. Otherwise, leave it blank.", max_length=256, verbose_name=b'Your legal name (for your receipt)'),
),
migrations.DeleteModel(
name='DemoPayment',
),
migrations.DeleteModel(
name='DynamicValues',
),
]

View file

@ -1,18 +1,9 @@
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 DynamicValues(models.Model):
name = models.CharField(max_length=64)
value = models.IntegerField()
def __str__(self):
return "%s - %d" % (self.name, self.value)
class AttendeeProfile(rego.AttendeeProfileBase):
@classmethod
@ -22,11 +13,49 @@ class AttendeeProfile(rego.AttendeeProfileBase):
return "name"
def invoice_recipient(self):
lines = [
self.name_per_invoice,
]
if self.company:
base = "\n%(company)s\nAttention: %(name_per_invoice)s"
else:
base = "%(name_per_invoice)s"
return base % self.__dict__
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",
))
if errors:
raise ValidationError(dict(errors))
def save(self):
if not self.name_per_invoice:
@ -42,56 +71,68 @@ class AttendeeProfile(rego.AttendeeProfileBase):
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",
help_text="The name of your company, as you'd like it on your badge and receipt",
blank=True,
)
# Other important Information
name_per_invoice = models.CharField(
verbose_name="Your legal name (for invoicing purposes)",
max_length=64,
verbose_name="Your legal name (for your receipt)",
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, "
"fill this in, and we'll put it on your receipt. Otherwise, "
"leave it blank.",
blank=True,
)
of_legal_age = models.BooleanField(
default=False,
verbose_name="18+?",
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,
)
dietary_requirements = models.CharField(
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="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",
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,
)
db_defined_values = models.ManyToManyField(
DynamicValues
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,
)
class DemoPayment(rego.PaymentBase):
''' A subclass of PaymentBase for use in our demo payments function. '''
pass # No custom features here, but yours could be here.

View file

@ -30,6 +30,8 @@
</div>
</div>
{% include "registrasion/dashboard_widget.html" %}
<div class="panel panel-default">
<div class="panel-heading">
<div class="pull-right">