From fc36c300b1c7ed42227bd37bba7977f79f701b38 Mon Sep 17 00:00:00 2001 From: Jodything Date: Thu, 11 Sep 2014 14:01:30 -0400 Subject: [PATCH 1/3] adding twilio keys in .env file. --- main/templates/index.html | 4 ++-- pushups/settings.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/main/templates/index.html b/main/templates/index.html index 5b5952b..229dc03 100644 --- a/main/templates/index.html +++ b/main/templates/index.html @@ -20,7 +20,7 @@
- +

because sitting is the new smoking

@@ -49,7 +49,7 @@

See!
We know.
We know how you are.
Ya lazy bum!

Sarge is here to get that shit in order.
Press start to get in the game.

- +
diff --git a/pushups/settings.py b/pushups/settings.py index 34a2a7c..2c05b72 100644 --- a/pushups/settings.py +++ b/pushups/settings.py @@ -19,8 +19,6 @@ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '#-2+byiet=(7dd^k%*8=q%v^h^q)2ac+$)6i#@imx87vvxgxoo' -TWILIO_ACCOUNT_SID='AC1228449546e2367b274cc342487419dc' -TWILIO_AUTH_TOKEN='b34cee3d99af7233b9e81dd885ad1e57' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -106,9 +104,18 @@ STATICFILES_DIRS = [os.path.join(PROJECT_PATH, 'static')] #AUTH_PROFILE_MODULE = 'userprofile.UserProfile' +#email verif. stuff ACCOUNT_ACTIVATION_DAYS = 7 REGISTRATION_EMAIL_SUBJECT_PREFIX = '[Pushups App Registration]' SEND_ACTIVATION_EMAIL = True REGISTRATION_AUTO_LOGIN = False +EMAIL_HOST = 'localhost' +EMAIL_PORT = 1025 +EMAIL_HOST_USER = '' +EMAIL_HOST_PASSWORD = '' +EMAIL_USE_TLS = False +DEFAULT_FROM_EMAIL = 'SGT@pushups.com' + + EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' From 53547801b0f94285a5175daec5c07dc6971c3050 Mon Sep 17 00:00:00 2001 From: Jodything Date: Fri, 12 Sep 2014 08:44:27 -0400 Subject: [PATCH 2/3] clean up. deleted userprofile app --- main/forms.py | 19 ------- main/templates/profile.html | 2 +- main/views.py | 54 +------------------ pushups/settings.py | 11 +--- pushups/views.py | 37 ------------- registration/models.py | 2 +- .../registration/activation_email.html | 4 +- userprofile/__init__.py | 0 userprofile/admin.py | 3 -- userprofile/forms.py | 8 --- userprofile/migrations/0001_initial.py | 27 ---------- userprofile/migrations/__init__.py | 0 userprofile/models.py | 11 ---- userprofile/templates/profile.html | 18 ------- userprofile/tests.py | 3 -- userprofile/urls.py | 5 -- userprofile/views.py | 24 --------- 17 files changed, 6 insertions(+), 222 deletions(-) delete mode 100644 main/forms.py delete mode 100644 pushups/views.py delete mode 100644 userprofile/__init__.py delete mode 100644 userprofile/admin.py delete mode 100644 userprofile/forms.py delete mode 100644 userprofile/migrations/0001_initial.py delete mode 100644 userprofile/migrations/__init__.py delete mode 100644 userprofile/models.py delete mode 100644 userprofile/templates/profile.html delete mode 100644 userprofile/tests.py delete mode 100644 userprofile/urls.py delete mode 100644 userprofile/views.py diff --git a/main/forms.py b/main/forms.py deleted file mode 100644 index 6c7f0f3..0000000 --- a/main/forms.py +++ /dev/null @@ -1,19 +0,0 @@ -from django import forms -from django.contrib.auth.models import User -from django.contrib.auth.forms import UserCreationForm - -class MyRegistrationForm(UserCreationForm): - email = forms.EmailField(required=True) - - class Meta: - model = User - fields = ('username', 'email', 'password1', 'password2') - - def save(self, commit=True): - user = super(MyRegistrationForm, self).save(commit=False) - user.email = self.cleaned_data['email'] - - if commit: - user.save() - - return user diff --git a/main/templates/profile.html b/main/templates/profile.html index f4f34c9..3d63b89 100644 --- a/main/templates/profile.html +++ b/main/templates/profile.html @@ -3,5 +3,5 @@ {% block title %}Account Profile{% endblock %} -{% block content %} +{% block body %} {% endblock %} diff --git a/main/views.py b/main/views.py index 16bee88..fa29aaa 100644 --- a/main/views.py +++ b/main/views.py @@ -2,60 +2,8 @@ from django.http import HttpResponseRedirect, HttpResponse from django_twilio.decorators import twilio_view from twilio.twiml import Response -from django.contrib import auth -from django.core.context_processors import csrf -from django.contrib.auth.forms import UserCreationForm -# from forms import MyRegistrationForm - -# Create your views here. -def index(request): - return render(request, 'main/index.html') - -#signin/login views - -def login(request): - c = {} - c.update(csrf(request)) - return render_to_response('login.html', c) - -def auth_view(request): - username = request.POST.get('username', '') - password = request.POST.get('password', '') - user = auth.authenticate(username=username, password=password) - - if user is not None: - auth.login(request, user) - return HttpResponseRedirect('/accounts/loggedin') - else: - return HttpResponseRedirect('/accounts/invalid') - -def loggedin(request): - return render_to_response('loggedin.html', {'full_name': request.user.username}) -def invalid_login(request): - return render_to_response('invalid_login.html') - -def logout(request): - auth.logout(request) - return render_to_response('logout.html') - -#user registration -def register_user(request): - if request.method == 'POST': - form = MyRegistrationForm(request.POST) - if form.is_valid(): - form.save() - return HttpResponseRedirect('/accounts/register_success') - - args = {} - args.update(csrf(request)) - - args['form'] = MyRegistrationForm() - print (args) - return render_to_response('register.html', args) - -def register_success(request): - return render_to_response('register_success.html') +# from forms import MyRegistrationForm @twilio_view def sms(request): diff --git a/pushups/settings.py b/pushups/settings.py index 2c05b72..5361cc7 100644 --- a/pushups/settings.py +++ b/pushups/settings.py @@ -18,7 +18,7 @@ # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '#-2+byiet=(7dd^k%*8=q%v^h^q)2ac+$)6i#@imx87vvxgxoo' + # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -42,8 +42,6 @@ 'django.contrib.staticfiles', 'django_twilio', 'main', - 'userprofile', - 'phonenumber_field', 'registration', 'django.contrib.sites', ) @@ -110,12 +108,5 @@ SEND_ACTIVATION_EMAIL = True REGISTRATION_AUTO_LOGIN = False -EMAIL_HOST = 'localhost' -EMAIL_PORT = 1025 -EMAIL_HOST_USER = '' -EMAIL_HOST_PASSWORD = '' -EMAIL_USE_TLS = False -DEFAULT_FROM_EMAIL = 'SGT@pushups.com' - EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff --git a/pushups/views.py b/pushups/views.py deleted file mode 100644 index ca45a3e..0000000 --- a/pushups/views.py +++ /dev/null @@ -1,37 +0,0 @@ -from django.shortcuts import render, HttpResponseRedirect, render_to_response -from django.http import HttpResponseRedirect, HttpResponse - -from django.contrib import auth -from django.core.context_processors import csrf - -def test_index(request): - return render(request, 'test_index.html') - - -#signin/login views - -def login(request): - c = {} - c.update(csrf(request)) - return render_to_response('login.html', c) - -def auth_view(request): - username = request.POST.get('username', '') - password = request.POST.get('password', '') - user = auth.authenticate(username=username, password=password) - - if user is not None: - auth.login(request, user) - return HttpResponseRedirect('/accounts/loggedin') - else: - return HttpResponseRedirect('/accounts/invalid') - -def loggedin(request): - return render_to_response('loggedin.html', {'full_name': request.user.username}) - -def invalid_login(request): - return render_to_response('invalid_login.html') - -def logout(request): - auth.logout(request) - return render_to_response('logout.html') diff --git a/registration/models.py b/registration/models.py index 05aff01..a5d9d9b 100755 --- a/registration/models.py +++ b/registration/models.py @@ -285,4 +285,4 @@ def send_activation_email(self, site): if message_html: email_message.attach_alternative(message_html, 'text/html') - email_message.send() \ No newline at end of file + email_message.send() diff --git a/registration/templates/registration/activation_email.html b/registration/templates/registration/activation_email.html index 8f2fe72..8467319 100755 --- a/registration/templates/registration/activation_email.html +++ b/registration/templates/registration/activation_email.html @@ -23,7 +23,7 @@

