# 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
#     You should have received a copy of the GNU General Public License
#     along with formunculous.  If not, see <http://www.gnu.org/licenses/>.
#     Copyright 2009-2013 Carson Gee






# Used to introspect model namespace
        
class ApplicationForm(forms.Form):

    def __init__(self, app_def, app=None, reviewer=False, *args, **kwargs):
        super(ApplicationForm, self).__init__(*args, **kwargs)
        self.app_def = app_def
        self.app = app
        self.reviewer = reviewer

        # If there is an application defined, add it's pk
        if app:
            pk_field = forms.IntegerField(initial=app.id, widget=HiddenInput)
            pk_field.is_hidden = True
            pk_field.required = False
            self.fields['pk'] = pk_field

        field_set = app_def.fielddefinition_set.filter(
            reviewer_only=self.reviewer)
        # Loop through the application field definition set
        # and create form fields for them.

# 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

#     You should have received a copy of the GNU General Public License
#     along with formunculous.  If not, see <http://www.gnu.org/licenses/>.
#     Copyright 2009-2013 Carson Gee






# Used to introspect model namespace
        
class ApplicationForm(forms.Form):

    def __init__(self, app_def, app=None, reviewer=False, *args, **kwargs):
        super(ApplicationForm, self).__init__(*args, **kwargs)
        self.app_def = app_def
        self.app = app
        self.reviewer = reviewer

        # If there is an application defined, add it's pk
        if app:
            pk_field = forms.IntegerField(initial=app.id, widget=HiddenInput)
            pk_field.is_hidden = True
            pk_field.required = False
            self.fields['pk'] = pk_field

        field_set = app_def.fielddefinition_set.filter(
            reviewer_only=self.reviewer)
        # Loop through the application field definition set
        # and create form fields for them.

        for field_def in field_set: