Skip to content
This repository has been archived by the owner on Oct 22, 2022. It is now read-only.

Commit

Permalink
Update packages, accounts app and settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mazdakb committed Apr 19, 2019
1 parent 591c52f commit c096fbb
Show file tree
Hide file tree
Showing 42 changed files with 570 additions and 320 deletions.
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ Answer the prompts with your own desired options_. For example::
Select cloud_provider:
1 - AWS
2 - GCS
3 - Minio
Choose from 1, 2 [1]: 1
Select open_source_license:
1 - MIT
Expand Down
3 changes: 1 addition & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
],
"cloud_provider": [
"AWS",
"GCE",
"Minio"
"GCE"
],
"use_celery": "y",
"use_mailhog": "n",
Expand Down
2 changes: 0 additions & 2 deletions docs/project-generation-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ cloud_provider:

1. AWS_
2. GCS_
2. Minio_

use_celery:
Indicates whether the project should be configured to use Celery_.
Expand Down Expand Up @@ -113,7 +112,6 @@ debug:

.. _AWS: https://aws.amazon.com/s3/
.. _GCS: https://cloud.google.com/storage/
.. _Minio: https://min.io/

.. _Celery: https://github.com/celery/celery

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cookiecutter_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RE_OBJ = re.compile(PATTERN)

YN_CHOICES = ["y", "n"]
CLOUD_CHOICES = ["AWS", "GCE", "Minio"]
CLOUD_CHOICES = ["AWS", "GCE"]


@pytest.fixture
Expand Down
4 changes: 0 additions & 4 deletions {{cookiecutter.project_slug}}/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,3 @@ trim_trailing_whitespace = false

[Makefile]
indent_style = tab

[nginx.conf]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions {{cookiecutter.project_slug}}/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ tags
[Ss]cripts
pyvenv.cfg
pip-selfcheck.json
.env
{% endif %}

### Project template
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[MASTER]
load-plugins=pylint_common, pylint_django{% if cookiecutter.use_celery == "y" %}, pylint_celery {% endif %}
load-plugins=pylint_django{% if cookiecutter.use_celery == "y" %}, pylint_celery {% endif %}

[FORMAT]
max-line-length=120
Expand Down
6 changes: 5 additions & 1 deletion {{cookiecutter.project_slug}}/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ before_install:
- sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm
language: python
python:
- "3.6"
- "3.7"
install:
- pip install -r requirements/local.txt
script:
- "pytest"
3 changes: 2 additions & 1 deletion {{cookiecutter.project_slug}}/Procfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
release: python manage.py migrate
web: gunicorn config.wsgi:application
{% if cookiecutter.use_celery == "y" -%}
worker: celery worker --app={{cookiecutter.project_slug}}.celery --loglevel=info
worker: celery worker --app={{cookiecutter.project_slug}}.taskapp --loglevel=info
{%- endif %}
22 changes: 17 additions & 5 deletions {{cookiecutter.project_slug}}/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ Basic Commands
Setting Up Your Users
^^^^^^^^^^^^^^^^^^^^^

* To create a **normal user account**, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.

* To create an **superuser account**, use this command::

$ python manage.py createsuperuser

For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.

Type checks
^^^^^^^^^^^

Running type checks with mypy:

::

$ mypy {{cookiecutter.project_slug}}

Test coverage
^^^^^^^^^^^^^

Expand All @@ -49,6 +56,7 @@ Running tests with py.test
$ pytest

{% if cookiecutter.use_celery == "y" -%}

Celery
^^^^^^

Expand All @@ -62,9 +70,10 @@ To run a celery worker:
celery -A {{cookiecutter.project_slug}}.celery worker -l info
Please note: For Celery's import magic to work, it is important *where* the celery commands are run. If you are in the same folder with *manage.py*, you should be right.
{%- endif %}

{%- endif %}
{% if cookiecutter.use_mailhog == "y" -%}

Email Server
^^^^^^^^^^^^
{% if cookiecutter.use_docker == 'y' %}
Expand All @@ -89,9 +98,10 @@ To view messages that are sent by your application, open your browser and go to
The email server will exit when you exit the Grunt task on the CLI with Ctrl+C.
{% endif %}
.. _mailhog: https://github.com/mailhog/MailHog
{%- endif %}

{%- endif %}
{% if cookiecutter.use_sentry == "y" -%}

Sentry
^^^^^^

Expand All @@ -107,15 +117,17 @@ Deployment
The following details how to deploy this application.

{% if cookiecutter.use_heroku.lower() == "y" -%}

Heroku
^^^^^^

See detailed `django-naqsh Heroku documentation`_.

.. _`django-naqsh Heroku documentation`: http://django-naqsh.readthedocs.io/en/latest/deployment-on-heroku.html
{%- endif %}

{%- endif %}
{% if cookiecutter.use_docker.lower() == "y" -%}

Docker
^^^^^^

Expand Down
42 changes: 19 additions & 23 deletions {{cookiecutter.project_slug}}/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@

import environ