- + {{site.domain}}{% url 'registration_activate' activation_key %}

@@ -64,4 +64,4 @@ ``user`` The new user account -{% endcomment %} \ No newline at end of file +{% endcomment %} diff --git a/userprofile/__init__.py b/userprofile/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/userprofile/admin.py b/userprofile/admin.py deleted file mode 100644 index 8c38f3f..0000000 --- a/userprofile/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.contrib import admin - -# Register your models here. diff --git a/userprofile/forms.py b/userprofile/forms.py deleted file mode 100644 index a88a315..0000000 --- a/userprofile/forms.py +++ /dev/null @@ -1,8 +0,0 @@ -from django import forms -from models import UserProfile - -class UserProfileForm(forms.ModelForm): - - class Meta: - model = UserProfile - fields = ('phone_number',) diff --git a/userprofile/migrations/0001_initial.py b/userprofile/migrations/0001_initial.py deleted file mode 100644 index db210d0..0000000 --- a/userprofile/migrations/0001_initial.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models, migrations -from django.conf import settings -import phonenumber_field.modelfields - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='UserProfile', - fields=[ - ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('phone_number', phonenumber_field.modelfields.PhoneNumberField(max_length=128)), - ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)), - ], - options={ - }, - bases=(models.Model,), - ), - ] diff --git a/userprofile/migrations/__init__.py b/userprofile/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/userprofile/models.py b/userprofile/models.py deleted file mode 100644 index fab43ba..0000000 --- a/userprofile/models.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.db import models -from django.contrib.auth.models import User -from phonenumber_field.modelfields import PhoneNumberField - -# Create your models here. - -class UserProfile(models.Model): - user = models.OneToOneField(User) - phone_number = PhoneNumberField(blank=False) - -User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0]) diff --git a/userprofile/templates/profile.html b/userprofile/templates/profile.html deleted file mode 100644 index 5b48e87..0000000 --- a/userprofile/templates/profile.html +++ /dev/null @@ -1,18 +0,0 @@ - -{% block content %} - -

