commit 6f5167c24f073957650a8f61b60e87742a371ebe Author: wsvincent Date: Thu Feb 15 12:28:05 2018 -0500 initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..08307e0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +djangox: Copyright (c) 2018 William Vincent +django-allauth: Copyright (c) 2010 Raymond Penners and contributors +cookie-cutter-django: Copyright (c) 2013-2018 Daniel Greenfeld + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..684da9d --- /dev/null +++ b/Pipfile @@ -0,0 +1,16 @@ +[[source]] + +url = "https://pypi.python.org/simple" +verify_ssl = true +name = "pypi" + + +[packages] + +django = "*" +django-allauth = "*" +django-crispy-forms = "*" + + +[dev-packages] + diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..7301037 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,128 @@ +{ + "_meta": { + "hash": { + "sha256": "6d92f3e54c0f137198dc7ff38d1703a2c25f77a1870919b2cd22333a8fe35d51" + }, + "host-environment-markers": { + "implementation_name": "cpython", + "implementation_version": "3.6.4", + "os_name": "posix", + "platform_machine": "x86_64", + "platform_python_implementation": "CPython", + "platform_release": "17.4.0", + "platform_system": "Darwin", + "platform_version": "Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64", + "python_full_version": "3.6.4", + "python_version": "3.6", + "sys_platform": "darwin" + }, + "pipfile-spec": 6, + "requires": {}, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.python.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "certifi": { + "hashes": [ + "sha256:14131608ad2fd56836d33a71ee60fa1c82bc9d2c8d98b7bdbc631fe1b3cd1296", + "sha256:edbc3f203427eef571f79a7692bb160a2b0f7ccaa31953e99bd17e307cf63f7d" + ], + "version": "==2018.1.18" + }, + "chardet": { + "hashes": [ + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691", + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae" + ], + "version": "==3.0.4" + }, + "defusedxml": { + "hashes": [ + "sha256:702a91ade2968a82beb0db1e0766a6a273f33d4616a6ce8cde475d8e09853b20", + "sha256:24d7f2f94f7f3cb6061acb215685e5125fbcdc40a857eff9de22518820b0a4f4" + ], + "version": "==0.5.0" + }, + "django": { + "hashes": [ + "sha256:7c8ff92285406fb349e765e9ade685eec7271d6f5c3f918e495a74768b765c99", + "sha256:dc3b61d054f1bced64628c62025d480f655303aea9f408e5996c339a543b45f0" + ], + "version": "==2.0.2" + }, + "django-allauth": { + "hashes": [ + "sha256:7b31526cccd1c46f9f09acf0703068e8a9669337d29eb065f7e8143c2d897339" + ], + "version": "==0.35.0" + }, + "django-crispy-forms": { + "hashes": [ + "sha256:d37fe72eb550b41ba651c06293fb861d5a9e6e3ada23304718858cd6250d258d", + "sha256:b29a9a671194e3a482891f319f69da81e30ae81c075f6e37adb14a83ba2c409b" + ], + "version": "==1.7.0" + }, + "idna": { + "hashes": [ + "sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4", + "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f" + ], + "version": "==2.6" + }, + "oauthlib": { + "hashes": [ + "sha256:ce57b501e906ff4f614e71c36a3ab9eacbb96d35c24d1970d2539bbc3ec70ce1" + ], + "version": "==2.0.6" + }, + "python3-openid": { + "hashes": [ + "sha256:0086da6b6ef3161cfe50fb1ee5cceaf2cda1700019fda03c2c5c440ca6abe4fa", + "sha256:628d365d687e12da12d02c6691170f4451db28d6d68d050007e4a40065868502" + ], + "version": "==3.1.0" + }, + "pytz": { + "hashes": [ + "sha256:ed6509d9af298b7995d69a440e2822288f2eca1681b8cce37673dbb10091e5fe", + "sha256:f93ddcdd6342f94cea379c73cddb5724e0d6d0a1c91c9bdef364dc0368ba4fda", + "sha256:61242a9abc626379574a166dc0e96a66cd7c3b27fc10868003fa210be4bff1c9", + "sha256:ba18e6a243b3625513d85239b3e49055a2f0318466e0b8a92b8fb8ca7ccdf55f", + "sha256:07edfc3d4d2705a20a6e99d97f0c4b61c800b8232dc1c04d87e8554f130148dd", + "sha256:3a47ff71597f821cd84a162e71593004286e5be07a340fd462f0d33a760782b5", + "sha256:5bd55c744e6feaa4d599a6cbd8228b4f8f9ba96de2c38d56f08e534b3c9edf0d", + "sha256:887ab5e5b32e4d0c86efddd3d055c1f363cbaa583beb8da5e22d2fa2f64d51ef", + "sha256:410bcd1d6409026fbaa65d9ed33bf6dd8b1e94a499e32168acfc7b332e4095c0" + ], + "version": "==2018.3" + }, + "requests": { + "hashes": [ + "sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b", + "sha256:9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e" + ], + "version": "==2.18.4" + }, + "requests-oauthlib": { + "hashes": [ + "sha256:50a8ae2ce8273e384895972b56193c7409601a66d4975774c60c2aed869639ca", + "sha256:883ac416757eada6d3d07054ec7092ac21c7f35cb1d2cf82faf205637081f468" + ], + "version": "==0.8.0" + }, + "urllib3": { + "hashes": [ + "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b", + "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f" + ], + "version": "==1.22" + } + }, + "develop": {} +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..e37155c --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +# DjangoX + +**DjangoX** - A framework for launching new Django projects quickly. + +Comes with a custom user model, social authentication, and email/password for sign up and log in. + +![Falconx](static/images/falconx.png) + +## Features + +* Django 2.0 and Python 3.6 +* [Pipenv](https://github.com/pypa/pipenv) for virtualenvs +* User registration via [django-allauth](https://github.com/pennersr/django-allauth) +* Add social auth via Google, Facebook, etc +* [Bootstrap v4](https://getbootstrap.com/) +* Custom user model with email and no username + +## First-time setup + +1. Make sure Python 3.6x and Pipenv are already installed. [See here for help](https://djangoforbeginners.com/initial-setup/). +2. Install packages with `pipenv install` +3. Activate a virtual environment with `pipenv shell` +4. Set up the initial migration for our custom user models in `users` + + $ python manage.py makemigrations users + +5. Build the database schema: + + $ python manage.py migrate + +6. Create a superuser: + + $ python manage.py createsuperuser + +7. Confirm everything is working: + + $ python manage.py runserver + + Load the site at [http://127.0.0.1:8000](http://127.0.0.1:8000). + + Click on links for "Sign up" or "Log in." + +8. This is optional but I also recommend logging into admin and changing the default site: + + Go to [http://127.0.0.1:8000/admin]([http://127.0.0.1:8000/admin]). You may need to logout and then login with your superuser account. + + Navigate to [http://127.0.0.1:8000/admin/sites/site/](http://127.0.0.1:8000/admin/sites/site/) and change the default "example.com" to "127.0.0.1" and the name to "" for local development. + +## Recommendations + +* Use [PostgreSQL locally via Docker](https://wsvincent.com/django-docker-postgresql/) +* Use [django-environ](https://github.com/joke2k/django-environ) for environment variables +* Update [EMAIL_BACKEND](https://docs.djangoproject.com/en/2.0/topics/email/#module-django.core.mail) to [configure an SMTP backend](https://djangoforbeginners.com/password-change-reset/) +* Add [django-debug-toolbar](https://github.com/jazzband/django-debug-toolbar) and [django-extensions](https://github.com/django-extensions/django-extensions) + +* Make the [admin more secure](https://opensource.com/article/18/1/10-tips-making-django-admin-more-secure) + +## Adding Social Authentication + +* [Configuring Google](https://wsvincent.com/django-allauth-tutorial-custom-user-model/#google-credentials) +* [Configuring Facebook](http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/#Create_and_configure_a_Facebook_app) +* [Configuring Github](https://wsvincent.com/django-allauth-tutorial/) +* `django-allauth` supports [many, many other providers in the official docs](https://django-allauth.readthedocs.io/en/latest/providers.html) + +## Acknowledgments + +This project is heavily inspired by [cookiecutter-django](https://github.com/pydanny/cookiecutter-django). It's my own preferred template for starting new projects built out of a personal desire to actually understand all the config magic in `cookiecutter-django`. diff --git a/djangox/__init__.py b/djangox/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/djangox/settings.py b/djangox/settings.py new file mode 100644 index 0000000..ca31718 --- /dev/null +++ b/djangox/settings.py @@ -0,0 +1,145 @@ +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '4(j*7q=-dm@4&d8hb)-ivy#b(&_3ew19ujzo#h_hq-39!6-5d+' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django.contrib.sites', + + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + # 'allauth.socialaccount.providers.google', + 'crispy_forms', + + 'users', + 'pages', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'djangox.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'djangox.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.0/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/2.0/howto/static-files/ + +STATIC_URL = '/static/' +STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] + +# Bootstrap Crispy-Forms config +CRISPY_TEMPLATE_PACK = 'bootstrap4' + +# Authentication settings +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +AUTHENTICATION_BACKENDS = ( + "django.contrib.auth.backends.ModelBackend", + "allauth.account.auth_backends.AuthenticationBackend", +) + +AUTH_USER_MODEL = 'users.CustomUser' +SITE_ID = 1 +LOGIN_REDIRECT_URL = 'home' +ACCOUNT_LOGOUT_REDIRECT_URL = 'home' +ACCOUNT_AUTHENTICATION_METHOD = 'email' +ACCOUNT_USERNAME_REQUIRED = False +ACCOUNT_EMAIL_REQUIRED = True +ACCOUNT_USERNAME_MIN_LENGTH = 3 +ACCOUNT_EMAIL_VERIFICATION = 'optional' # set this to 'mandatory'? +ACCOUNT_UNIQUE_EMAIL = True +# ACCOUNT_USER_MODEL_EMAIL_FIELD = 'email' +ACCOUNT_LOGOUT_ON_PASSWORD_CHANGE = True +ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = False +ACCOUNT_SESSION_REMEMBER = True diff --git a/djangox/urls.py b/djangox/urls.py new file mode 100644 index 0000000..755dc21 --- /dev/null +++ b/djangox/urls.py @@ -0,0 +1,13 @@ +from django.contrib import admin +from django.urls import include, path + +urlpatterns = [ + path('', include('pages.urls')), + + # Django Admin + path('admin/', admin.site.urls), + + # User management + path('users/', include('users.urls')), + path('accounts/', include('allauth.urls')), # new +] \ No newline at end of file diff --git a/djangox/wsgi.py b/djangox/wsgi.py new file mode 100644 index 0000000..e6aa2b3 --- /dev/null +++ b/djangox/wsgi.py @@ -0,0 +1,7 @@ +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangox.settings") + +application = get_wsgi_application() diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..cac2990 --- /dev/null +++ b/manage.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangox.settings") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) diff --git a/notes.md b/notes.md new file mode 100644 index 0000000..d2e2212 --- /dev/null +++ b/notes.md @@ -0,0 +1,6 @@ +- tut on custom/auth... + +- add about page... +- add base.html with nav, update other templates +- add 404, 403, 500 pages +- customize password reset... \ No newline at end of file diff --git a/pages/__init__.py b/pages/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pages/admin.py b/pages/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/pages/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/pages/apps.py b/pages/apps.py new file mode 100644 index 0000000..acdb960 --- /dev/null +++ b/pages/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class PagesConfig(AppConfig): + name = 'pages' diff --git a/pages/migrations/__init__.py b/pages/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pages/models.py b/pages/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/pages/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/pages/tests.py b/pages/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/pages/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/pages/urls.py b/pages/urls.py new file mode 100644 index 0000000..403ff04 --- /dev/null +++ b/pages/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.HomePageView.as_view(), name='home'), + path('about/', views.AboutPageView.as_view(), name='about'), +] diff --git a/pages/views.py b/pages/views.py new file mode 100644 index 0000000..52d79a3 --- /dev/null +++ b/pages/views.py @@ -0,0 +1,9 @@ +from django.views.generic import TemplateView + + +class HomePageView(TemplateView): + template_name = 'pages/home.html' + + +class AboutPageView(TemplateView): + template_name = 'pages/about.html' diff --git a/static/images/falconx.png b/static/images/falconx.png new file mode 100644 index 0000000..b4b5ee4 Binary files /dev/null and b/static/images/falconx.png differ diff --git a/static/images/favicon.ico b/static/images/favicon.ico new file mode 100644 index 0000000..eeebd56 Binary files /dev/null and b/static/images/favicon.ico differ diff --git a/templates/403_csrf.html b/templates/403_csrf.html new file mode 100644 index 0000000..2e2a9a7 --- /dev/null +++ b/templates/403_csrf.html @@ -0,0 +1,8 @@ +{% extends 'base.html' %} + +{% block title %}Forbidden (403){% endblock title %} + +{% block content %} +

Forbidden (403)

+

CSRF verification failed. Request aborted.

+{% endblock content %} \ No newline at end of file diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..6fde634 --- /dev/null +++ b/templates/404.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} + +{% block title %}404 Page not found{% endblock %} + +{% block content %} +

