097514a9e8701d68f39c99c4bb28417053bf9a9f
[redakcja.git] / apps / explorer / admin.py
1 from django.contrib import admin
2 from django import forms
3 import os
4
5 from django.conf import settings
6
7 import explorer.models
8
9 admin.site.register(explorer.models.EditorSettings)
10 admin.site.register(explorer.models.EditorPanel)
11
12
13 class GalleryAdminForm(forms.ModelForm):
14     subpath = forms.ChoiceField(choices=())
15     
16     def __init__(self, *args, **kwargs):
17         super(GalleryAdminForm, self).__init__(*args, **kwargs)
18         self.fields['subpath'].choices = [(x, x) for x in os.listdir(settings.MEDIA_ROOT + settings.IMAGE_DIR)]
19         
20     class Meta:
21         mode = explorer.models.GalleryForDocument
22         fields = ('document', 'subpath',)
23
24
25 class GalleryAdmin(admin.ModelAdmin):
26     form = GalleryAdminForm
27     list_display = ('document', 'subpath',)
28     search_fields = ('document', 'subpath',)
29
30 admin.site.register(explorer.models.GalleryForDocument, GalleryAdmin)