Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only allow certain types to be attached #3

Closed
panosl opened this issue Nov 30, 2009 · 8 comments
Closed

Only allow certain types to be attached #3

panosl opened this issue Nov 30, 2009 · 8 comments

Comments

@panosl
Copy link

panosl commented Nov 30, 2009

A patch that allows users to specify the type of files that can be attached:

ATTACHMENTS_ALLOWED_TYPES = '.jpg .png .jpeg .gif .bmp'

'' is special and everything can be attached.

http://panos.solhost.org/temp/allowed_types.patch

@bartTC
Copy link
Owner

bartTC commented Nov 30, 2009

I don't like "" for "everything". None as a default value makes more sense.

Why raising an IntegrityError and overwriting the save method? It's already checked in the form.

@panosl
Copy link
Author

panosl commented Dec 1, 2009

I'll switch to None :)

As for overriding the save() method, there we have model validation, while in the form it only checks on the upload form. You can still attach other types from shell etc.

@panosl
Copy link
Author

panosl commented Dec 1, 2009

What should '' mean? If a user chooses to set:

ATTACHMENTS_ALLOWED_TYPES = ''

@bartTC
Copy link
Owner

bartTC commented Apr 3, 2010

I dont see the need for validation on model level, if the admin does that from the shell, he should take care of it.

I'm fine with the form validation but I have some minor nits how it's currently done. I try to add this feature asap and leave that file open.

@panosl
Copy link
Author

panosl commented Apr 3, 2010

Fine, let's ditch the validation at the model level :)

@panosl
Copy link
Author

panosl commented Oct 8, 2011

I've published a branch[1] on launchpad which includes this update and a way to limit the total size of attachments per model here:

https://code.launchpad.net/~panosl/+junk/django-attachments

@bartTC
Copy link
Owner

bartTC commented May 9, 2013

I didn't heard of a need for this in teh past, I'm going to close this. Thank you.

@bartTC bartTC closed this as completed May 9, 2013
@dmarcelino
Copy link

@bartTC I have a similar albeit different requirement. Is there currently a way to restrict which file types can be attached (globally or per model/form)? If not can you point me to a way to work around it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants