# Path: image_filer/context_processors.py
# def media(request):


from django.utils.translation import ugettext as _
from django.utils.text import truncate_words
from django.utils import simplejson
from django.db import models
from django import forms
from django.contrib.admin.widgets import ForeignKeyRawIdWidget
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
from django.conf import settings
from sorl.thumbnail.base import ThumbnailException
from image_filer import context_processors
        from image_filer.models import Image
        from south.modelsinspector import introspector
        from image_filer.models import Folder
        self.queryset = queryset
        self.to_field_name = to_field_name
        self.max_value = None
        self.min_value = None
        other_widget = kwargs.pop('widget', None)
        forms.Field.__init__(self, widget=self.widget(rel), *args, **kwargs)

class ImageFilerModelImageField(models.ForeignKey):
    def __init__(self, **kwargs):
        return super(ImageFilerModelImageField,self).__init__(Image, **kwargs)
    def formfield(self, **kwargs):
        # This is a fairly standard way to set up some defaults
        # while letting the caller override them.
        #defaults = {'form_class': ImageFilerImageWidget}
        defaults = {
            'form_class': ImageFilerImageFormField,
            'rel': self.rel,
        }
        defaults.update(kwargs)
        return super(ImageFilerModelImageField, self).formfield(**defaults)
    def south_field_triple(self):
        "Returns a suitable description of this field for South."
        # We'll just introspect ourselves, since we inherit.
        field_class = "django.db.models.fields.related.ForeignKey"
        args, kwargs = introspector(self)
        # That's our definition!
        return (field_class, args, kwargs)

class ImageFilerFolderWidget(ForeignKeyRawIdWidget):
    choices = None

# Path: image_filer/context_processors.py
# def media(request):


# Path: image_filer/fields.py
from django.utils.translation import ugettext as _
from django.utils.text import truncate_words
from django.utils import simplejson
from django.db import models
from django import forms
from django.contrib.admin.widgets import ForeignKeyRawIdWidget
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
from django.conf import settings
from sorl.thumbnail.base import ThumbnailException
from image_filer import context_processors
        from image_filer.models import Image
        from south.modelsinspector import introspector
        from image_filer.models import Folder

        self.queryset = queryset
        self.to_field_name = to_field_name
        self.max_value = None
        self.min_value = None
        other_widget = kwargs.pop('widget', None)
        forms.Field.__init__(self, widget=self.widget(rel), *args, **kwargs)

class ImageFilerModelImageField(models.ForeignKey):
    def __init__(self, **kwargs):
        return super(ImageFilerModelImageField,self).__init__(Image, **kwargs)
    def formfield(self, **kwargs):
        # This is a fairly standard way to set up some defaults
        # while letting the caller override them.
        #defaults = {'form_class': ImageFilerImageWidget}
        defaults = {
            'form_class': ImageFilerImageFormField,
            'rel': self.rel,
        }
        defaults.update(kwargs)
        return super(ImageFilerModelImageField, self).formfield(**defaults)
    def south_field_triple(self):
        "Returns a suitable description of this field for South."
        # We'll just introspect ourselves, since we inherit.
        field_class = "django.db.models.fields.related.ForeignKey"
        args, kwargs = introspector(self)
        # That's our definition!
        return (field_class, args, kwargs)

class ImageFilerFolderWidget(ForeignKeyRawIdWidget):
    choices = None

    input_type = 'hidden'