Comments (16)
From what I can remember — I needed the files later to be be used as an attachment for sending email submissions via email. See: https://github.com/mishbahr/djangocms-forms/blob/master/djangocms_forms/forms.py#L357
from djangocms-forms.
You seem to approach the uploaded files from the fields, while when using a FormView as you do, the files are available in form.files already. Any reason why you took this approach?
I'd like to rewrite it a bit, but don't want to overlook something.
from djangocms-forms.
I'm more than happy for you to refactor bits.
Just looking through the code.. can't really remember why I did it this way.
from djangocms-forms.
@driesdesmet I slightly refactored the email attachment logic last night. Now we get the files form request.FILES
. Please try this, and let me know.
— Mishbah
from djangocms-forms.
Hi mishbahr. Thank you for your work. I was doing the same this morning, and since I'm trying to improve on my programming skill, I would care if you have a look at it. I've made a pull new #15, but it doesn't automerge with the changes you've done.
I think my patch particularly solves my problem I had with an S3 storage class which doesn't provide a .path method. So in my case, your solution wouldn't work. I'm going to comment on your code to open up discussion. Again, I'm not an experienced contributor, but I'd like to very much improve. Let me know what you think.
from djangocms-forms.
Hmm. looks like we both did very similar thing. I removed the bit where I was trying to access the file path.. and as for attachments.. I'm looping through request.FILES
instead of form.files
as per doc here: https://docs.djangoproject.com/en/1.8/topics/http/file-uploads/#basic-file-uploads
Please try using my latest commit and see if it works with S3 Storage. If not .. I'll try to resolve the merge conflict. Thanks
from djangocms-forms.
UPDATE: I have just tried my code using django-storages-redux==1.3 with:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
Its uploads to S3 bucket just fine. However the email attachment seems to 0 Bytes
:-(
from djangocms-forms.
Yes. I fixed this. One moment.
On 7 October 2015 at 15:49, Mishbah Razzaque [email protected]
wrote:
UPDATE: I have just tried my code using django-storages-redux==1.3 with:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
Its uploads to S3 bucket just fine. However the email attachment seems to 0
Bytes :-(—
Reply to this email directly or view it on GitHub
#14 (comment)
.
Dries Desmet
URGA | creatieve communicatie
Zuiderlaan 69
8790 Waregem
t 056 61 41 94
m 0477 19 41 13
[email protected]
www.urga.be
from djangocms-forms.
It's because Django's file object returns an empty bytestring when the file object is not open yet. I'm not sure if this is expected behaviour. It should probably return an exception rather than just a zero length bytestring. the version #16 PR runs for me without errors.
from djangocms-forms.
btw, I wondered why you create a hash for file names at all. Is that because they wouldn't get overwritten? Doesn't Django create a new filename anyway if it already exists? I also noticed that you generate a has only once for every file field, which means filenames uploaded within the same form would have the same hash. Intended?
from djangocms-forms.
Just committed fully working code. Took some inspiration from #15 pull request :-)
As far as using a hash in filename -- its not based on filename but rather just a UUID appended to filename. So I'm hoping it will be unique per file.
from djangocms-forms.
If you'd like it to be unique per file, you should probably put it within the for loop for every file field in handle_uploaded_files. No?
from djangocms-forms.
btw, I've sent you a google chat invitation. Thought that would talk easier. Couldn't see your name in django-cms chatroom either. My nichname is TrioTorus.
from djangocms-forms.
You are correct!
Fixed in 88dda1f
Thanks
from djangocms-forms.
Happy to help. I'm delighted you made this plugin, and now it works with S3!
On 7 October 2015 at 16:21, Mishbah Razzaque [email protected]
wrote:
You are correct!
Thanks
—
Reply to this email directly or view it on GitHub
#14 (comment)
.
Dries Desmet
URGA | creatieve communicatie
Zuiderlaan 69
8790 Waregem
t 056 61 41 94
m 0477 19 41 13
[email protected]
www.urga.be
from djangocms-forms.
I'll push it to PyPi :-)
from djangocms-forms.
Related Issues (20)
- Missing migrations HOT 2
- Empty choice of Form Template yields in error during rendering
- Issues with files stored using boto
- Incorrect behavior with "Form submissions" while copying the plugin.
- Form submissions "sent on" does not respect settings.TIME_ZONE
- admin html rendering HOT 2
- django.conf.urls.patterns() was removed in 1.10 HOT 1
- Is is possible to add DjangoCMS TextPlugin?
- 'PluginReferenceField' object has no attribute 'rel' HOT 1
- 'PluginReferenceField' object has no attribute 'rel' HOT 1
- 'PluginReferenceField' object has no attribute 'rel' HOT 1
- success message not appearing after submitting form.
- How to use Jquery Validation for djangocms forms
- How to customize the template to get application forms design for djangocms form. HOT 1
- default attached file for e-mail
- 'Dataset' object has no attribute 'xls' HOT 2
- Python 2 Compatible? HOT 3
- compatibility with django 3.9 HOT 1
- Make email work on form submission wtih djangocms 3.11 and python 3.7
- Bug with file upload on form submission AttributeError: 'InMemoryUploadedFile' object has no attribute '_size'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from djangocms-forms.