Giter Site home page Giter Site logo

Comments (16)

mishbahr avatar mishbahr commented on July 17, 2024

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.

driesdesmet avatar driesdesmet commented on July 17, 2024

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.

mishbahr avatar mishbahr commented on July 17, 2024

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.

mishbahr avatar mishbahr commented on July 17, 2024

@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.

driesdesmet avatar driesdesmet commented on July 17, 2024

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.

mishbahr avatar mishbahr commented on July 17, 2024

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.

mishbahr avatar mishbahr commented on July 17, 2024

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.

driesdesmet avatar driesdesmet commented on July 17, 2024

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.

driesdesmet avatar driesdesmet commented on July 17, 2024

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.

driesdesmet avatar driesdesmet commented on July 17, 2024

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.

mishbahr avatar mishbahr commented on July 17, 2024

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.

driesdesmet avatar driesdesmet commented on July 17, 2024

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.

driesdesmet avatar driesdesmet commented on July 17, 2024

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.

mishbahr avatar mishbahr commented on July 17, 2024

You are correct!

Fixed in 88dda1f

Thanks

from djangocms-forms.

driesdesmet avatar driesdesmet commented on July 17, 2024

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!

Fixed in 88dda1f
88dda1f

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.

mishbahr avatar mishbahr commented on July 17, 2024

I'll push it to PyPi :-)

from djangocms-forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.