osuosl / formsender

Simple script to email form submissions.
Apache License 2.0
3 stars 1 forks source link

string composition from form fields #79

Closed leian7 closed 7 years ago

leian7 commented 7 years ago

For #77 . Needed for osuosl-pelican's https://github.com/osuosl/osuosl-pelican/issues/159

Changes

To run tests

To "send" a test email (unable to send actual email locally because it would require running a local smtp server)

Expected output

Contact:

NAME: Firstname Lastname EMAIL: firstlast@example.com

Information:

firstlast@example.com:Firstname Lastname

127.0.0.1 - - [02/Jun/2017 16:37:48] "POST / HTTP/1.1" 302 -


- test bad "email": the email will not print in the terminal. The redirected page upon submission should include something like ?error=3&message=Improper+Form+Submission in the url.

Notes
- Did everything in ``request_handler.py``'s existing ``format_message`` method, but I can make a new method for ``format_message`` to call if needed. 
ramereth commented 7 years ago

@leian7 did you see my update to #77 related to this PR?

leian7 commented 7 years ago

@ramereth I did, I discussed it with @Kennric , and my understanding is that the list provided to fields_to_join can be completely arbitrary; the form author gets to decide their specific string and its order. For extra bits like ibm-power they can have it be a hidden field. Is this correct? Or did you want $username:$user_first:$user_last:$phone:$company:$date:$email:ibm-power:support to always be included in the string?

ramereth commented 7 years ago

How will the date field work since it's not a field in the form?

Kennric commented 7 years ago

@leian7 @ramereth for the date, we'll need to calculate that - my thought was that we'd do it in the form, but on second thought I'd rather not add javascript for that. Let's have formsender check the fields_to_join list, and if it contains 'date' just insert today's date.

ramereth commented 7 years ago

@Kennric how will we determine the format of the date being printed in the string? For this specific use-case, we need a unix echo timestamp, but we may need others later.

leian7 commented 7 years ago

@Kennric @ramereth For now I check for 'date' and insert the timestamp if 'date' is there. I interpreted "unix timestamp" as the regular "seconds since 1970" unix standard, is this correct?

leian@osuosl.org:Timestamp Test:1497398504:Annie Lei
ramereth commented 7 years ago

@leian7 yes, that is correct

ramereth commented 7 years ago

@Kennric can we please get this merged and deployed?