From ffe433e734d085266a5bdd6ab098b6ec1d312044 Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Fri, 4 Nov 2016 11:46:50 -0400 Subject: [PATCH] Remove requirement on Postmark for basic installs. --- README.md | 27 +++++++-------------------- forms.py | 6 ------ settings.py | 2 +- urls.py | 34 ++++++++-------------------------- utils/views.py | 4 ++-- 5 files changed, 18 insertions(+), 55 deletions(-) delete mode 100644 forms.py diff --git a/README.md b/README.md index 3dc74c0..521902d 100644 --- a/README.md +++ b/README.md @@ -6,32 +6,13 @@ You can click the button below to automatically deploy Snipt to Heroku. [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/nicksergeant/snipt/tree/heroku) -**Please note:** this method will work fine, but you will not have email support -unless you manually configure Postmark. You don't necessarily need this, -though. After deploying the instance, visit -`https:///signup`, and create a user. You will get a 500 -Server Error, which is the site trying to send a welcome email. Ignore the -error and go to `/login`, and log in with the -username and password you provided. Snipt will work fine, but you will not -receive any emails if there are server errors. - -If you would like to configure your instance to use a free Postmark addon, do -the following after deploying (you'll need the -[Heroku CLI](https://devcenter.heroku.com/articles/heroku-command-line)): - -- `heroku run -a addons:open postmark` -> use an email you control and confirm it -- `heroku config:add -a POSTMARK_EMAIL=` - ## Manual deploy to Heroku - Clone the repo. - `heroku create` - `heroku addons:add heroku-postgresql:hobby-dev` - `heroku addons:add searchbox` -- `heroku addons:create postmark:10k` -- `heroku addons:open postmark` -> use an email you control and confirm it -- `heroku config:add POSTMARK_EMAIL=` -- `heroku config:add SECRET_KEY=` +- `heroku config:add SECRET_KEY=` - `git push heroku` - `heroku run python manage.py migrate` - `heroku run python manage.py createsuperuser` @@ -47,6 +28,12 @@ the following after deploying (you'll need the ## Options +If you want email support (for password resets, server errors, etc): + +- `heroku addons:create postmark:10k` +- `heroku run addons:open postmark` -> use an email you control and confirm it +- `heroku config:add POSTMARK_EMAIL=` + If you want to disable user-facing signup: - `heroku config:set DISABLE_SIGNUP=true` diff --git a/forms.py b/forms.py deleted file mode 100644 index b33d28d..0000000 --- a/forms.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.contrib.auth.forms import AuthenticationForm - - -class AuthenticationFormWithInactiveUsersOkay(AuthenticationForm): - def confirm_login_allowed(self, user): - pass diff --git a/settings.py b/settings.py index 3396b48..66c753a 100644 --- a/settings.py +++ b/settings.py @@ -42,7 +42,7 @@ if 'HAYSTACK_URL' in os.environ: ABSOLUTE_URL_OVERRIDES = {'auth.user': lambda u: "/%s/" % u.username} -ACCOUNT_ACTIVATION_DAYS = 14 +ACCOUNT_ACTIVATION_DAYS = 0 ADMINS = (('Nick Sergeant', 'nick@snipt.net'),) ALLOWED_HOSTS = ['*'] AUTH_PROFILE_MODULE = 'accounts.UserProfile' diff --git a/urls.py b/urls.py index 095d3a6..b47488c 100644 --- a/urls.py +++ b/urls.py @@ -6,7 +6,6 @@ from django.contrib.auth.views import login from django.http import HttpResponseRedirect from django.views.generic import RedirectView, TemplateView from django.views.static import serve -from forms import AuthenticationFormWithInactiveUsersOkay from snipts.api import (PublicSniptResource, PublicUserResource, PrivateSniptResource, PrivateFavoriteResource, PrivateUserProfileResource, @@ -33,49 +32,32 @@ urlpatterns = [] if os.environ.get("DISABLE_SIGNUP") != "true": urlpatterns += [ url(r'^register/$', lambda x: HttpResponseRedirect('/signup/')), - url(r'^signup/$', SniptRegistrationView.as_view(), - name='registration_register'), + url(r'^signup/$', SniptRegistrationView.as_view(), name='registration_register'), + url(r'', include('registration.backends.simple.urls')), ] urlpatterns += [ url(r'^$', homepage), url(r'^login-redirect/$', login_redirect), - url(r'^admin/', include(admin.site.urls)), - url(r'^404/$', TemplateView.as_view(template_name='404.html')), url(r'^500/$', TemplateView.as_view(template_name='500.html')), - - url(r'^robots.txt$', - TemplateView.as_view(template_name='robots.txt')), + url(r'^robots.txt$', TemplateView.as_view(template_name='robots.txt')), url(r'^tags/$', tags), - url(r'^account/', include('accounts.urls')), - url(r'^api/public/lexer/$', lexers), - url(r'^api/private/key/$', user_api_key), url(r'^api/', include(public_api.urls)), url(r'^api/', include(private_api.urls)), - url(r'^search/$', search), - - url(r'^activate/complete/$', RedirectView.as_view( - url='/login-redirect/')), - url(r'^login/?$', login, { - 'authentication_form': AuthenticationFormWithInactiveUsersOkay - }, name='login'), - url(r'', include('registration.backends.default.urls')), - + url(r'^activate/complete/$', RedirectView.as_view( url='/login-redirect/')), + url(r'^login/?$', login, name='login'), url(r'^', include('teams.urls')), url(r'^', include('snipts.urls')), - url(r'^(?Pfavicon\.ico)$', serve, { - 'document_root': os.path.join(os.path.dirname(__file__), - 'static/img') - }), + 'document_root': os.path.join(os.path.dirname(__file__), 'static/img') + }), url(r'^static/(?P.*)$', serve, { - 'document_root': os.path.join(os.path.dirname(__file__), - 'media') + 'document_root': os.path.join(os.path.dirname(__file__), 'media') }) ] diff --git a/utils/views.py b/utils/views.py index 4cf5335..d116f01 100644 --- a/utils/views.py +++ b/utils/views.py @@ -1,4 +1,4 @@ -from registration.backends.default.views import RegistrationView +from registration.backends.simple.views import RegistrationView from utils.forms import SniptRegistrationForm @@ -12,4 +12,4 @@ class SniptRegistrationView(RegistrationView): return super(RegistrationView, self).dispatch(request, *args, **kwargs) def get_success_url(self, request): - return '/account/activate/' + return '/login-redirect'