Changeset - 737db640aaeb
[Not reviewed]
0 2 1
Christopher Neugebauer - 7 years ago 2016-10-06 17:53:38
chrisjrn@gmail.com
Adds a demo RelatedField to the database to demonstrate reporting.
3 files changed with 47 insertions and 0 deletions:
0 comments (0 inline, 0 general)
pinaxcon/registrasion/admin.py
Show inline comments
 
import models
 

	
 
from django.contrib import admin
 
from django.utils.translation import ugettext_lazy as _
 

	
 
@admin.register(models.AttendeeProfile)
 
class UserProfileAdmin(admin.ModelAdmin):
 
    model = models.AttendeeProfile
 
    list_display = ("name", "company", "name_per_invoice")
 

	
 
@admin.register(models.DynamicValues)
 
class DynamicValuesAdmin(admin.ModelAdmin):
 
    pass
pinaxcon/registrasion/migrations/0002_auto_20161005_1823.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8 -*-
 
# Generated by Django 1.9.2 on 2016-10-05 18:23
 
from __future__ import unicode_literals
 

	
 
from django.db import migrations, models
 

	
 

	
 
class Migration(migrations.Migration):
 

	
 
    dependencies = [
 
        ('pinaxcon_registrasion', '0001_initial'),
 
    ]
 

	
 
    operations = [
 
        migrations.CreateModel(
 
            name='DynamicValues',
 
            fields=[
 
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
 
                ('name', models.CharField(max_length=64)),
 
                ('value', models.IntegerField()),
 
            ],
 
        ),
 
        migrations.AddField(
 
            model_name='attendeeprofile',
 
            name='db_defined_values',
 
            field=models.ManyToManyField(to='pinaxcon_registrasion.DynamicValues'),
 
        ),
 
    ]
pinaxcon/registrasion/models.py
Show inline comments
 
from django.db import models
 
from django.utils.encoding import python_2_unicode_compatible
 
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
 
    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):
 
        if self.company:
 
            base = "\n%(company)s\nAttention: %(name_per_invoice)s"
 
        else:
...
 
@@ -65,18 +77,21 @@ class AttendeeProfile(rego.AttendeeProfileBase):
 
    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,
 
    )
 
    db_defined_values = models.ManyToManyField(
 
        DynamicValues
 
    )
 

	
 

	
 
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.
0 comments (0 inline, 0 general)