2016-09-20 00:33:43 +00:00
|
|
|
from registrasion.models import conditions
|
2016-09-02 04:33:23 +00:00
|
|
|
from registrasion.models import inventory
|
|
|
|
|
2016-09-20 09:18:09 +00:00
|
|
|
from symposion.proposals import models as proposals_models
|
|
|
|
|
2016-09-02 04:33:23 +00:00
|
|
|
from django import forms
|
|
|
|
|
2016-09-20 00:33:43 +00:00
|
|
|
# Reporting forms.
|
|
|
|
|
|
|
|
|
|
|
|
class DiscountForm(forms.Form):
|
|
|
|
discount = forms.ModelMultipleChoiceField(
|
|
|
|
queryset=conditions.DiscountBase.objects.all(),
|
|
|
|
required=False,
|
|
|
|
)
|
2016-09-02 04:33:23 +00:00
|
|
|
|
2016-09-13 08:54:28 +00:00
|
|
|
|
2016-09-02 04:33:23 +00:00
|
|
|
class ProductAndCategoryForm(forms.Form):
|
|
|
|
product = forms.ModelMultipleChoiceField(
|
|
|
|
queryset=inventory.Product.objects.all(),
|
|
|
|
required=False,
|
|
|
|
)
|
|
|
|
category = forms.ModelMultipleChoiceField(
|
|
|
|
queryset=inventory.Category.objects.all(),
|
|
|
|
required=False,
|
|
|
|
)
|
2016-09-02 05:15:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UserIdForm(forms.Form):
|
|
|
|
user = forms.IntegerField(
|
|
|
|
label="User ID",
|
|
|
|
required=False,
|
|
|
|
)
|
2016-09-20 03:36:49 +00:00
|
|
|
|
|
|
|
|
2016-09-20 09:18:09 +00:00
|
|
|
class ProposalKindForm(forms.Form):
|
|
|
|
kind = forms.ModelMultipleChoiceField(
|
|
|
|
queryset=proposals_models.ProposalKind.objects.all(),
|
|
|
|
required=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-09-20 03:36:49 +00:00
|
|
|
def model_fields_form_factory(model):
|
|
|
|
''' Creates a form for specifying fields from a model to display. '''
|
|
|
|
|
|
|
|
fields = model._meta.get_fields()
|
|
|
|
|
|
|
|
choices = []
|
|
|
|
for field in fields:
|
|
|
|
if hasattr(field, "verbose_name"):
|
|
|
|
choices.append((field.name, field.verbose_name))
|
|
|
|
|
|
|
|
class ModelFieldsForm(forms.Form):
|
|
|
|
fields = forms.MultipleChoiceField(
|
|
|
|
choices=choices,
|
|
|
|
required=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
return ModelFieldsForm
|