mirror of
https://github.com/pretix/pretix.git
synced 2026-05-03 14:54:04 +00:00
Add data structure for questions
This commit is contained in:
43
src/tixlbase/migrations/0014_auto_20141005_1037.py
Normal file
43
src/tixlbase/migrations/0014_auto_20141005_1037.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tixlbase', '0013_propertyvalue_position'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Question',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)),
|
||||
('question', models.TextField(verbose_name='Question')),
|
||||
('type', models.CharField(choices=[('N', 'Number'), ('S', 'Text (one line)'), ('T', 'Multiline text'), ('B', 'Yes/No')], max_length=5, verbose_name='Question type')),
|
||||
('required', models.BooleanField(default=False, verbose_name='Required question')),
|
||||
('event', models.ForeignKey(to='tixlbase.Event', related_name='events')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Question',
|
||||
'verbose_name_plural': 'Questions',
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='itemvariation',
|
||||
options={'verbose_name': 'Item variation', 'verbose_name_plural': 'Item variations'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='propertyvalue',
|
||||
options={'ordering': ('position',), 'verbose_name': 'Property value', 'verbose_name_plural': 'Property values'},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='item',
|
||||
name='questions',
|
||||
field=models.ManyToManyField(to='tixlbase.Question', related_name='questions', blank=True, verbose_name='Questions', help_text='The user will be asked to fill in answers for the selected questions'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
@@ -406,6 +406,47 @@ class PropertyValue(models.Model):
|
||||
return "%s: %s" % (self.prop.name, self.value)
|
||||
|
||||
|
||||
class Question(models.Model):
|
||||
"""
|
||||
A question is an input field that can be used to extend a ticket
|
||||
by custom information, e.g. "Attendee name" or "Attendee age".
|
||||
"""
|
||||
TYPE_NUMBER = "N"
|
||||
TYPE_STRING = "S"
|
||||
TYPE_TEXT = "T"
|
||||
TYPE_BOOLEAN = "B"
|
||||
TYPE_CHOICES = (
|
||||
(TYPE_NUMBER, _("Number")),
|
||||
(TYPE_STRING, _("Text (one line)")),
|
||||
(TYPE_TEXT, _("Multiline text")),
|
||||
(TYPE_BOOLEAN, _("Yes/No")),
|
||||
)
|
||||
|
||||
event = models.ForeignKey(
|
||||
Event,
|
||||
related_name="questions",
|
||||
)
|
||||
question = models.TextField(
|
||||
verbose_name=_("Question"),
|
||||
)
|
||||
type = models.CharField(
|
||||
max_length=5,
|
||||
choices=TYPE_CHOICES,
|
||||
verbose_name=_("Question type"),
|
||||
)
|
||||
required = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name=_("Required question"),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Question")
|
||||
verbose_name_plural = _("Questions")
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Item(models.Model):
|
||||
"""
|
||||
An item is a thing which can be sold. It belongs to an
|
||||
@@ -470,6 +511,16 @@ class Item(models.Model):
|
||||
+ '\'Variations\' tab to configure the details.'
|
||||
)
|
||||
)
|
||||
questions = models.ManyToManyField(
|
||||
Question,
|
||||
related_name='questions',
|
||||
verbose_name=_("Questions"),
|
||||
blank=True,
|
||||
help_text=_(
|
||||
'The user will be asked to fill in answers for the '
|
||||
+ 'selected questions'
|
||||
)
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Item")
|
||||
|
||||
Reference in New Issue
Block a user