# Path: dockit/paginator.py

# 
# Path: dockit/forms/forms.py
# class DocumentForm(BaseDocumentForm):
#     """ The document form object """
#     __metaclass__ = DocumentFormMetaClass
# 
# Path: dockit/forms/fields.py
# class PrimitiveListField(Field):
#     '''
#     Wraps around a subfield
#     The widget receives the subfield and is responsible for rendering multiple iterations of the subfield and collecting of data
#     '''
#     widget = PrimitiveListWidget
#     
#     def __init__(self, subfield, *args, **kwargs):
#         self.subfield = subfield
#         widget = kwargs.get('widget', self.widget)
#         if isinstance(widget, type):
#             widget = widget(subfield)
#         kwargs['widget'] = widget
#         super(PrimitiveListField, self).__init__(*args, **kwargs)
#     
#     def prepare_value(self, value):
#         if value is None:
#             return
#         ret = list()
#         for val in value:
#             ret.append(self.subfield.prepare_value(val))
#         return ret
#     
#     def bound_data(self, data, initial):
#         ret = list()
#         for data_item, initial_item in zip(data, initial):
#             ret.append(self.subfield.bound_data(data_item, initial_item))
#         return ret
#     
#     def clean(self, data, initial=None):
#         ret = list()
#         for i, data_item in enumerate(data):
#             if data_item.get('DELETE', False):
#                 continue
#             if initial and len(initial) > i:
#                 initial_item = initial[i]
#             else:
#                 initial_item = None
#             val = self.subfield.bound_data(data_item['value'], initial_item)
#             
#             arg_spec = inspect.getargspec(self.subfield.clean)
#             try:
#                 if len(arg_spec.args) > 2:
#                     val = self.subfield.clean(val, initial_item)
#                 else:
#                     val = self.subfield.clean(val)
#             except ValidationError:
#                 if val:
#                     raise
#             else:
#                 if val:
#                     ret.append((val, data_item.get('ORDER', None)))
#         
#         def compare_ordering_key(k):
#             if k[1] is None:
#                 return (1, 0) # +infinity, larger than any number
#             return (0, k[1])
#         
#         ret.sort(key=compare_ordering_key)
#         return [item[0] for item in ret]
# 
# class HiddenJSONField(Field):
#     widget = HiddenInput
#     
#     def to_python(self, value):
#         if value and isinstance(value, basestring):
#             try:
#                 return json.loads(value)
#             except ValueError:
#                 raise ValidationError("Invalid JSON")#TODO more descriptive error?
#         return None
# 
#     def validate(self, value):
#         return Field.validate(self, value)
#     
#     def prepare_value(self, value):
#         if hasattr(value, 'to_primitive'):
#             return json.dumps(type(value).to_primitive(value))
#         return Field.prepare_value(self, value)
# 
# Path: dockit/models.py
# class DockitPermission(models.Model):
#     pass #a content type is required for creating permissions


from django.conf.urls.defaults import patterns, url
from django.utils.functional import update_wrapper
from django.utils.encoding import force_unicode
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
from django.contrib.admin import widgets
from django.contrib.admin.options import get_ul_class
from django.contrib.contenttypes.models import ContentType
from django import forms
from dockit.paginator import Paginator
from dockit.forms import DocumentForm
from dockit.forms.fields import PrimitiveListField, HiddenJSONField
from dockit.models import DockitPermission
from widgets import AdminPrimitiveListWidget
from breadcrumbs import Breadcrumb
from objecttools import LinkObjectTool
        from django.conf import settings
        from django import forms
        from inlines import StackedInline
        from dockit import schema
            from fields import TypedSchemaField
        from fields import DotPathField
            from django.utils.safestring import mark_safe
            from django.core.urlresolvers import reverse  
                from dockit.schema.common import DotPathTraverser
        from changelist import ChangeList
        from django.core.urlresolvers import get_urlconf, get_resolver
        from django.contrib.admin.models import LogEntry, ADDITION
        from django.contrib.admin.models import LogEntry, CHANGE
        from django.contrib.admin.models import LogEntry, DELETION
import views



