Esempio n. 1
0
 def __init__(self, *args, **kwargs):
     super(ImageFormMixin, self).__init__(*args, **kwargs)
     try:
         self.fields['image_file'].initial = kwargs['instance'].image.pk
     except (AttributeError, KeyError):
         pass
     self.fields['image_file'].widget = AdminFileWidget(ManyToOneRel(FilerImageField, Image, 'file_ptr'), site)
Esempio n. 2
0
 def __init__(self, *args, **kwargs):
     try:
         self.base_fields['image_file'].initial = kwargs['initial'][
             'image']['pk']
     except KeyError:
         self.base_fields['image_file'].initial = None
     self.base_fields['image_file'].widget = AdminFileWidget(
         ManyToOneRel(FilerImageField, Image, 'file_ptr'), site)
     super(ImageFormMixin, self).__init__(*args, **kwargs)
Esempio n. 3
0
 def __init__(self, *args, **kwargs):
     try:
         initial = dict(kwargs['instance'].glossary)
     except (KeyError, AttributeError):
         initial = {}
     initial.update(kwargs.pop('initial', {}))
     for key in self.glossary_fields:
         self.base_fields[key].initial = initial.get(key)
     try:
         self.base_fields['image_file'].initial = initial['image']['pk']
     except KeyError:
         self.base_fields['image_file'].initial = None
     self.base_fields['image_file'].widget = AdminFileWidget(ManyToOneRel(FilerImageField, Image, 'file_ptr'), site)
     super(GalleryImageForm, self).__init__(*args, **kwargs)
Esempio n. 4
0
 def __init__(self, *args, **kwargs):
     try:
         initial = dict(kwargs['instance'].glossary)
         has_original = True
     except (KeyError, AttributeError):
         initial = {}
         has_original = False
     initial.update(kwargs.pop('initial', {}))
     self.base_fields['position'].initial = json.dumps(
         initial.pop('position', {}))
     for key in self.glossary_field_order:
         self.base_fields[key].initial = initial.get(key)
     try:
         self.base_fields['marker_image'].initial = initial['image']['pk']
     except KeyError:
         self.base_fields['marker_image'].initial = None
         self.base_fields['use_icon'].initial = False
     else:
         self.base_fields['use_icon'].initial = True
     self.base_fields['marker_image'].widget = AdminFileWidget(
         ManyToOneRel(FilerImageField, Image, 'file_ptr'), site)
     super(MarkerForm, self).__init__(*args, **kwargs)
     if has_original:
         self.fields['title'].help_text = None