ROOT_DIR = environ.Path(__file__) - 3 # ({{ cookiecutter.project_slug }}/config/settings/base.py - 3 = {{ cookiecutter.project_slug }}/)
APPS_DIR = ROOT_DIR.path('{{ cookiecutter.project_slug }}')
ROOT_DIR = (
environ.Path(__file__) - 3
) # ({{ cookiecutter.project_slug }}/config/settings/base.py - 3 = {{ cookiecutter.project_slug }}/)
APPS_DIR = ROOT_DIR.path("{{ cookiecutter.project_slug }}")

env = environ.Env()

READ_DOT_ENV_FILE = env.bool('DJANGO_READ_DOT_ENV_FILE', default=False)
READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=False)
if READ_DOT_ENV_FILE:
# OS environment variables take precedence over variables from .env
env.read_env(str(ROOT_DIR.path('.env')))
env.read_env(str(ROOT_DIR.path(".env")))

# GENERAL
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -99,9 +101,7 @@
# MIGRATIONS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#migration-modules
MIGRATION_MODULES = {
'sites': '{{ cookiecutter.project_slug }}.contrib.sites.migrations'
}
MIGRATION_MODULES = {"sites": "{{ cookiecutter.project_slug }}.contrib.sites.migrations"}

# AUTHENTICATION
# ------------------------------------------------------------------------------
Expand All @@ -117,26 +117,20 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
PASSWORD_HASHERS = [
# https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
'django.contrib.auth.hashers.Argon2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
'django.contrib.auth.hashers.BCryptPasswordHasher',
"django.contrib.auth.hashers.Argon2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
"django.contrib.auth.hashers.BCryptPasswordHasher",
]
# https://docs.djangoproject.com/en/dev/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',
"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"},
]

# MIDDLEWARE
Expand Down Expand Up @@ -234,7 +228,9 @@
# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.smtp.EmailBackend')
EMAIL_BACKEND = env(
"DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.smtp.EmailBackend"
)

# ADMIN
# ------------------------------------------------------------------------------
Expand Down
56 changes: 26 additions & 30 deletions {{cookiecutter.project_slug}}/config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = env.bool('DJANGO_DEBUG', default=True)
DEBUG = True
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = env('DJANGO_SECRET_KEY', default='!!!SET DJANGO_SECRET_KEY!!!')
SECRET_KEY = env(
"DJANGO_SECRET_KEY",
default="!!!SET DJANGO_SECRET_KEY!!!",
)
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
"localhost",
"0.0.0.0",
"127.0.0.1",
]
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"]

# CACHES
# ------------------------------------------------------------------------------
Expand All @@ -24,64 +23,61 @@
}
}

# TEMPLATES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG # noqa F405

# EMAIL
# ------------------------------------------------------------------------------
{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' -%}
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
EMAIL_HOST = env('EMAIL_HOST', default='mailhog')
EMAIL_HOST = env("EMAIL_HOST", default="mailhog")
{%- elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' -%}
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
EMAIL_HOST = 'localhost'
EMAIL_HOST = "localhost"
{%- else -%}
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.console.EmailBackend')
EMAIL_BACKEND = env(
"DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend"
)
# https://docs.djangoproject.com/en/dev/ref/settings/#email-host
EMAIL_HOST = 'localhost'
EMAIL_HOST = "localhost"
{%- endif %}

# https://docs.djangoproject.com/en/dev/ref/settings/#email-port
EMAIL_PORT = 1025

# django-debug-toolbar
# ------------------------------------------------------------------------------
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#prerequisites
INSTALLED_APPS += ['debug_toolbar'] # noqa F405
INSTALLED_APPS += ["debug_toolbar"] # noqa F405
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#middleware
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware'] # noqa F405
MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"] # noqa F405
# https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-config
DEBUG_TOOLBAR_CONFIG = {
'DISABLE_PANELS': [
'debug_toolbar.panels.redirects.RedirectsPanel',
],
'SHOW_TEMPLATE_CONTEXT': True,
"DISABLE_PANELS": ["debug_toolbar.panels.redirects.RedirectsPanel"],
"SHOW_TEMPLATE_CONTEXT": True,
}
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2']

INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"]
{% if cookiecutter.use_docker == 'y' -%}
if env('USE_DOCKER') == 'yes':
import socket # noqa F405
if env("USE_DOCKER") == "yes":
import socket

hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS += [ip[:-1] + '1' for ip in ips]
INTERNAL_IPS += [ip[:-1] + "1" for ip in ips]
{%- endif %}

# django-extensions
# ------------------------------------------------------------------------------
# https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration
INSTALLED_APPS += ['django_extensions'] # noqa F405

INSTALLED_APPS += ["django_extensions"] # noqa F405
{% if cookiecutter.use_celery == 'y' -%}

# Celery
# ------------------------------------------------------------------------------
{% if cookiecutter.use_docker == 'n' -%}
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-always-eager
CELERY_TASK_ALWAYS_EAGER = True
{%- endif %}
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-eager-propagates
CELERY_TASK_EAGER_PROPAGATES = True

{%- endif %}

# TODO: custom local settings

0 comments on commit c096fbb

Please sign in to comment.