Page not found

+{% endblock content %} \ No newline at end of file diff --git a/templates/500.html b/templates/500.html new file mode 100644 index 0000000..b47dac1 --- /dev/null +++ b/templates/500.html @@ -0,0 +1,8 @@ +{% extends 'base.html' %} + +{% block title %}500 Server Error{% endblock %} + +{% block content %} +

500 Server Error

+

Looks like something went wrong!

+{% endblock content %} \ No newline at end of file diff --git a/templates/account/email/password_reset_key_message.txt b/templates/account/email/password_reset_key_message.txt new file mode 100644 index 0000000..237f1b5 --- /dev/null +++ b/templates/account/email/password_reset_key_message.txt @@ -0,0 +1,14 @@ +{% load i18n %} +{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Hello from {{ site_name }}! + +We've received a request to reset your password. If you didn't make this request, you can safely ignore this email. Otherwise, click the button below to reset your password.{% endblocktrans %} + +{{ password_reset_url }} + +{% if username %}{% blocktrans %}In case you forgot, your username is {{ username }}.{% endblocktrans %} + +{% endif %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you for using {{ site_name }}! +{{ site_domain }}{% endblocktrans %} + + + diff --git a/templates/account/email/password_reset_key_subject.txt b/templates/account/email/password_reset_key_subject.txt new file mode 100644 index 0000000..7e7c104 --- /dev/null +++ b/templates/account/email/password_reset_key_subject.txt @@ -0,0 +1 @@ +Password Reset E-mail \ No newline at end of file diff --git a/templates/account/login.html b/templates/account/login.html new file mode 100644 index 0000000..e50a4f8 --- /dev/null +++ b/templates/account/login.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} +{% load crispy_forms_tags %} + +{% block title %}Log in{% endblock %} + +{% block content %} +

Log in

+
+ {% csrf_token %} + {{ form|crispy }} + +
+Forgot Password? +{% endblock content %} \ No newline at end of file diff --git a/templates/account/password_change.html b/templates/account/password_change.html new file mode 100644 index 0000000..ba2a68c --- /dev/null +++ b/templates/account/password_change.html @@ -0,0 +1,13 @@ +{% extends 'base.html' %} +{% load crispy_forms_tags %} + +{% block title %}Change Password{% endblock %} + +{% block content %} +

Change Password

+
+ {% csrf_token %} + {{ form|crispy }} + +
+{% endblock content %} \ No newline at end of file diff --git a/templates/account/password_reset.html b/templates/account/password_reset.html new file mode 100644 index 0000000..e159f29 --- /dev/null +++ b/templates/account/password_reset.html @@ -0,0 +1,15 @@ +{% extends 'base.html' %} +{% load crispy_forms_tags %} + +{% block title %}Password Reset{% endblock %} + +{% block content %} +

Forgot your password?

+
+ {% csrf_token %} + {{ form|crispy }} + +
+{% endblock content %} + + diff --git a/templates/account/password_reset_done.html b/templates/account/password_reset_done.html new file mode 100644 index 0000000..38cd134 --- /dev/null +++ b/templates/account/password_reset_done.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} +{% load crispy_forms_tags %} + +{% block title %}Password Reset Done{% endblock %} + +{% block content %} +

