Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
armaangoel78 committed Oct 30, 2018
2 parents 85de975 + e03342e commit 78af70c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 15 deletions.
8 changes: 5 additions & 3 deletions ClubWebsite_django/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@

USE_TZ = True

EMAIL_HOST_USER = 'testemail2081@gmail.com' #this is a testing account
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'testemail2081@gmail.com'
EMAIL_HOST_PASSWORD = 'TandemTricycle'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'testemail2081@gmail.com'

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dj-database-url = "==0.4.2"
"Jinja2" = "==2.10"
Django = "==1.11.9"
Pillow = "==5.1.0"
sendgrid = "*"

[dev-packages]

Expand Down
18 changes: 16 additions & 2 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
Jinja2==2.10
django==1.11.7
djangorestframework==3.7.3
dj-database-url==0.4.2
Django==1.11.15
django-contact-us==0.4.1
django-crispy-forms==1.7.0
djangorestframework==3.7.3
gunicorn==19.7.1
whitenoise==3.3.1
dj-database-url==0.4.2
psycopg2-binary==2.7.4
Jinja2==2.10
MarkupSafe==1.0
Pillow==5.1.0
psycopg2-binary==2.7.4
python-http-client==3.1.0
pytz==2018.5
sendgrid==5.6.0
whitenoise==3.3.1
2 changes: 1 addition & 1 deletion resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ <h2>Deployment</h2>
<h2 class="display-4 subhead">Our Locations</h2>
<p class="home">Don't see a location near you? Click below to learn about creating a Code For Change
club.</p>
<a href="/projects" class="text-center btn btn-project-types btn-primary btn-xl rounded-pill mt-1">Create
<a href="/#contact" class="text-center btn btn-project-types btn-primary btn-xl rounded-pill mt-1">Create
A Club</a>

</div>
Expand Down
19 changes: 16 additions & 3 deletions website/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django.core.mail import EmailMessage
from django.shortcuts import render, redirect
from django.http import HttpResponseRedirect

import sendgrid
import os
from sendgrid.helpers.mail import *
# Create your views here.
from django.template.loader import get_template, render_to_string

Expand Down Expand Up @@ -36,8 +38,19 @@ def contact(request):
'domain': form_content,
})

email = EmailMessage('Request Project', message, to=['chscodeforchange@gmail.com'])
email.send()
'''email = EmailMessage('Request Project', message, to=['chscodeforchange@gmail.com'])
email.send()'''

sg = sendgrid.SendGridAPIClient(apikey='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')
from_email = Email("testemail2081@gmail.com")
to_email = Email("chscodeforchange@gmail.com")
subject = "New Contact From Website"
content = Content("text/plain", message)
mail = Mail(from_email, subject, to_email, content)
response = sg.client.mail.send.post(request_body=mail.get())
print(response.status_code)
print(response.body)
print(response.headers)

return redirect('/')
else:
Expand Down

0 comments on commit 78af70c

Please sign in to comment.