Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions django_email_foundation/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ class Checks:
FOLDERS = ('pages', 'layouts', 'partials', 'helpers', 'assets', 'data')

CHECKS = (
('npm_or_yarn_installed', 'The "npm" or "yarn" is not installed or is not in your $PATH'),
('npm_or_yarn_installed',
'The "npm" or "yarn" is not installed or is not in your $PATH'),
('required_node_packages', 'Some of the required modules are not installed in "node_modules". Please run '
'"./manage.py install_requires"'),
('templates_source_path', 'It is necessary to define DEF_TEMPLATES_SOURCE_PATH in your settings'),
('templates_source_path',
'It is necessary to define DEF_TEMPLATES_SOURCE_PATH in your settings'),
('templates_dir_structure', 'The templates directory must have a valid structure. It must contain the pages,'
' layouts, partials and helpers folders. You can run '
'"./manage.py create_basic_structure" to build this structure, '
'and to add a basic layout '),
('templates_target_path', 'It is necessary to define DEF_TEMPLATES_TARGET_PATH in your settings'),
('templates_target_path',
'It is necessary to define DEF_TEMPLATES_TARGET_PATH in your settings'),
('static_target_path', 'You must to set the DEF_STATIC_TARGET_PATH setting'),
('exists_pages', 'You do not have any template in your \'pages\' folder. Please, create one before run the '
'email builder command'),
Expand All @@ -38,7 +41,8 @@ def exists_pages(self) -> bool:
return True

try:
walk = os.listdir(os.path.join(self.get_templates_source_path(), 'pages'))
walk = os.listdir(os.path.join(
self.get_templates_source_path(), 'pages'))
except FileNotFoundError:
return False

Expand Down Expand Up @@ -153,7 +157,9 @@ def install_required_packages(self) -> bool:
settings.DEF_NPM_YARN_INSTALL_COMMAND,
] + list(settings.DEF_NODE_PACKAGES_REQUIRED)

exit_code = subprocess.call(command, cwd=settings.DEF_NODE_MODULES_PATH)
exit_code = subprocess.call(command,
cwd=settings.DEF_NODE_MODULES_PATH,
shell=True)

if exit_code != 0:
return False
Expand Down Expand Up @@ -183,19 +189,23 @@ def run_watch(self):
'--ignore_files={}'.format(','.join(settings.DEF_IGNORE_FILES)),
'--preview_url={}'.format(self.preview_url),
)
subprocess.call(command, cwd=settings.DEF_NODE_MODULES_PATH)
# subprocess.call(command, cwd=settings.DEF_NODE_MODULES_PATH)
subprocess.call(command, cwd=settings.DEF_NODE_MODULES_PATH,
shell=True)

def create_basic_structure(self) -> Optional[str]:
"""
It creates the basic foundation for emails (or panini) structure in your source path folder.
:return: If some error occurs, the method return the description.
"""
source_default_templates = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'default_templates')
source_default_templates = os.path.join(os.path.dirname(
os.path.realpath(__file__)), 'default_templates')

for folder in Checks.FOLDERS:

source_path = '{}/{}'.format(source_default_templates, folder)
target_path = '{}/{}'.format(Checks.get_templates_source_path(), folder)
target_path = '{}/{}'.format(
Checks.get_templates_source_path(), folder)

# If the target path already exists, it's not necessary to create it.
if os.path.isdir(target_path):
Expand Down
48 changes: 33 additions & 15 deletions django_email_foundation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,40 @@
DEF_NODE_MODULES_PATH = getattr(settings, 'DEF_NODE_MODULES_PATH', os.getcwd())

# A list with a node modules required packages
# DEF_NODE_PACKAGES_REQUIRED = (
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# '[email protected]',
# )

DEF_NODE_PACKAGES_REQUIRED = (
'[email protected]',
'[email protected]',
'[email protected]',
'gulp-open@3.0.1',
'gulp-debug@4.0.0',
'gulp-[email protected]',
'gulp-[email protected]',
'gulp-[email protected]',
'[email protected]',
'node-sass@4.9.3',
'[email protected]',
'siphon-media-query@1.0.0',
'[email protected]',
'gulp-htmlmin@1.3.0',
'[email protected]',
"gulp-debug@4.0.0",
"[email protected]",
"[email protected]",
"gulp-inline-css@3.4.0",
"gulp-load-plugins@2.0.1",
"gulp-[email protected]",
"gulp-[email protected]",
"gulp-[email protected]",
"[email protected]",
"gulp@4.0.2",
"[email protected]",
"lazypipe@1.0.2",
"[email protected]",
"panini@1.6.3",
"[email protected]"
)

# Path for email templates. This settings is required for start run the email builder.
Expand Down