Password Reset

+

We have sent you an e-mail. Please contact us if you do not receive it in a few minutes.

+{% endblock content %} diff --git a/templates/account/password_reset_from_key.html b/templates/account/password_reset_from_key.html new file mode 100644 index 0000000..c142b19 --- /dev/null +++ b/templates/account/password_reset_from_key.html @@ -0,0 +1,22 @@ +{% extends 'base.html' %} +{% load crispy_forms_tags %} + +{% block title %}Change Password{% endblock title %} + +{% block content %} +

{% if token_fail %}Bad Token{% else %}Change Password{% endif %}

+ + {% if token_fail %} +

The password reset link was invalid. Perhaps it has already been used? Please request a new password reset.

+ {% else %} + {% if form %} +
+ {% csrf_token %} + {{ form|crispy }} + +
+ {% else %} +

Your password is now changed.

+ {% endif %} + {% endif %} +{% endblock content%} diff --git a/templates/account/password_reset_from_key_done.html b/templates/account/password_reset_from_key_done.html new file mode 100644 index 0000000..4b59c6d --- /dev/null +++ b/templates/account/password_reset_from_key_done.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} +{% load crispy_forms_tags %} + +{% block title %}Change Password Done{% endblock title %} + +{% block content %} +

Password Change Done

+