Profile

- - {% for field in form %} - {{field.error}} - - {% endfor %} - -
{% csrf_token %} - {{form.as_ul}} - - - -
- -{% endblock %} diff --git a/userprofile/tests.py b/userprofile/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/userprofile/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/userprofile/urls.py b/userprofile/urls.py deleted file mode 100644 index 2485ef4..0000000 --- a/userprofile/urls.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.conf.urls import patterns, include, url - -urlpatterns = patterns('', - url(r'^profile/$', 'userprofile.views.user_profile'), -) diff --git a/userprofile/views.py b/userprofile/views.py deleted file mode 100644 index f625ad1..0000000 --- a/userprofile/views.py +++ /dev/null @@ -1,24 +0,0 @@ -from django.shortcuts import render_to_response -from django.http import HttpResponseRedirect -from django.core.context_processors import csrf -from forms import UserProfileForm -from django.contrib.auth.decorators import login_required - -@login_required -def user_profile(request): - if request.method == 'POST': - form = UserProfileForm(request.POST, instance=request.user.profile) - if form.is_valid(): - form.save() - return HttpResponseRedirect('/accounts/loggedin') - else: - user = request.user - profile = user.profile - form = UserProfileForm(instance=profile) - - args = {} - args.update(csrf(request)) - - args['form'] = form - - return render_to_response('profile.html', args) From cbbb4797b45819e01be156d27bc38d62fe2eff32 Mon Sep 17 00:00:00 2001 From: Jodything Date: Mon, 15 Sep 2014 13:44:07 -0400 Subject: [PATCH 3/3] registration update --- pushups/settings.py | 10 ++++++++-- pushups/urls.py | 2 +- registration/admin.py | 4 ++-- registration/forms.py | 2 +- .../templates/registration/activation_email.html | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pushups/settings.py b/pushups/settings.py index 5361cc7..072266e 100644 --- a/pushups/settings.py +++ b/pushups/settings.py @@ -18,7 +18,7 @@ # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! - +SECRET_KEY = '#-2+byiet=(7dd^k%*8=q%v^h^q)2ac+$)6i#@imx87vvxgxoo' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -108,5 +108,11 @@ SEND_ACTIVATION_EMAIL = True REGISTRATION_AUTO_LOGIN = False +EMAIL_TLS= True +EMAIL_HOST= 'smtp.mandrillapp.com' +EMAIL_PORT= '587' +EMAIL_HOST_USER= 'jody@waypaver.co' +EMAIL_HOST_PASSWORD= 'W9xSNi9MtAdKCqVeVoku1g' +#SERVER_EMAIL = 'jody@waypaver.co' -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' diff --git a/pushups/urls.py b/pushups/urls.py index 3e1a853..d4976f1 100644 --- a/pushups/urls.py +++ b/pushups/urls.py @@ -11,7 +11,7 @@ url(r'^$',TemplateView.as_view(template_name='index.html'),name='index'), url(r'^accounts/', - include('registration.backends.simple.urls')), + include('registration.backends.default.urls')), url(r'^accounts/profile/', TemplateView.as_view(template_name='profile.html'), diff --git a/registration/admin.py b/registration/admin.py index 6541f6a..13b8040 100755 --- a/registration/admin.py +++ b/registration/admin.py @@ -16,7 +16,7 @@ def activate_users(self, request, queryset): """ Activates the selected users, if they are not alrady activated. - + """ for profile in queryset: RegistrationProfile.objects.activate_user(profile.activation_key) @@ -30,7 +30,7 @@ def resend_activation_email(self, request, queryset): who are eligible to activate; emails will not be sent to users whose activation keys have expired or who have already activated. - + """ if Site._meta.installed: site = Site.objects.get_current() diff --git a/registration/forms.py b/registration/forms.py index 2cddd80..ff8f89d 100755 --- a/registration/forms.py +++ b/registration/forms.py @@ -105,7 +105,7 @@ class RegistrationFormNoFreeEmail(RegistrationForm): override the attribute ``bad_domains``. """ - bad_domains = ['aim.com', 'aol.com', 'email.com', 'gmail.com', + bad_domains = ['aim.com', 'aol.com', 'email.com', 'googlemail.com', 'hotmail.com', 'hushmail.com', 'msn.com', 'mail.ru', 'mailinator.com', 'live.com', 'yahoo.com'] diff --git a/registration/templates/registration/activation_email.html b/registration/templates/registration/activation_email.html index 8467319..6748914 100755 --- a/registration/templates/registration/activation_email.html +++ b/registration/templates/registration/activation_email.html @@ -23,7 +23,7 @@

- + {{site.domain}}{% url 'registration_activate' activation_key %}