Downgrade reason (#197)

* adding downgrade survey
* adding release to procfile
* removing unused manage.py autorun behavior
This commit is contained in:
Cole 2018-09-15 20:59:09 -04:00 committed by GitHub
parent d073748885
commit 8d1024c0fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 202 additions and 14 deletions

2
.gitignore vendored
View File

@ -79,3 +79,5 @@ include
mydata
*.dump
.python-version

View File

@ -7,6 +7,7 @@ url = "https://pypi.org/simple"
python-dotenv = { version = "*" }
pytest = { version = "*" }
pytest-mock = "*"
pylint = "*"
[requires]
python_version = "3.6"
@ -30,8 +31,9 @@ Flask-Redis = "==0.0.6"
Flask-SQLAlchemy = "==2.1"
Flask-Testing = "==0.6.1"
unicodecsv = "==0.14.1"
flask-migrate = "*"
flask-migrate = "==2.2.1"
premailer = "==3.2.0"
ptvsd = "==4.1.2"
[pipenv]
allow_prereleases = true

147
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "b8f5f3bb6f3a51dbdd1b1111142970862c2b59926e803b4d095cd3f4978e0114"
"sha256": "0beec9c65d249913687cbf70f560a64c506f6f3bfa339c178bd90c4d30efb986"
},
"pipfile-spec": 6,
"requires": {
@ -44,6 +44,20 @@
"index": "pypi",
"version": "==4.2.0"
},
"certifi": {
"hashes": [
"sha256:376690d6f16d32f9d1fe8932551d80b23e9d393a8578c5633a2ed39a64861638",
"sha256:456048c7e371c089d0a77a5212fb37a2c2dce1e24146e3b7e0261736aaeaa22a"
],
"version": "==2018.8.24"
},
"chardet": {
"hashes": [
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
],
"version": "==3.0.4"
},
"click": {
"hashes": [
"sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",
@ -56,6 +70,7 @@
"sha256:066d8bc5229af09617e24b3ca4d52f1f9092d9e061931f4184cd572885c23204",
"sha256:3b5103e8789da9e936a68d993b70df732d06b8bb9a337a05ed4eb52c17ef7206"
],
"markers": "python_version != '3.1.*' and python_version != '3.2.*' and python_version >= '2.7' and python_version != '3.3.*' and python_version != '3.0.*'",
"version": "==1.0.3"
},
"cssutils": {
@ -146,6 +161,13 @@
"index": "pypi",
"version": "==1.2.0"
},
"idna": {
"hashes": [
"sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e",
"sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16"
],
"version": "==2.7"
},
"itsdangerous": {
"hashes": [
"sha256:cbb3fcf8d3e33df861709ecaf89d9e6629cff0a217bc2848f1b41cd30d360519"
@ -261,6 +283,15 @@
"index": "pypi",
"version": "==2.7.4"
},
"ptvsd": {
"hashes": [
"sha256:080ab468f9ccaf2c95fd4823edaabc19243d5a56fe89ad11009662e9492d29ff",
"sha256:45dab79d52a6962322933428f6805ee61467c255005b1bc017fed7f21e2c258a",
"sha256:d0596e1ff5c902d04bbc7b1613b76eb9b6e98599e9006bf6b402b374d8010de6"
],
"index": "pypi",
"version": "==4.1.2"
},
"python-dateutil": {
"hashes": [
"sha256:1adb80e7a782c12e52ef9a8182bebeb73f1d7e24e374397af06fb4956c8dc5c0",
@ -335,6 +366,14 @@
"index": "pypi",
"version": "==0.14.1"
},
"urllib3": {
"hashes": [
"sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf",
"sha256:b5725a0bd4ba422ab0e66e89e030c806576753ea3ee08554382c14e685d117b5"
],
"markers": "python_version != '3.1.*' and python_version != '3.0.*' and python_version >= '2.6' and python_version != '3.2.*' and python_version != '3.3.*' and python_version < '4'",
"version": "==1.23"
},
"vine": {
"hashes": [
"sha256:52116d59bc45392af9fdd3b75ed98ae48a93e822cee21e5fda249105c59a7a72",
@ -351,12 +390,19 @@
}
},
"develop": {
"astroid": {
"hashes": [
"sha256:292fa429e69d60e4161e7612cb7cc8fa3609e2e309f80c224d93a76d5e7b58be",
"sha256:c7013d119ec95eb626f7a2011f0b63d0c9a095df9ad06d8507b37084eada1a8d"
],
"version": "==2.0.4"
},
"atomicwrites": {
"hashes": [
"sha256:0312ad34fcad8fac3704d441f7b317e50af620823353ec657a53e981f92920c0",
"sha256:ec9ae8adaae229e4f8446952d204a3e4b5fdd2d099f9be3aaf556120135fb3ee"
],
"markers": "python_version != '3.0.*' and python_version != '3.2.*' and python_version != '3.3.*' and python_version >= '2.7' and python_version != '3.1.*'",
"markers": "python_version >= '2.7' and python_version != '3.0.*' and python_version != '3.2.*' and python_version != '3.1.*' and python_version != '3.3.*'",
"version": "==1.2.1"
},
"attrs": {
@ -366,6 +412,56 @@
],
"version": "==18.2.0"
},
"isort": {
"hashes": [
"sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af",
"sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8",
"sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497"
],
"markers": "python_version >= '2.7' and python_version != '3.0.*' and python_version != '3.2.*' and python_version != '3.1.*' and python_version != '3.3.*'",
"version": "==4.3.4"
},
"lazy-object-proxy": {
"hashes": [
"sha256:0ce34342b419bd8f018e6666bfef729aec3edf62345a53b537a4dcc115746a33",
"sha256:1b668120716eb7ee21d8a38815e5eb3bb8211117d9a90b0f8e21722c0758cc39",
"sha256:209615b0fe4624d79e50220ce3310ca1a9445fd8e6d3572a896e7f9146bbf019",
"sha256:27bf62cb2b1a2068d443ff7097ee33393f8483b570b475db8ebf7e1cba64f088",
"sha256:27ea6fd1c02dcc78172a82fc37fcc0992a94e4cecf53cb6d73f11749825bd98b",
"sha256:2c1b21b44ac9beb0fc848d3993924147ba45c4ebc24be19825e57aabbe74a99e",
"sha256:2df72ab12046a3496a92476020a1a0abf78b2a7db9ff4dc2036b8dd980203ae6",
"sha256:320ffd3de9699d3892048baee45ebfbbf9388a7d65d832d7e580243ade426d2b",
"sha256:50e3b9a464d5d08cc5227413db0d1c4707b6172e4d4d915c1c70e4de0bbff1f5",
"sha256:5276db7ff62bb7b52f77f1f51ed58850e315154249aceb42e7f4c611f0f847ff",
"sha256:61a6cf00dcb1a7f0c773ed4acc509cb636af2d6337a08f362413c76b2b47a8dd",
"sha256:6ae6c4cb59f199d8827c5a07546b2ab7e85d262acaccaacd49b62f53f7c456f7",
"sha256:7661d401d60d8bf15bb5da39e4dd72f5d764c5aff5a86ef52a042506e3e970ff",
"sha256:7bd527f36a605c914efca5d3d014170b2cb184723e423d26b1fb2fd9108e264d",
"sha256:7cb54db3535c8686ea12e9535eb087d32421184eacc6939ef15ef50f83a5e7e2",
"sha256:7f3a2d740291f7f2c111d86a1c4851b70fb000a6c8883a59660d95ad57b9df35",
"sha256:81304b7d8e9c824d058087dcb89144842c8e0dea6d281c031f59f0acf66963d4",
"sha256:933947e8b4fbe617a51528b09851685138b49d511af0b6c0da2539115d6d4514",
"sha256:94223d7f060301b3a8c09c9b3bc3294b56b2188e7d8179c762a1cda72c979252",
"sha256:ab3ca49afcb47058393b0122428358d2fbe0408cf99f1b58b295cfeb4ed39109",
"sha256:bd6292f565ca46dee4e737ebcc20742e3b5be2b01556dafe169f6c65d088875f",
"sha256:cb924aa3e4a3fb644d0c463cad5bc2572649a6a3f68a7f8e4fbe44aaa6d77e4c",
"sha256:d0fc7a286feac9077ec52a927fc9fe8fe2fabab95426722be4c953c9a8bede92",
"sha256:ddc34786490a6e4ec0a855d401034cbd1242ef186c20d79d2166d6a4bd449577",
"sha256:e34b155e36fa9da7e1b7c738ed7767fc9491a62ec6af70fe9da4a057759edc2d",
"sha256:e5b9e8f6bda48460b7b143c3821b21b452cb3a835e6bbd5dd33aa0c8d3f5137d",
"sha256:e81ebf6c5ee9684be8f2c87563880f93eedd56dd2b6146d8a725b50b7e5adb0f",
"sha256:eb91be369f945f10d3a49f5f9be8b3d0b93a4c2be8f8a5b83b0571b8123e0a7a",
"sha256:f460d1ceb0e4a5dcb2a652db0904224f367c9b3c1470d5a7683c0480e582468b"
],
"version": "==1.3.1"
},
"mccabe": {
"hashes": [
"sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
"sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
],
"version": "==0.6.1"
},
"more-itertools": {
"hashes": [
"sha256:c187a73da93e7a8acc0001572aebc7e3c69daf7bf6881a2cea10650bd4420092",
@ -379,6 +475,7 @@
"sha256:6e3836e39f4d36ae72840833db137f7b7d35105079aee6ec4a62d9f80d594dd1",
"sha256:95eb8364a4708392bae89035f45341871286a333f749c3141c20573d2b3876e1"
],
"markers": "python_version >= '2.7' and python_version != '3.0.*' and python_version != '3.2.*' and python_version != '3.1.*' and python_version != '3.3.*'",
"version": "==0.7.1"
},
"py": {
@ -386,15 +483,24 @@
"sha256:06a30435d058473046be836d3fc4f27167fd84c45b99704f2fb5509ef61f9af1",
"sha256:50402e9d1c9005d759426988a492e0edaadb7f4e68bcddfea586bc7432d009c6"
],
"markers": "python_version != '3.2.*' and python_version != '3.0.*' and python_version >= '2.7' and python_version != '3.1.*' and python_version != '3.3.*'",
"markers": "python_version >= '2.7' and python_version != '3.0.*' and python_version != '3.2.*' and python_version != '3.1.*' and python_version != '3.3.*'",
"version": "==1.6.0"
},
"pylint": {
"hashes": [
"sha256:1d6d3622c94b4887115fe5204982eee66fdd8a951cf98635ee5caee6ec98c3ec",
"sha256:31142f764d2a7cd41df5196f9933b12b7ee55e73ef12204b648ad7e556c119fb"
],
"index": "pypi",
"version": "==2.1.1"
},
"pytest": {
"hashes": [
"sha256:453cbbbe5ce6db38717d282b758b917de84802af4288910c12442984bde7b823",
"sha256:a8a07f84e680482eb51e244370aaf2caa6301ef265f37c2bdefb3dd3b663f99d"
],
"index": "pypi",
"markers": null,
"version": "==3.8.0"
},
"pytest-mock": {
@ -419,6 +525,41 @@
"sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb"
],
"version": "==1.11.0"
},
"typed-ast": {
"hashes": [
"sha256:0948004fa228ae071054f5208840a1e88747a357ec1101c17217bfe99b299d58",
"sha256:10703d3cec8dcd9eef5a630a04056bbc898abc19bac5691612acba7d1325b66d",
"sha256:1f6c4bd0bdc0f14246fd41262df7dfc018d65bb05f6e16390b7ea26ca454a291",
"sha256:25d8feefe27eb0303b73545416b13d108c6067b846b543738a25ff304824ed9a",
"sha256:29464a177d56e4e055b5f7b629935af7f49c196be47528cc94e0a7bf83fbc2b9",
"sha256:2e214b72168ea0275efd6c884b114ab42e316de3ffa125b267e732ed2abda892",
"sha256:3e0d5e48e3a23e9a4d1a9f698e32a542a4a288c871d33ed8df1b092a40f3a0f9",
"sha256:519425deca5c2b2bdac49f77b2c5625781abbaf9a809d727d3a5596b30bb4ded",
"sha256:57fe287f0cdd9ceaf69e7b71a2e94a24b5d268b35df251a88fef5cc241bf73aa",
"sha256:668d0cec391d9aed1c6a388b0d5b97cd22e6073eaa5fbaa6d2946603b4871efe",
"sha256:68ba70684990f59497680ff90d18e756a47bf4863c604098f10de9716b2c0bdd",
"sha256:6de012d2b166fe7a4cdf505eee3aaa12192f7ba365beeefaca4ec10e31241a85",
"sha256:79b91ebe5a28d349b6d0d323023350133e927b4de5b651a8aa2db69c761420c6",
"sha256:8550177fa5d4c1f09b5e5f524411c44633c80ec69b24e0e98906dd761941ca46",
"sha256:898f818399cafcdb93cbbe15fc83a33d05f18e29fb498ddc09b0214cdfc7cd51",
"sha256:94b091dc0f19291adcb279a108f5d38de2430411068b219f41b343c03b28fb1f",
"sha256:a26863198902cda15ab4503991e8cf1ca874219e0118cbf07c126bce7c4db129",
"sha256:a8034021801bc0440f2e027c354b4eafd95891b573e12ff0418dec385c76785c",
"sha256:bc978ac17468fe868ee589c795d06777f75496b1ed576d308002c8a5756fb9ea",
"sha256:c05b41bc1deade9f90ddc5d988fe506208019ebba9f2578c622516fd201f5863",
"sha256:c9b060bd1e5a26ab6e8267fd46fc9e02b54eb15fffb16d112d4c7b1c12987559",
"sha256:edb04bdd45bfd76c8292c4d9654568efaedf76fe78eb246dde69bdb13b2dad87",
"sha256:f19f2a4f547505fe9072e15f6f4ae714af51b5a681a97f187971f50c283193b6"
],
"markers": "python_version < '3.7' and implementation_name == 'cpython'",
"version": "==1.1.0"
},
"wrapt": {
"hashes": [
"sha256:d4d560d479f2c21e1b5443bbd15fe7ec4b37fe7e53d335d3b9b0a7b1226fe3c6"
],
"version": "==1.10.11"
}
}
}

