Przyspieszenie dziaƂania operatora in na vstorage.
[redakcja.git] / apps / explorer / forms.py
index 6c5c88d..33585bc 100644 (file)
@@ -1,12 +1,14 @@
 # -*- coding: utf-8 -*-
 # -*- coding: utf-8 -*-
-from django import forms
-
-from lxml import etree
+import os
 from librarian import dcparser
 from librarian import dcparser
+
+from django import forms
+from django.conf import settings
 import django.utils
 
 from explorer import models
 
 import django.utils
 
 from explorer import models
 
+
 class PersonField(forms.CharField):
     def clean(self, value):
         try:
 class PersonField(forms.CharField):
     def clean(self, value):
         try:
@@ -79,6 +81,17 @@ class SplitForm(forms.Form):
     fulltext = forms.CharField(widget=forms.HiddenInput(), required=False)
     splittext = forms.CharField(widget=forms.HiddenInput(), required=False)
 
     fulltext = forms.CharField(widget=forms.HiddenInput(), required=False)
     splittext = forms.CharField(widget=forms.HiddenInput(), required=False)
 
+class GalleryChoiceForm(forms.ModelForm):
+    subpath = forms.ChoiceField(choices=())
+
+    def __init__(self, *args, **kwargs):
+        super(GalleryChoiceForm, self).__init__(*args, **kwargs)
+        self.fields['subpath'].choices = [(settings.IMAGE_DIR + '/' + x, x) for x in os.listdir(settings.MEDIA_ROOT + settings.IMAGE_DIR)]
+
+    class Meta:
+        model = models.GalleryForDocument
+        fields = ('document', 'subpath',)
+
 class DublinCoreForm(forms.Form):
     about = forms.URLField(verify_exists=False)
     author = PersonField()
 class DublinCoreForm(forms.Form):
     about = forms.URLField(verify_exists=False)
     author = PersonField()
@@ -109,4 +122,5 @@ class DublinCoreForm(forms.Form):
             vdict = info.to_dict()
             for name in self.fields.keys():
                 if vdict.has_key(name):
             vdict = info.to_dict()
             for name in self.fields.keys():
                 if vdict.has_key(name):
-                    self.fields[name].initial = vdict[name]
\ No newline at end of file
+                    self.fields[name].initial = vdict[name]
+