For whatever reason, a random space is getting inserted in the UUID of a record. I send out emails for people to click on confirm or cancel links to update the records in my database. I use the UUID to make sure they are updating the correct record.
I generate the HTML for the link within my forms.py- If I only have the cancel_donation_link in there, it works fine. Once confirmation link is added. It add a space inbetween the canceled link UUID.
for special_word in values['special_words']:
print special_word
text = values['text']
print text
uuid = rescheduled_donor.uuid
if special_word == "confirm_donation_link":
values['text'] = text.replace(
special_word,
'<a href="http://{0}/actions/email_blasts/confirm/' \
'{1}">Confirm Donation</a>'.format(
domain,
uuid
)
)
values['special_words'].remove(special_word)
continue
if special_word == "cancel_donation_link":
values['text'] = text.replace(
special_word,
'<a href="http://{0}/actions/email_blasts/cancel/' \
'{1}">Cancel</a>'.format(
domain,
uuid
)
)
values['special_words'].remove(special_word)
continue
Right before I send off all the context to the email template I print out the html which shows NO space in between the UUID
<div>If you wish to cancel your donation click here: <a href="http://127.0.0.1:8000/actions/ema
il_blasts/cancel/f42f1915-2e6b-401c-bd0f-e99ba54e9ea5">Cancel</a> </div>
Once the email is sent, the URL has a space in the UUID section. It gets replaced by %20.
Cancel
template
<div style="color:#500050">
<img src="{{ STATIC_URL}}images/email_logo2.jpg">
<p>
{{ message|safe }}
</p>
<p>
{% for image in pages %}
<img src="{{ MEDIA_URL }}{{ image }}">
{% endfor %}
</p>
<p>
{{ closing_message|safe }}
</p>
</div>
~
I have no idea why or how this random space is getting inserted.
HTML From Email
<div style="color:#500050">
</p><div>If you have any questions or need any assistance you may reply by e-mail or call customer service <a href="tel:631-234-0000" value="+16312340000" target="_blank">631-234-0000</a>.<br></div><div><br></div><div><br></div><div>To confirm this new date, click here: <a href="http://127.0.0.1:8000/actions/email_blasts/confirm/1544ce69-3c44-4554-839a-a2fd09f049e3" target="_blank">Confirm Donation</a> </div><div><br></div><div>To pick a different date, click here: <a href="http://127.0.0.1:8000/external/1544ce69-3c44-4554-839a-a2fd09f049e3/" target="_blank">Donate</a> </div><div><br></div><div>To cancel your donation, click here: <a href="http://127.0.0.1:8000/actions/email_blasts/cancel/1544ce%2069-3c44-4554-839a-a2fd09f049e3" target="_blank">Cancel</a> <br></div>
<p></p>
<p>
</p>
<p>
<br>
</p>
</div>