View File

@ -1,2 +1,3 @@
web: gunicorn formspree:app
web: gunicorn 'formspree:debuggable_app()'
worker: celery worker --app=formspree.stuff
release: flask db upgrade

View File

@ -1,4 +1,18 @@
from . import settings
from .create_app import create_app
app = create_app()
def debuggable_app():
""" For launching with gunicorn from a Heroku Procfile.
Problem: both the web and worker processes run the same create_app code. If we start a ptvsd service in create_app, it will be
started twice on the same port, and fail.
Solution: gunicorn gets its app object through this method that also starts the debug server.
"""
if settings.DEBUG:
import ptvsd
ptvsd.enable_attach(address=('0.0.0.0', 3000))
return app
from . import manage

View File

@ -58,6 +58,3 @@ def test(args):
errno = pytest.main(argv)
sys.exit(errno)
if __name__ == "__main__":
app.run()

View File

@ -0,0 +1,5 @@
A customer has downgraded. :( :( :(
Here's the reason he or she gave:
{{reason}}

View File

@ -20,9 +20,7 @@
</form>
{% else %}
<p>Your subscription will automatically renew on {{ sub.current_period_end }}.</p>
<form action="/account/downgrade" method="POST">
<button type="submit">Cancel subscription</button>
</form>
<a href="#cancel-feedback" class="button">Cancel subscription</a>
{% endif %}
{% else %}
@ -135,8 +133,7 @@
</a>
<div class="modal narrow" id="edit-billing" aria-hidden="true">
<div class="container">
<div class="x">
<h4>Edit Invoice Address</h4><a href="#">&times;</a></div>
<div class="x"><h4>Edit Invoice Address</h4><a href="#">&times;</a></div>
<form method="POST" action="{{ url_for('update-invoice-address') }}">
<textarea rows="4" name="invoice-address">{% if current_user.invoice_address %}{{ current_user.invoice_address }}{% endif %}</textarea>
<div class="col-1-1">
@ -150,4 +147,17 @@
</div>
</div>
<div class="modal" id="cancel-feedback" aria-hidden="true">
<div class="container">
<div class="x">
<h4>Why are you cancelling?</h4>
<a href="#">&times;</a>
</div>
<form action="/account/downgrade" method="POST">
<textarea name="why" placeholder="Was it a missing feature? Bad service? Just don't need us anymore?"></textarea>
<button type="submit">Cancel Subscription</button>
</form>
</div>
</div>
{% endblock %}

View File

@ -24,3 +24,14 @@ def send_downgrade_email(customer_email):
html=render_template_string(TEMPLATES.get('downgraded.html')),
sender=settings.DEFAULT_SENDER
)
@celery.task()
def send_downgrade_reason_email(customer_email, reason):
send_email(
to=settings.CONTACT_EMAIL,
reply_to=customer_email,
subject='A customer has downgraded from {}'.format(settings.UPGRADED_PLAN_NAME),
text=render_template('email/downgraded_reason.txt', reason=reason),
sender=settings.DEFAULT_SENDER
)

View File

@ -11,7 +11,8 @@ from formspree import settings
from formspree.stuff import DB, TEMPLATES
from formspree.utils import send_email
from .models import User, Email
from .helpers import check_password, hash_pwd, send_downgrade_email
from .helpers import check_password, hash_pwd, send_downgrade_email, \
send_downgrade_reason_email
def register():
@ -273,6 +274,10 @@ def downgrade():
"warning")
return redirect(url_for('account'))
reason = request.form.get('why')
if reason:
send_downgrade_reason_email.delay(current_user.email, reason)
sub = sub.delete(at_period_end=True)
flash(u"You were unregistered from the {SERVICE_NAME} "
"{UPGRADED_PLAN_NAME} plan.".format(**settings.__dict__),