kmike / django-generic-images

This app provides image model (with useful managers, fields, utility methods and advanced admin image uploader) that can be attached to any other Django model using generic relations. License is MIT.

Changed (Δ73 bytes):

raw changeset »

generic_images/admin.py (5 lines added, 4 lines removed)

Up to file-list generic_images/admin.py:

@@ -7,11 +7,12 @@ from generic_images.models import Attach
7
7
8
8
admin.site.register(AttachedImage)
9
9
10
def attachedimage_form_factory(lang='en'):
10
def attachedimage_form_factory(lang='en', debug=False):
11
11
    ''' Returns ModelForm class to be used in admin.
12
12
        'lang' is the language for GearsUploader (can be 'en' and 'ru' at the
13
13
        moment).
14
14
    '''
15
    yui = '' if debug else '.yui'
15
16
    class _AttachedImageAdminForm(forms.ModelForm):
16
17
17
18
        caption = forms.CharField(label=_('Caption'), required=False)
@@ -19,7 +20,7 @@ def attachedimage_form_factory(lang='en'
19
20
        class Media:
20
21
            js = [
21
22
                  'generic_images/js/mootools-1.2.4-core-yc.js',
22
                  'generic_images/js/GearsUploader.%s.yui.js' % lang,
23
                  'generic_images/js/GearsUploader.%s%s.js' % (lang, yui,),
23
24
                  'generic_images/js/AttachedImageInline.js',
24
25
            ]
25
26
@@ -31,7 +32,7 @@ AttachedImageAdminForm = attachedimage_f
31
32
''' Form for AttachedImage model to be used in inline admin '''
32
33
33
34
34
def attachedimages_inline_factory(lang='en', max_width=''):
35
def attachedimages_inline_factory(lang='en', max_width='', debug=False):
35
36
    '''  Returns InlineModelAdmin for attached images.
36
37
        'lang' is the language for GearsUploader (can be 'en' and 'ru' at the
37
38
        moment). 'max_width' is default resize width parameter to be set in
@@ -40,7 +41,7 @@ def attachedimages_inline_factory(lang='
40
41
41
42
    class _AttachedImagesInline(GenericTabularInline):
42
43
        model = AttachedImage
43
        form = attachedimage_form_factory(lang)
44
        form = attachedimage_form_factory(lang, debug)
44
45
        template = 'generic_images/attached_images_inline.html'
45
46
        max_w = max_width
46
47