class ImageInsertionForm(forms.Form): """ Form for selecting parameters of the image (e.g. format) prior to insertion into a rich text area """ format = forms.ChoiceField(choices=[(format.name, format.label) for format in get_image_formats()], widget=forms.RadioSelect) alt_text = forms.CharField()
class ImageFormatChoiceBlock(FieldBlock): field = forms.ChoiceField(choices=[(format.name, format.label) for format in get_image_formats()])
def get_all_image_formats(): return [{ 'label': str(f.label), 'value': f.name } for f in get_image_formats()]