Changeset - 236c61eefa0d
[Not reviewed]
0 4 5
Christopher Neugebauer - 8 years ago 2016-03-24 01:44:59
chrisjrn@gmail.com
Fleshes out badge model, and adds first pass at display of the badge form
9 files changed with 253 insertions and 10 deletions:
0 comments (0 inline, 0 general)
registrasion/forms.py
Show inline comments
...
 
@@ -57,6 +57,15 @@ def CategoryForm(category):
 

	
 
    return _CategoryForm
 

	
 

	
 
class ProfileForm(forms.ModelForm):
 
    ''' A form for requesting badge and profile information. '''
 

	
 
    class Meta:
 
        model = rego.BadgeAndProfile
 
        exclude = ['attendee']
 

	
 

	
 
class VoucherForm(forms.Form):
 
    voucher = forms.CharField(
 
        label="Voucher code",
registrasion/migrations/0002_auto_20160323_2029.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('registrasion', '0001_squashed_0002_auto_20160304_1723'),
 
    ]
 

	
 
    operations = [
 
        migrations.AddField(
 
            model_name='badge',
 
            name='accessibility_requirements',
 
            field=models.CharField(max_length=256, blank=True),
 
        ),
 
        migrations.AddField(
 
            model_name='badge',
 
            name='dietary_requirements',
 
            field=models.CharField(max_length=256, blank=True),
 
        ),
 
        migrations.AddField(
 
            model_name='badge',
 
            name='free_text_1',
 
            field=models.CharField(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.", max_length=64, verbose_name='Free text line 1', blank=True),
 
        ),
 
        migrations.AddField(
 
            model_name='badge',
 
            name='free_text_2',
 
            field=models.CharField(max_length=64, verbose_name='Free text line 2', blank=True),
 
        ),
 
        migrations.AddField(
 
            model_name='badge',
 
            name='gender',
 
            field=models.CharField(max_length=64, blank=True),
 
        ),
 
        migrations.AddField(
 
            model_name='badge',
 
            name='of_legal_age',
 
            field=models.BooleanField(default=False, verbose_name='18+?'),
 
        ),
 
        migrations.AlterField(
 
            model_name='badge',
 
            name='company',
 
            field=models.CharField(help_text="The name of your company, as you'd like it on your badge", max_length=64, blank=True),
 
        ),
 
        migrations.AlterField(
 
            model_name='badge',
 
            name='name',
 
            field=models.CharField(help_text="Your name, as you'd like it on your badge", max_length=64),
 
        ),
 
    ]
registrasion/migrations/0003_auto_20160323_2044.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('registrasion', '0002_auto_20160323_2029'),
 
    ]
 

	
 
    operations = [
 
        migrations.AddField(
 
            model_name='badge',
 
            name='name_per_invoice',
 
            field=models.CharField(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.", max_length=64, verbose_name='Your legal name (for invoicing purposes)', blank=True),
 
        ),
 
        migrations.AlterField(
 
            model_name='badge',
 
            name='name',
 
            field=models.CharField(help_text="Your name, as you'd like it to appear on your badge. ", max_length=64, verbose_name='Your name (for your conference nametag)'),
 
        ),
 
    ]
registrasion/migrations/0004_auto_20160323_2137.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 
from django.conf import settings
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
 
        ('registrasion', '0003_auto_20160323_2044'),
 
    ]
 

	
 
    operations = [
 
        migrations.CreateModel(
 
            name='Attendee',
 
            fields=[
 
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
 
                ('completed_registration', models.BooleanField(default=False)),
 
                ('highest_complete_category', models.IntegerField(default=0)),
 
                ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
 
            ],
 
        ),
 
        migrations.CreateModel(
 
            name='BadgeAndProfile',
 
            fields=[
 
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
 
                ('name', models.CharField(help_text="Your name, as you'd like it to appear on your badge. ", max_length=64, verbose_name='Your name (for your conference nametag)')),
 
                ('company', models.CharField(help_text="The name of your company, as you'd like it on your badge", max_length=64, blank=True)),
 
                ('free_text_1', models.CharField(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.", max_length=64, verbose_name='Free text line 1', blank=True)),
 
                ('free_text_2', models.CharField(max_length=64, verbose_name='Free text line 2', blank=True)),
 
                ('name_per_invoice', models.CharField(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.", max_length=64, verbose_name='Your legal name (for invoicing purposes)', blank=True)),
 
                ('of_legal_age', models.BooleanField(default=False, verbose_name='18+?')),
 
                ('dietary_requirements', models.CharField(max_length=256, blank=True)),
 
                ('accessibility_requirements', models.CharField(max_length=256, blank=True)),
 
                ('gender', models.CharField(max_length=64, blank=True)),
 
                ('profile', models.OneToOneField(to='registrasion.Attendee')),
 
            ],
 
        ),
 
        migrations.RemoveField(
 
            model_name='badge',
 
            name='profile',
 
        ),
 
        migrations.RemoveField(
 
            model_name='profile',
 
            name='user',
 
        ),
 
        migrations.DeleteModel(
 
            name='Badge',
 
        ),
 
        migrations.DeleteModel(
 
            name='Profile',
 
        ),
 
    ]
registrasion/migrations/0005_auto_20160323_2141.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('registrasion', '0004_auto_20160323_2137'),
 
    ]
 

	
 
    operations = [
 
        migrations.RenameField(
 
            model_name='badgeandprofile',
 
            old_name='profile',
 
            new_name='attendee',
 
        ),
 
    ]
registrasion/models.py
Show inline comments
...
 
@@ -15,29 +15,79 @@ from model_utils.managers import InheritanceManager
 
# User models
 

	
 
@python_2_unicode_compatible
 
class Profile(models.Model):
 
class Attendee(models.Model):
 
    ''' Miscellaneous user-related data. '''
 

	
 
    def __str__(self):
 
        return "%s" % self.user
 

	
 
    user = models.OneToOneField(User, on_delete=models.CASCADE)
 
    # Badge is linked
 
    # Badge/profile is linked
 
    completed_registration = models.BooleanField(default=False)
 
    highest_complete_category = models.IntegerField(default=0)
 

	
 

	
 
@python_2_unicode_compatible
 
class Badge(models.Model):
 
    ''' Information for an attendee's badge. '''
 
class BadgeAndProfile(models.Model):
 
    ''' Information for an attendee's badge and related preferences '''
 

	
 
    def __str__(self):
 
        return "Badge for: %s of %s" % (self.name, self.company)
 

	
 
    profile = models.OneToOneField(Profile, on_delete=models.CASCADE)
 

	
 
    name = models.CharField(max_length=256)
 
    company = models.CharField(max_length=256)
 
    attendee = models.OneToOneField(Attendee, on_delete=models.CASCADE)
 

	
 
    # 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=64,
 
        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,
 
        )
 
    of_legal_age = models.BooleanField(
 
        default=False,
 
        verbose_name="18+?",
 
        blank=True,
 
    )
 
    dietary_requirements = models.CharField(
 
        max_length=256,
 
        blank=True,
 
    )
 
    accessibility_requirements = models.CharField(
 
        max_length=256,
 
        blank=True,
 
    )
 
    gender = models.CharField(
 
        max_length=64,
 
        blank=True,
 
    )
 

	
 

	
 
# Inventory Models
registrasion/templates/profile_form.html
Show inline comments
 
new file 100644
 
<!--- Sample template. Move elsewhere once it's ready to go. -->
 

	
 
{% extends "site_base.html" %}
 
{% block body %}
 

	
 
  <h1>Attendee Profile</h1>
 

	
 
  <p>Something something fill in your attendee details here!</p>
 

	
 
  <form method="post" action="">
 
    {% csrf_token %}
 

	
 
    <table>
 
        {{ form }}
 
    </table>
 

	
 
    <input type="submit">
 

	
 
  </form>
 

	
 

	
 
{% endblock %}
registrasion/urls.py
Show inline comments
...
 
@@ -2,10 +2,11 @@ from django.conf.urls import url, patterns
 

	
 
urlpatterns = patterns(
 
    "registrasion.views",
 
    url(r"^register$", "guided_registration", name="guided_registration"),
 
    url(r"^register/([0-9]+)$", "guided_registration", name="guided_registration"),
 
    url(r"^category/([0-9]+)$", "product_category", name="product_category"),
 
    url(r"^checkout$", "checkout", name="checkout"),
 
    url(r"^invoice/([0-9]+)$", "invoice", name="invoice"),
 
    url(r"^invoice/([0-9]+)/pay$", "pay_invoice", name="pay_invoice"),
 
    url(r"^profile$", "profile", name="profile"),
 
    url(r"^register$", "guided_registration", name="guided_registration"),
 
    url(r"^register/([0-9]+)$", "guided_registration", name="guided_registration"),
 
)
registrasion/views.py
Show inline comments
...
 
@@ -38,6 +38,15 @@ def guided_registration(request, page_id=0):
 
    else:
 
        return redirect("dashboard")
 

	
 
@login_required
 
def profile(request):
 

	
 
    form = forms.ProfileForm()
 
    data = {
 
        "form": form,
 
    }
 
    return render(request, "profile_form.html", data)
 

	
 
@login_required
 
def product_category(request, category_id):
 
    ret = product_category_inner(request, category_id)
0 comments (0 inline, 0 general)