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 new file mode 100644 index 0000000..072266e --- /dev/null +++ b/pushups/settings.py @@ -0,0 +1,118 @@ +""" +Django settings for pushups project. + +For more information on this file, see +https://docs.djangoproject.com/en/1.7/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.7/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) +PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) + + +# Quick-start development settings - unsuitable for production +# 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 + +TEMPLATE_DEBUG = True +TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'pushups/templates','django.template.loaders.app_directories.Loader',)] + +ALLOWED_HOSTS = ['*'] + +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + +SITE_ID = 1 +# Application definition + +INSTALLED_APPS = ( + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django_twilio', + 'main', + 'registration', + 'django.contrib.sites', +) + +MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + +ROOT_URLCONF = 'pushups.urls' + +WSGI_APPLICATION = 'pushups.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.7/ref/settings/#databases + + +# DATABASES = { + # 'default': { + # 'ENGINE': 'django.db.backends.sqlite3', + # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + # } +# } + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': 'pushups', # Or path to database file if using sqlite3. + 'HOST': 'localhost', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. + 'PORT': '', # Set to empty string for default. + } +} + +# Internationalization +# https://docs.djangoproject.com/en/1.7/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.7/howto/static-files/ +STATIC_ROOT = 'staticfiles' +STATIC_URL = '/static/' +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_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.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/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/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/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..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 %}

@@ -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)