Your password has been changed.

+{% endblock content %} \ No newline at end of file diff --git a/templates/account/password_set.html b/templates/account/password_set.html new file mode 100644 index 0000000..37f5e86 --- /dev/null +++ b/templates/account/password_set.html @@ -0,0 +1,14 @@ +{% extends 'base.html' %} +{% load crispy_forms_tags %} + +{% block title %}Set Password{% endblock title %} + +{% block content %} +
+ {% csrf_token %} + {% bootstrap_form password_set_form %} +
+ +
+
+{% endblock content %} diff --git a/templates/account/signup.html b/templates/account/signup.html new file mode 100644 index 0000000..c98bbb3 --- /dev/null +++ b/templates/account/signup.html @@ -0,0 +1,13 @@ +{% extends 'base.html' %} +{% load crispy_forms_tags %} + +{% block title %}Sign up{% endblock %} + +{% block content %} +

Sign up

+
+ {% csrf_token %} + {{ form|crispy }} + +
+{% endblock content %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..1440d9e --- /dev/null +++ b/templates/base.html @@ -0,0 +1,76 @@ +{% load static %} +{% load socialaccount %} + + + + + + +{% block title %}DjangoX{% endblock title %} + + + + +{% block css %} + + + + +{% endblock %} + + + + + + + +
+ {% block content %} +

Default content...

+ {% endblock content %} +
+ + + + + {% block javascript %} + + + + + + + + + + + {% endblock javascript %} + + + \ No newline at end of file diff --git a/templates/pages/about.html b/templates/pages/about.html new file mode 100644 index 0000000..90282c2 --- /dev/null +++ b/templates/pages/about.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} + +{% block title %}About page{% endblock %} + +{% block content %} +

