# Path: formunculous/fields.py
# class HoneypotField(Field):
#     """
#     Creates a hidden text input field, that when validated, if the
#     field has a different value in it than when initialized, the form
#     is invalid.  This is used to stop simple SPAM bots.
#     """
# 
#     widget = HoneypotWidget
# 
#     def clean(self, value):
# 
#         # If the value is empty or changed from the initial
#         # invalidate the field.
#         if (self.initial in EMPTY_VALUES and value \
#             in EMPTY_VALUES) or value == self.initial:
#             return value
# 
#         raise ValidationError('Honeypot field changed in value.')
# 
# class MultipleChoiceToStringField(MultipleChoiceField):
# 
#     def clean(self, value):
# 
#         super(MultipleChoiceToStringField, self).clean(value)
#         return ' | '.join(value)


from django import forms
from django.db import models
from django.utils.safestring import mark_safe
from django.forms.util import ErrorList
from django.contrib.auth.models import User
from formunculous.models import *
from formunculous.fields import HoneypotField, MultipleChoiceToStringField
from django.utils.translation import ugettext as _
from django.forms import ModelForm
from django.forms.widgets import RadioSelect, Select, SelectMultiple, CheckboxSelectMultiple, HiddenInput
from django.contrib.admin.widgets import FilteredSelectMultiple
from django.forms.formsets import BaseFormSet, TOTAL_FORM_COUNT, INITIAL_FORM_COUNT, ORDERING_FIELD_NAME, DELETION_FIELD_NAME, ManagementForm
import formunculous.models as funcmodels
    import django
                # Grab the model if this value is already stored otherwise,
                # ignore
                field_model = field_model.objects.get(field_def = field_def,
                                                      app = self.app)
                data = field_model.value
            except field_model.DoesNotExist:
                pass

            # If there are dropdown choices specified, create the
            # choices tuple for use in the field determined by other
            # user choices.
            field_def_choices = field_def.dropdownchoices_set.all()
            if field_def_choices and field_model.allow_dropdown:
                choices = (())
                for choice in field_def_choices:
                    choices += (choice.value, _(choice.text),),

                # Users are allowed to specify that a choiced
                widget = Select
                if field_def.multi_select:
                    # Fix the data from being stored as a string to
                    # being stored as a list
                    if data:
                        try:
                            data = data.split(' | ')
                        except:
                            data = None
                    widget = SelectMultiple
                    if field_def.use_radio:
                        widget = CheckboxSelectMultiple

# Path: formunculous/fields.py
# class HoneypotField(Field):
#     """
#     Creates a hidden text input field, that when validated, if the
#     field has a different value in it than when initialized, the form
#     is invalid.  This is used to stop simple SPAM bots.
#     """
# 
#     widget = HoneypotWidget
# 
#     def clean(self, value):
# 
#         # If the value is empty or changed from the initial
#         # invalidate the field.
#         if (self.initial in EMPTY_VALUES and value \
#             in EMPTY_VALUES) or value == self.initial:
#             return value
# 
#         raise ValidationError('Honeypot field changed in value.')
# 
# class MultipleChoiceToStringField(MultipleChoiceField):
# 
#     def clean(self, value):
# 
#         super(MultipleChoiceToStringField, self).clean(value)
#         return ' | '.join(value)


# Path: formunculous/forms.py
from django import forms
from django.db import models
from django.utils.safestring import mark_safe
from django.forms.util import ErrorList
from django.contrib.auth.models import User
from formunculous.models import *
from formunculous.fields import HoneypotField, MultipleChoiceToStringField
from django.utils.translation import ugettext as _
from django.forms import ModelForm
from django.forms.widgets import RadioSelect, Select, SelectMultiple, CheckboxSelectMultiple, HiddenInput
from django.contrib.admin.widgets import FilteredSelectMultiple
from django.forms.formsets import BaseFormSet, TOTAL_FORM_COUNT, INITIAL_FORM_COUNT, ORDERING_FIELD_NAME, DELETION_FIELD_NAME, ManagementForm
import formunculous.models as funcmodels
    import django

                # Grab the model if this value is already stored otherwise,
                # ignore
                field_model = field_model.objects.get(field_def = field_def,
                                                      app = self.app)
                data = field_model.value
            except field_model.DoesNotExist:
                pass

            # If there are dropdown choices specified, create the
            # choices tuple for use in the field determined by other
            # user choices.
            field_def_choices = field_def.dropdownchoices_set.all()
            if field_def_choices and field_model.allow_dropdown:
                choices = (())
                for choice in field_def_choices:
                    choices += (choice.value, _(choice.text),),

                # Users are allowed to specify that a choiced
                widget = Select
                if field_def.multi_select:
                    # Fix the data from being stored as a string to
                    # being stored as a list
                    if data:
                        try:
                            data = data.split(' | ')
                        except:
                            data = None
                    widget = SelectMultiple
                    if field_def.use_radio:
                        widget = CheckboxSelectMultiple

                if field_def.use_radio and not field_def.multi_select: