Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating project to the latest standards and versions #1

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
64 changes: 1 addition & 63 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,64 +1,2 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IDE specifics
.idea/
*.swp

# Database specifics
*.sqlite
__pycache__/
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: python

python: 3.5
env:
- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
- TOXENV=py35

install:
- pip install -U tox

script:
- tox
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# django-api-template
# django-api-template
[![Build Status](https://travis-ci.org/harnash/django_api_template.svg?branch=master)](https://travis-ci.org/harnash/django_api_template)

Django project template for building RESTful API services
8 changes: 8 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"apps_dir": "apps",
"project_name": "my_project",
"project_dir": "{{cookiecutter.project_name|replace(' ', '_')}}",
"secret_key": "FOR DEV ONLY - CHANGE ME",
"database_type": ["PostgreSQL", "MySQL", "SQLite", "Other"],
"database_url": "{{cookiecutter.database_type|lower}}://path_to_database"
}
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
testpaths = tests/
43 changes: 0 additions & 43 deletions requirements/_base.txt

This file was deleted.

19 changes: 0 additions & 19 deletions requirements/local.txt

This file was deleted.

29 changes: 29 additions & 0 deletions tests/test_sample_projects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
from contextlib import contextmanager
from cookiecutter.utils import rmtree


@contextmanager
def temporary_project(cookies, *args, **kwargs):
"""
Delete the temporal directory that is created when executing the tests
:param cookies: pytest_cookies.Cookies
"""
result = cookies.bake(*args, **kwargs)
try:
yield result
finally:
rmtree(str(result.project))

def test_envrc(cookies):
"""
Test if the .envrc file was created successfully
"""

extra_context = {'project_name': 'environ'}

with temporary_project(cookies, extra_context=extra_context) as result:
envrc_file = result.project.join('.envrc')
lines = [x.strip() for x in envrc_file.readlines(cr=False)]
assert 'export ENVIRON_SECRET_KEY=FOR DEV ONLY - CHANGE ME' in lines
assert 'export ENVIRON_DATABASE_URL=postgresql://path_to_database' in lines
20 changes: 20 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tox]
envlist = py27, py33, py34, py35, pypy
skipsdist = true

[testenv]
whitelist_externals = bash
deps =
Django>=1.10
pip
cookiecutter
pytest-cookies
pytest
tox
pytest-cov
watchdog
sh
flake8

commands =
py.test
65 changes: 65 additions & 0 deletions {{cookiecutter.project_dir}}/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
.venv/

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IDE specifics
.idea/
*.swp

# Database specifics
*.sqlite
20 changes: 20 additions & 0 deletions {{cookiecutter.project_dir}}/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[source]]
url = "https://pypi.org/"
verify_ssl = true

[dev-packages]
django-extensions = "*"
Sphinx = "*"
django-debug-toolbar = "*"
Werkzeug = "*"

[packages]
Unipath = "*"
djangorestframework = ">=3.5"
dj-database-url = "*"
django = ">=1.10"
{% if cookiecutter.database_type == "MySQL" %}
mysqlclient = ">=1.3"
{% elif cookiecutter.database_type == "PostgreSQL" %}
psycopg2 = ">=2.7"
{% endif %}
38 changes: 38 additions & 0 deletions {{cookiecutter.project_dir}}/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{cookiecutter.project_name}}.settings.local")

from django.core.management import execute_from_command_line

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_env_var(varname, default=None):
MANAGERS = ADMINS

DATABASES = {
'default': dj_database_url.parse(get_env_var('{{ project_name|upper }}_DATABASE_URL'))
'default': dj_database_url.parse(get_env_var('{{cookiecutter.project_name|upper}}_DATABASE_URL'))
}

# Local time zone for this installation. Choices can be found here:
Expand Down Expand Up @@ -74,7 +74,7 @@ def get_env_var(varname, default=None):
STATICFILES_DIRS = ()

# Make this unique, and don't share it with anybody.
SECRET_KEY = get_env_var('{{ project_name|upper }}_SECRET_KEY')
SECRET_KEY = get_env_var('{{cookiecutter.project_name|upper}}_SECRET_KEY')

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
Expand All @@ -87,10 +87,10 @@ def get_env_var(varname, default=None):
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = '{{ project_name }}.urls'
ROOT_URLCONF = '{{cookiecutter.project_name}}.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
WSGI_APPLICATION = '{{cookiecutter.project_name}}.wsgi.application'

TEMPLATES = [
{
Expand Down
Loading