Skip to content

Commit

Permalink
Merge pull request #255 from grepthink/master
Browse files Browse the repository at this point in the history
Forgot Password Fix
  • Loading branch information
Kapn committed Feb 8, 2020
2 parents 3d7636e + c49b699 commit 6cf6025
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 15 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ sendgrid
django-gravatar2
xlwt
Django==1.11.18
tox
8 changes: 4 additions & 4 deletions teamwork/apps/core/helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Required headers for sendgrid: (sendgrid, os)
import sendgrid
from sendgrid import SendGridAPIClient
import os
from sendgrid.helpers.mail import *
from sendgrid.helpers.mail import Mail, Email, Personalization, Content

from django.http import JsonResponse
from django.db.models import Q
Expand Down Expand Up @@ -54,9 +54,9 @@ def send_email(recipients, gt_email, subject, content):
else:
return HttpResponseBadRequest("Bad Request")


print("settings.EMAIL_SENDGRID_KEY:", settings.EMAIL_SENDGRID_KEY)
# Handle email sending
sg = sendgrid.SendGridAPIClient(apikey=settings.EMAIL_SENDGRID_KEY)
sg = SendGridAPIClient(settings.EMAIL_SENDGRID_KEY)

mail = Mail()
mail.from_email = Email(gt_email)
Expand Down
20 changes: 9 additions & 11 deletions teamwork/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,21 @@

EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_PORT = 587
EMAIL_HOST_USER = os.environ.get('SENDGRID_USERNAME')
EMAIL_HOST_PASSWORD = os.environ.get('SENDGRID_PASSWORD')
EMAIL_HOST_USER = 'apikey'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'Grepthink Team <info@grepthink.com>'

if DEBUG:
EMAIL_SENDGRID_KEY = os.environ.get('SENDGRID_TEST_KEY')
if DEBUG:
EMAIL_SENDGRID_KEY = config('SENDGRID_TEST_KEY', default='Not Set')
else:
EMAIL_SENDGRID_KEY = os.environ.get('SENDGRID_API_KEY')
EMAIL_SENDGRID_KEY = config('SENDGRID_API_KEY', default='Not Set')

EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'Grepthink Team <info@grepthink.com>'
EMAIL_HOST_PASSWORD = EMAIL_SENDGRID_KEY

isProd = config('PRODUCTION', default=False)
IS_PRODUCTION = config('PRODUCTION', default=False)

if isProd:
if IS_PRODUCTION:
pass
#For Testing, comment out for production
#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
else:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

Expand Down
99 changes: 99 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Quicktro
# --------
#
# To use, run::
#
# tox
#
# To list all entry points and their descriptions, run::
#
# tox -alv
#
[tox]
envlist=flake8,docformatter,pydocstyle,isort
skipsdist=True

[testenv]
# The default environment. All other environments extend this one.
basepython = python3.6
passenv = USER

[pylint]
deps =
pylint==2.3.1

[flake8]
# E501: line too long (other tools check line length)
# E704: multiple statements on one line (we like that, for lambdas!)
# E731: do not assign a lambda expression, use a def
# W503,W504: https://github.com/PyCQA/pycodestyle/issues/498#issue-148719255
# Both flake8 and pycodestyle configuration overlap, be sure to update both!
ignore = E501,W503,W504,E704,E731,E701
max-line-length = 100
exclude = .tox
deps =
entrypoints==0.3
flake8==3.7.5
mccabe==0.6.1
pycodestyle==2.5.0
pyflakes==2.1.0

[pycodestyle]
# Both flake8 and pycodestyle configuration overlap, be sure to update both!
ignore = E501,W503,W504,E704,E731,E701
max-line-length = 100
statistics = True
explain = True
deps =
autopep8==1.4.3
pycodestyle==2.5.0

[docformatter]
deps =
docformatter==1.0
untokenize==0.1.1

[pydocstyle]
# D101: Missing docstring in public class
# D212: Multi-line docstring summary should start at the first line
# D203,D204: 1 blank line required before/after class docstring
ignore = D101,D212,D203,D204
deps = pydocstyle==3.0.0
six==1.12.0
snowballstemmer==1.2.1

[testenv:flake8]
description = Quick and basic Lint using 'flake8' Tool
deps = {[flake8]deps}
commands = {envbindir}/flake8

[testenv:pydocstyle]
description = Checks docstrings for compliance with a subset of PEP 257 conventions
deps =
{[pydocstyle]deps}
commands =
{envbindir}/pydocstyle --source --explain \
--add-ignore D101,D212,D213,D203,D204 \
{toxinidir}

[testenv:docformatter]
description = Automatically formats docstrings to follow a subset of the PEP 257 conventions
deps =
{[docformatter]deps}
commands =
{envbindir}/docformatter \
--recursive \
--pre-summary-newline \
--wrap-summaries=100 \
--wrap-descriptions=100 \
{posargs:in_place} \
{toxinidir}

[testenv:isort]
description = Automatically sort python imports
deps =
isort==4.3.17
commands =
{envbindir}/isort --quiet --apply --recursive \
{toxinidir}

0 comments on commit 6cf6025

Please sign in to comment.