Working on Heroku integration.
parent
a5bc4c451b
commit
01d943521f
30
README.md
30
README.md
|
@ -2,22 +2,30 @@
|
|||
|
||||
This is the codebase for the website, [Snipt.net](https://snipt.net/).
|
||||
|
||||
It's a relatively well-kept Django app, so you shouldn't have too many problems getting a local copy running.
|
||||
|
||||
**Note:** These instructions assume you already have [Git](http://git-scm.com/) and [Mercurial](http://mercurial.selenic.com/) installed.
|
||||
|
||||
If you need help, visit `#snipt` on irc.freenode.net.
|
||||
|
||||
# Running the Django app
|
||||
|
||||
1. Clone the repo.
|
||||
2. Setup a virtualenv.
|
||||
3. `pip install -r requirements.txt`
|
||||
4. `pip install --index-url https://code.stripe.com --upgrade stripe`
|
||||
5. Copy settings_local-template.py to settings_local.py and edit the settings. Be sure to change the [`SESSION_COOKIE_DOMAIN`](https://github.com/nicksergeant/snipt/blob/master/settings_local-template.py#L58), or authentication won't work.
|
||||
6. `python manage.py syncdb`
|
||||
7. `python manage.py migrate`
|
||||
8. `python manage.py runserver`
|
||||
9. If you created a superuser in the syncdb step, you need to also run `python manage.py backfill_api_keys` to generate an API key for that user.
|
||||
5. `python manage.py syncdb`
|
||||
6. `python manage.py migrate`
|
||||
7. `python manage.py runserver`
|
||||
8. If you created a superuser in the syncdb step, you need to also run `python manage.py backfill_api_keys` to generate an API key for that user.
|
||||
|
||||
# Deploying to Heroku
|
||||
|
||||
1. Clone the repo.
|
||||
2. `heroku create`
|
||||
3. `heroku config:add DEBUG=True`
|
||||
3. `heroku config:add INTERCOM_SECRET_KEY=`
|
||||
3. `heroku config:add POSTMARK_API_KEY=`
|
||||
3. `heroku config:add RAVEN_CONFIG_DSN=`
|
||||
3. `heroku config:add SECRET_KEY=`
|
||||
3. `heroku config:add STRIPE_SECRET_KEY=`
|
||||
4. `git push heroku`
|
||||
5. `heroku run pip install --index-url https://code.stripe.com --upgrade stripe`
|
||||
6. `heroku run python manage.py syncdb`
|
||||
7. `heroku run python manage.py migrate`
|
||||
|
||||
Any problems / questions / bugs, [create an issue](https://github.com/nicksergeant/snipt/issues). Thanks! :)
|
||||
|
|
|
@ -18,7 +18,7 @@ def cancel_subscription(request):
|
|||
if request.user.profile.stripe_id is None:
|
||||
return {}
|
||||
else:
|
||||
stripe.api_key = STRIPE_SECRET_KEY
|
||||
stripe.api_key = os.environ['STRIPE_SECRET_KEY']
|
||||
customer = stripe.Customer.retrieve(request.user.profile.stripe_id)
|
||||
customer.delete()
|
||||
|
||||
|
@ -36,7 +36,7 @@ def stripe_account_details(request):
|
|||
if request.user.profile.stripe_id is None:
|
||||
return {}
|
||||
else:
|
||||
stripe.api_key = STRIPE_SECRET_KEY
|
||||
stripe.api_key = os.environ['STRIPE_SECRET_KEY']
|
||||
customer = stripe.Customer.retrieve(request.user.profile.stripe_id)
|
||||
|
||||
data = {
|
||||
|
|
17
settings.py
17
settings.py
|
@ -2,16 +2,20 @@ import dj_database_url, os
|
|||
|
||||
ABSOLUTE_URL_OVERRIDES = { 'auth.user': lambda u: "/%s/" % u.username, }
|
||||
ACCOUNT_ACTIVATION_DAYS = 0
|
||||
ADMINS = (('Name', 'name@domain.com'),)
|
||||
ADMINS = (('Nick Sergeant', 'nick@snipt.net'),)
|
||||
ALLOWED_HOSTS = ['*']
|
||||
AUTH_PROFILE_MODULE = 'accounts.UserProfile'
|
||||
AUTHENTICATION_BACKENDS = ('utils.backends.EmailOrUsernameModelBackend',)
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
BASE_PATH = os.path.dirname(__file__)
|
||||
CSRF_COOKIE_SECURE = False
|
||||
DATABASES = { 'default': dj_database_url.config() }
|
||||
DEBUG = True
|
||||
DEBUG = os.environ['DEBUG']
|
||||
DEFAULT_FROM_EMAIL = 'nick@snipt.net'
|
||||
EMAIL_BACKEND = 'postmark.django_backend.EmailBackend'
|
||||
HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine', }, }
|
||||
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
|
||||
INTERCOM_SECRET_KEY = os.environ['INTERCOM_SECRET_KEY']
|
||||
INTERNAL_IPS = ('127.0.0.1',)
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
LOGIN_REDIRECT_URL = '/login-redirect/'
|
||||
|
@ -21,11 +25,15 @@ MANAGERS = ADMINS
|
|||
MEDIA_ROOT = os.path.join(BASE_PATH, 'media/uploads')
|
||||
MEDIA_URL = '/media/uploads/'
|
||||
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
|
||||
POSTMARK_API_KEY = os.environ['POSTMARK_API_KEY']
|
||||
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||
RAVEN_CONFIG = { 'dsn': os.environ['RAVEN_CONFIG_DSN'] }
|
||||
ROOT_URLCONF = 'urls'
|
||||
SECRET_KEY = 'changethis'
|
||||
SECRET_KEY = os.environ['SECRET_KEY']
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
SERVER_EMAIL = 'nick@snipt.net'
|
||||
SESSION_COOKIE_AGE = 15801100
|
||||
SESSION_COOKIE_SECURE = False
|
||||
SITE_ID = 1
|
||||
STATICFILES_DIRS = (os.path.join(BASE_PATH, 'media'),)
|
||||
STATICFILES_FINDERS = ('django.contrib.staticfiles.finders.FileSystemFinder','django.contrib.staticfiles.finders.AppDirectoriesFinder',)
|
||||
|
@ -33,13 +41,16 @@ STATIC_ROOT = os.path.join(BASE_PATH, 'static')
|
|||
STATIC_URL = '/static/'
|
||||
TASTYPIE_CANNED_ERROR = "There was an error with your request. The site developers have a record of this error, please email api@snipt.net and we'll help you out."
|
||||
TEMPLATE_DIRS = (os.path.join(PROJECT_PATH, 'templates'))
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
TIME_ZONE = 'America/New_York'
|
||||
USE_HTTPS = False
|
||||
USE_I18N = True
|
||||
USE_L10N = True
|
||||
USE_TZ = True
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'gunicorn',
|
||||
'raven.contrib.django.raven_compat',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.humanize',
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from django import template
|
||||
|
||||
import hmac, hashlib
|
||||
import hmac, hashlib, os
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def intercom_sha_256(user_id):
|
||||
return hmac.new(INTERCOM_SECRET_KEY, str(user_id), digestmod=hashlib.sha256).hexdigest()
|
||||
return hmac.new(os.environ['INTERCOM_SECRET_KEY'], str(user_id), digestmod=hashlib.sha256).hexdigest()
|
||||
|
|
Loading…
Reference in New Issue