Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

File type management #255

Open
yakky opened this Issue · 2 comments

2 participants

@yakky
Collaborator

It would be great to have a way an easy way to define file types other than Image; this way it could be possible to associate different file icons according to type (say: recognize "PDF" file type and associate a PDF icon to it) and define allowed file type in the admin widget (e.g.: accept only PDF file in a file field); having used django-fliebrowser I think this could be very handy.
Key hooks are mostly in place already (matches_file_type is there for a reason, I guess :) )
Hardest part would be to implement it in a clean way.
I can take care of this having a very rough implementation for my own purpose

@stefanfoulis
Owner

Cool. What would your approach be?
Subclassing like with images or some functionality on the file model itself.
If it's just about the icon, it could be selected depending on the file ending in the icons property.

@yakky
Collaborator

I have yet to come up with a complete description and through analysis, but I'd like to avoid subclassing in favor of a setting to configure a list of file extension with icon and descriptive file type and a way to filter files using this data:

FILER_TYPE = {
     'document': {'exts':('doc','docx','pdf','rtf'),'icon':'icon_doc'}, 
     'audio': {'exts':('mp3','flac'):'icon':'mp3icon'}
}

For example we could use this to filter file types in FilerFileField / FilerImageField:

file = FilerFileField(verbose_name=_('file'),type="document")

AdminFileWidget could thus use this information to filter out all other filetypes

@yakky yakky referenced this issue in stefanfoulis/cmsplugin-filer
Merged

Use prefetch related to trigger polymorphic downcast. #116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.