FORMFIELD_FOR_FIELD_DEFAULTS = {
    forms.DateTimeField: {
        'form_class': forms.SplitDateTimeField,
        'widget': widgets.AdminSplitDateTime
    },
    forms.DateField:       {'widget': widgets.AdminDateWidget},

# Path: dockit/paginator.py

# 
# Path: dockit/forms/forms.py
# class DocumentForm(BaseDocumentForm):
#     """ The document form object """
#     __metaclass__ = DocumentFormMetaClass
# 
# Path: dockit/forms/fields.py
# class PrimitiveListField(Field):
#     '''
#     Wraps around a subfield
#     The widget receives the subfield and is responsible for rendering multiple iterations of the subfield and collecting of data
#     '''
#     widget = PrimitiveListWidget
#     
#     def __init__(self, subfield, *args, **kwargs):
#         self.subfield = subfield
#         widget = kwargs.get('widget', self.widget)
#         if isinstance(widget, type):
#             widget = widget(subfield)
#         kwargs['widget'] = widget
#         super(PrimitiveListField, self).__init__(*args, **kwargs)
#     
#     def prepare_value(self, value):
#         if value is None:
#             return
#         ret = list()
#         for val in value:
#             ret.append(self.subfield.prepare_value(val))
#         return ret
#     
#     def bound_data(self, data, initial):
#         ret = list()
#         for data_item, initial_item in zip(data, initial):
#             ret.append(self.subfield.bound_data(data_item, initial_item))
#         return ret
#     
#     def clean(self, data, initial=None):
#         ret = list()
#         for i, data_item in enumerate(data):
#             if data_item.get('DELETE', False):
#                 continue
#             if initial and len(initial) > i:
#                 initial_item = initial[i]
#             else:
#                 initial_item = None
#             val = self.subfield.bound_data(data_item['value'], initial_item)
#             
#             arg_spec = inspect.getargspec(self.subfield.clean)
#             try:
#                 if len(arg_spec.args) > 2:
#                     val = self.subfield.clean(val, initial_item)
#                 else:
#                     val = self.subfield.clean(val)
#             except ValidationError:
#                 if val:
#                     raise
#             else:
#                 if val:
#                     ret.append((val, data_item.get('ORDER', None)))
#         
#         def compare_ordering_key(k):
#             if k[1] is None:
#                 return (1, 0) # +infinity, larger than any number
#             return (0, k[1])
#         
#         ret.sort(key=compare_ordering_key)
#         return [item[0] for item in ret]
# 
# class HiddenJSONField(Field):
#     widget = HiddenInput
#     
#     def to_python(self, value):
#         if value and isinstance(value, basestring):
#             try:
#                 return json.loads(value)
#             except ValueError:
#                 raise ValidationError("Invalid JSON")#TODO more descriptive error?
#         return None
# 
#     def validate(self, value):
#         return Field.validate(self, value)
#     
#     def prepare_value(self, value):
#         if hasattr(value, 'to_primitive'):
#             return json.dumps(type(value).to_primitive(value))
#         return Field.prepare_value(self, value)
# 
# Path: dockit/models.py
# class DockitPermission(models.Model):
#     pass #a content type is required for creating permissions


# Path: dockit/admin/documentadmin.py
from django.conf.urls.defaults import patterns, url
from django.utils.functional import update_wrapper
from django.utils.encoding import force_unicode
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
from django.contrib.admin import widgets
from django.contrib.admin.options import get_ul_class
from django.contrib.contenttypes.models import ContentType
from django import forms
from dockit.paginator import Paginator
from dockit.forms import DocumentForm
from dockit.forms.fields import PrimitiveListField, HiddenJSONField
from dockit.models import DockitPermission
from widgets import AdminPrimitiveListWidget
from breadcrumbs import Breadcrumb
from objecttools import LinkObjectTool
        from django.conf import settings
        from django import forms
        from inlines import StackedInline
        from dockit import schema
            from fields import TypedSchemaField
        from fields import DotPathField
            from django.utils.safestring import mark_safe
            from django.core.urlresolvers import reverse  
                from dockit.schema.common import DotPathTraverser
        from changelist import ChangeList
        from django.core.urlresolvers import get_urlconf, get_resolver
        from django.contrib.admin.models import LogEntry, ADDITION
        from django.contrib.admin.models import LogEntry, CHANGE
        from django.contrib.admin.models import LogEntry, DELETION
import views




FORMFIELD_FOR_FIELD_DEFAULTS = {
    forms.DateTimeField: {
        'form_class': forms.SplitDateTimeField,
        'widget': widgets.AdminSplitDateTime
    },
    forms.DateField:       {'widget': widgets.AdminDateWidget},

    forms.TimeField:       {'widget': widgets.AdminTimeWidget},