About page

+{% endblock content %} \ No newline at end of file diff --git a/templates/pages/home.html b/templates/pages/home.html new file mode 100644 index 0000000..e5f32ae --- /dev/null +++ b/templates/pages/home.html @@ -0,0 +1,10 @@ +{% extends 'base.html' %} +{% load static %} + +{% block title %}Home page{% endblock title %} + +{% block content %} +

Home page

+FalconX launch +{% endblock content %} + diff --git a/templates/registration/login.html b/templates/registration/login.html new file mode 100644 index 0000000..91099ac --- /dev/null +++ b/templates/registration/login.html @@ -0,0 +1,6 @@ +

Login

+
+ {% csrf_token %} + {{ form.as_p }} + +
\ No newline at end of file diff --git a/users/__init__.py b/users/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/users/admin.py b/users/admin.py new file mode 100644 index 0000000..09c7b04 --- /dev/null +++ b/users/admin.py @@ -0,0 +1,15 @@ +from django.contrib import admin +from django.contrib.auth import get_user_model +from django.contrib.auth.admin import UserAdmin + +from .forms import CustomUserCreationForm, CustomUserChangeForm +from .models import CustomUser + + +class CustomUserAdmin(UserAdmin): + model = CustomUser + add_form = CustomUserCreationForm + form = CustomUserChangeForm + + +admin.site.register(CustomUser, CustomUserAdmin) diff --git a/users/apps.py b/users/apps.py new file mode 100644 index 0000000..4ce1fab --- /dev/null +++ b/users/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UsersConfig(AppConfig): + name = 'users' diff --git a/users/forms.py b/users/forms.py new file mode 100644 index 0000000..2973807 --- /dev/null +++ b/users/forms.py @@ -0,0 +1,17 @@ +from django import forms +from django.contrib.auth.forms import UserCreationForm, UserChangeForm +from .models import CustomUser + + +class CustomUserCreationForm(UserCreationForm): + + class Meta(UserCreationForm.Meta): + model = CustomUser + fields = ('username', 'email') + + +class CustomUserChangeForm(UserChangeForm): + + class Meta: + model = CustomUser + fields = UserChangeForm.Meta.fields diff --git a/users/models.py b/users/models.py new file mode 100644 index 0000000..8b840a8 --- /dev/null +++ b/users/models.py @@ -0,0 +1,9 @@ +from django.contrib.auth.models import AbstractUser, UserManager + + +class CustomUserManager(UserManager): + pass + + +class CustomUser(AbstractUser): + objects = CustomUserManager() diff --git a/users/tests.py b/users/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/users/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/users/urls.py b/users/urls.py new file mode 100644 index 0000000..5d4b73f --- /dev/null +++ b/users/urls.py @@ -0,0 +1,6 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('signup/', views.SignUp.as_view(), name='signup'), +] \ No newline at end of file diff --git a/users/views.py b/users/views.py new file mode 100644 index 0000000..870b748 --- /dev/null +++ b/users/views.py @@ -0,0 +1,10 @@ +from django.urls import reverse_lazy +from django.views import generic + +from .forms import CustomUserCreationForm + + +class SignUp(generic.CreateView): + form_class = CustomUserCreationForm + success_url = reverse_lazy('login') + template_name = 'account/signup.html'