Cookiecutter option to create domain app

The option allows the user to utilize Domain-Driven Design (DDD): If confirmed, a `domain` package will be created in apps dir, and referenced in `./config/settings/base.py`.
This commit is contained in:
Nikita P. Shupeyko 2017-03-20 19:02:47 +03:00
parent f3ea2570ab
commit d9e5295eab
7 changed files with 29 additions and 1 deletions

View File

@ -9,6 +9,7 @@
"timezone": "UTC",
"use_whitenoise": "y",
"use_celery": "n",
"use_domain_driven_design": "n",
"use_mailhog": "n",
"use_sentry_for_error_reporting": "y",
"use_opbeat": "n",

View File

@ -202,6 +202,15 @@ def remove_elasticbeanstalk():
PROJECT_DIRECTORY, filename
))
def remove_domain_app(project_directory):
"""Removes the domain app if Domain-Driven Design (DDD) isn't going to be used."""
# Determine the local_setting_file_location
domain_app_location = os.path.join(
PROJECT_DIRECTORY,
'{{ cookiecutter.project_slug }}/domain'
)
shutil.rmtree(domain_app_location)
# IN PROGRESS
# def copy_doc_files(project_directory):
# cookiecutters_dir = DEFAULT_CONFIG['cookiecutters_dir']
@ -284,3 +293,7 @@ if '{{ cookiecutter.open_source_license}}' != 'GPLv3':
# 12. Remove Elastic Beanstalk files
if '{{ cookiecutter.use_elasticbeanstalk_experimental }}'.lower() != 'y':
remove_elasticbeanstalk()
# 13. Removes the domain app if Domain-Driven Design (DDD) isn't going to be used.
if '{{ cookiecutter.use_domain_driven_design }}'.lower() == 'n':
remove_domain_app(PROJECT_DIRECTORY)

View File

@ -57,7 +57,8 @@ THIRD_PARTY_APPS = [
# Apps specific for this project go here.
LOCAL_APPS = [
# custom users app
'{{ cookiecutter.project_slug }}.users.apps.UsersConfig',
'{{ cookiecutter.project_slug }}.users.apps.UsersConfig',{% if cookiecutter.use_domain_driven_design == 'y' %}
'{{ cookiecutter.project_slug }}.domain.apps.DomainConfig',{% endif %}
# Your stuff: custom apps go here
]

View File

@ -0,0 +1,13 @@
from django.apps import AppConfig
class DomainConfig(AppConfig):
name = '{{cookiecutter.project_slug}}.domain'
verbose_name = "Domain"
def ready(self):
"""Override this to put in:
Users system checks
Users signal registration
"""
pass