diff --git a/.travis.yml b/.travis.yml index 7346328..ed26208 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ python: sudo: false env: - - TOX_ENV=pep8 + - TOX_ENV=py36-django211 + - TOX_ENV=coverage_combine - TOX_ENV=docs matrix: diff --git a/README.md b/README.md index 0a21958..64fcc4d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Build Status](https://travis-ci.org/alainivars/drf-microservice.png?branch=master)](https://travis-ci.org/alainivars/drf-microservice) [![PyPI version](https://badge.fury.io/py/drf-microservice.svg)](https://badge.fury.io/py/drf-microservice) -[![Documentation Status](https://readthedocs.org/projects/drf-microservice/badge/?version=latest)](http://alpha-vantage.readthedocs.io/en/latest/?badge=latest) +[![Documentation Status](https://readthedocs.org/projects/drf-microservice/badge/?version=latest)](http://drf-microservice.readthedocs.io/en/latest/?badge=latest) [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/alainivars/drf-microservice.svg)](http://isitmaintained.com/project/alainivars/drf-microservice "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/alainivars/drf-microservice.svg)](http://isitmaintained.com/project/alainivars/drf-microservice "Percentage of issues still open") [![Coverage Status](https://coveralls.io/repos/github/alainivars/drf-microservice/badge.svg?branch=master)](https://coveralls.io/github/alainivars/drf-microservice?branch=master) @@ -9,85 +9,58 @@ [![PyPi wheel](https://pypip.in/wheel/drf-microservice/badge.svg)](https://pypi.python.org/pypi/drf-microservice/) -# About drf-microservice Cookiescutter -drf-microservice is a ready-to-use API skeleton, Cookiescutter generates it, add your endpoints, test it, package it, validate it on stage and deploy it. +# About drf-microservice +drf-microservice is a ready-to-use API skeleton, generated by [cookiecutter-drf-microservice](https://github.com/alainivars/cookiecutter-drf-microservice), add your endpoints, test it, package it, validate it on stage and deploy it. It sounds simple and it is. Something disturb you in the code? Don't hesitate to submit a pull request and contribute. ### Releases Notes + - 0.7.0: restore original struct and move cookiecutter in cookiecutter-drf-microservice - 0.6.1: Update dependencies - - 0.6.0: total refactoring for add cookiecutter - - 0.5.2: fix depencies security alert + - 0.6.0: start to productionize and add cookiecutter + - 0.5.2: fix dendencies security alert - 0.5.1: fix some document presentation on github and pypi - 0.5.0: Initial publication version ### AWS secret required ```shell -APPNAME_USERNAME_PASSWD => a client API password +DRF_MiCROSERVICE_USERNAME_PASSWD => a client API password SECRET_KEY => the secret key ``` ### ENV required ```shell AWS_REGION_NAME => default="eu-east-1" -AWS_APPNAME_SECRET_NAME =>The name of the secret bucket +AWS_DRF_MiCROSERVICE_SECRET_NAME =>The name of the secret bucket ``` -## To setup - -If needed install [cookiecutter](https://github.com/audreyr/cookiecutter): -```bash -pip install cookiecutter -``` -Cookiescutter will generate it for you: -``` -cookiecutter gh:alainivars/drf-microservice 00:31:00 -github_username [my-github-user-name]: alainivars -github_repository_name [my-repository]: my-drf-microservice -app_name [my_app]: my_api -email [my-email@my-domain.my]: alainivars@gmail.com -description [The description of my drf app]: A simple demo on how to use drf-microservice generator -``` -Now we just jump in the new directory and run tox to: -- be sure that everything as worked fine -- generate the documentation -```bash -cd my-drf-microservice -tox -``` -An virtualenv is already ready for you at: -```shell -tox -l -py36-django222 -``` -or you can create your +## To install +todo ```shell -python3 -m venv /pass/to/venv +git clone xxx +cd xxx +python3 -m venv /pass_to/venv/drf-microservice ``` - for bash, zsh ```shell -source .tox/py36-django222/bin/activate +source /pass_to/venv/drf-microservice/bin/activate ``` - for fish ```shell -source .tox/py36-django222/bin/activate.fish +source /pass_to/venv/drf-microservice/bin/activate.fish +``` +python setup.py test +python manage.py migrate ``` - for bash, zsh ```shell -SECRET_KEY=my_secret_key -python manage.py makemigrations -python manage.py migrate -python manage.py createsuperuser +SECRET_KEY=my_secret_key python manage.py test ``` - for fish ```shell -env SECRET_KEY=my_secret_key -python manage.py makemigrations -python manage.py migrate -python manage.py createsuperuser +/usr/bin/env SECRET_KEY=my_secret_key python manage.py createsuperuser ``` - then run it ```shell -SECRET_KEY=my_secret_key -python manage.py runserver +SECRET_KEY=my_secret_key python manage.py runserver ``` - if you have any problem or you want enable the debug mode ```shell @@ -96,7 +69,7 @@ ENABLE_DEBUG=1 ## API -To see the Dynamic documentation for the API +To see the documentation for the API Login at ```shell curl --request POST \ @@ -128,7 +101,7 @@ curl --request GET \ ``` ![Dynamic documentation](media/docs.png) -## Testing +## testing You can run the tests by: ```shell SECRET_KEY=my_secret_key python manage.py test @@ -139,7 +112,7 @@ python setup.py test ``` or by ```shell -DJANGO_SETTINGS_MODULE={{cookiecutter.app_name}}.config.local SECRET_KEY=my_secret_key pytest +DJANGO_SETTINGS_MODULE=drf-microservice.config.local SECRET_KEY=my_secret_key pytest ``` ## Security check @@ -150,11 +123,13 @@ SECRET_KEY=my_secret_key python manage.py check --deploy ### Build and run the image with Docker #### Build the Docker image: -# WORK IN PROGRESS ````shell -docker build -t my-drf -f Dockerfile.drf-microservice . -docker build -t my-nginx -f Dockerfile.nginx . +#docker build -t drf-microservice-db -v db_volume:/var/lib/postgresql/data postgres:9.6 +docker build -t drf-microservice -f Dockerfile.drf-microservice . +docker-compose up +#docker build -t my-nginx -f Dockerfile.nginx . ```` + #### Run the container: ````shell docker network create my-network @@ -163,47 +138,48 @@ docker run -d --name nginx --net my-network -p "5000:80" my-nginx ```` If you want to change the port binding, it's here... +#### Backup your db: +````shell +sudo docker run --rm -it \ + -v pg_backups:/pg_backups \ + -v /host/dir/pg_backups:/host_backups \ + alpine:latest +```` +Then in the container +````shell +cp /pg_backups/* /host_backups/ +```` ### Build and run wit docker-compose ```shell docker-compose up ``` -### Functionalities DONE - - support basic auth +### DONE + + - support basic auth removed - support token auth - endpoint json file POST,GET - endpoint login/logout - endpoint get tocken - - postgreSQL support - -### DevOps tools DONE - - endpoint get status Icinga2 -#### Functionalities TODO - - AWS ssm secret - - endpoint json file DELETE,PUT? +### TODO + - AWS ssm secret and Kms + - add getSentry support + - endpoint json file DELETE, PUT? + - add some strong auth - create differents version: - - Aws S3 support (in progress) - - Aws RDS support - - Aws Elastisearch support - - Redis support - - Aerospike support + - S3 + - RDS + - postgreSQL + - Redis + - Aerospike - ... -#### DevOps tools TODO - - the docker-image configuration file (in progress) - - the docker-compose configuration file (in progress) - - the Packer configuration file - - the Terraform configuration file AWS - - the Terraform configuration file GCD - - the Terraform configuration file Azure - - add getSentry support - - add Aws Cloudwatch support - - the Ansible configuration file AWS - - the Ansible configuration file GCD - - the Ansible configuration file Azure - - the Juju configuration file AWS - - the Juju configuration file GCD - - the Juju configuration file Azure +#### for different use-case + - create the docker-image file + - create the ansible file + - create the terraform file + - create the kubertes file + - create the Juju file diff --git a/conf.py b/conf.py index 9541956..6a1a1fa 100644 --- a/conf.py +++ b/conf.py @@ -11,7 +11,7 @@ } master_doc = 'index' project = u'drf-microservice' -copyright = u'2017-2019' +copyright = u'2019' version = 'latest' release = 'latest' exclude_patterns = ['_build'] diff --git a/cookiecutter.json b/cookiecutter.json deleted file mode 100644 index c44bcec..0000000 --- a/cookiecutter.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "github_username": "my-github-user-name", - "github_repository_name": "my-repository", - "app_name": "my_app", - "email": "my-email@my-domain.my", - "description": "The description of my drf app" -} diff --git a/docs/index.rst b/docs/index.rst index 8cdb042..2f17307 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,243 +1,32 @@ -Welcome to drf-microservice cookiecutter's documentation! -========================================================= +.. django Highfeature website documentation master file -.. image:: https://api.travis-ci.org/alainivars/drf-microservice.svg?branch=master - :target: http://travis-ci.org/alainivars/drf-microservice - :alt: Build status +################################################################################ +Welcome to django drf-microservice website documentation! +################################################################################ -.. image:: https://coveralls.io/repos/github/alainivars/drf-microservice/badge.svg?branch=master - :target: https://coveralls.io/github/alainivars/drf-microservice?branch=master - :alt: Test coverage status +This document refers to version |release| -.. image:: https://requires.io/github/alainivars/drf-microservice/requirements.svg?branch=master - :target: https://requires.io/github/alainivars/drf-microservice/requirements/?branch=master - :alt: Requirements Status +.. warning:: + Please note that this Alpha Project is documented poorly. If you have any questions please contact us via + alainivars@gmail.com - we'd love to update the documentation and answer your question! -.. image:: https://img.shields.io/pypi/dm/drf-microservice.svg - :target: https://pypi.python.org/pypi/drf-microservice/ - :alt: pypi download +************** +Contents +************** -.. image:: https://img.shields.io/pypi/pyversions/drf-microservice.svg - :target: https://pypi.python.org/pypi/drf-microservice/ - :alt: python supported +.. toctree:: + :maxdepth: 2 -.. image:: https://img.shields.io/pypi/l/drf-microservice.svg - :target: https://pypi.python.org/pypi/drf-microservice/ - :alt: licence -.. image:: https://img.shields.io/pypi/v/drf-microservice.svg - :target: https://pypi.python.org/pypi/drf-microservice - :alt: PyPi version -.. image:: https://landscape.io/github/alainivars/drf-microservice/master/landscape.svg?style=flat - :target: https://landscape.io/github/alainivars/drf-microservice/master - :alt: Code Health +************************** +Indices and tables +************************** -.. image:: https://readthedocs.org/projects/drf-microservice/badge/?version=latest - :target: https://readthedocs.org/projects/drf-microservice/?badge=latest - :alt: Documentation status +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` -.. image:: https://pypip.in/wheel/drf-microservice/badge.svg - :target: https://pypi.python.org/pypi/drf-microservice/ - :alt: PyPi wheel - - - -About drf-microservice Cookiescutter -==================================== -drf-microservice is a ready-to-use API skeleton, Cookiescutter generates it, add your endpoints, test it, package it, validate it on stage and deploy it. -It sounds simple and it is. -Something disturb you in the code? Don't hesitate to submit a pull request and contribute. - -Releases Notes -============== - - 0.6.1: Update dependencies - - 0.6.0: total refactoring for add cookiecutter - - 0.5.2: fix depencies security alert - - 0.5.1: fix some document presentation on github and pypi - - 0.5.0: Initial publication version - -To setup -======== -+ If needed install https://github.com/audreyr/cookiecutter or :: - - pip install cookiecutter - - -+ Cookiescutter will generate it for you :: - - cookiecutter gh:alainivars/drf-microservice 00:31:00 - github_username [my-github-user-name]: alainivars - github_repository_name [my-repository]: my-drf-microservice - app_name [my_app]: my_api - email [my-email@my-domain.my]: alainivars@gmail.com - description [The description of my drf app]: A simple demo on how to use drf-microservice generator - -+ Now we just jump in the new directory and run tox to :: - - - be sure that everything as worked fine - - generate the documentation - - generate an virtualenv - - - cd my-drf-microservice - tox - -+ An virtualenv is already ready for you at :: - - tox -l - py36-django222 - -+ or you can create your :: - - python3 -m venv /pass/to/venv - -+ for bash, zsh :: - - source .tox/py36-django222/bin/activate - -+ for fish :: - - source .tox/py36-django222/bin/activate.fish - -+ for bash, zsh :: - - SECRET_KEY=my_secret_key - python setup.py makemigration - python manage.py migrate - python manage.py createsuperuser - -- for fish :: - - env SECRET_KEY=my_secret_key - python setup.py makemigration - python manage.py migrate - python manage.py createsuperuser - -- then run it :: - - SECRET_KEY=my_secret_key - python manage.py runserver - -- if you have any problem or you want enable the debug mode :: - - ENABLE_DEBUG=1 - - -API -=== -To see the documentation for the API -In development mode, login at :: - - curl --request POST \ - --url http://127.0.0.1:8000/rest-auth/login/ \ - --header 'authorization: Basic YWRtaW46YWRtaW4=' \ - --header 'content-type: application/json' \ - }' - -Actually the default mode is "development" (same to the state of this project) -in that mode a default login is the the db with username='admin' password='admin' -you will get back in return your token. - -Then open :: - - http://127.0.0.1:8000/docs/ - -Testing -======= -You can run the tests by :: - - SECRET_KEY=my_secret_key python manage.py test - -or by :: - - python setup.py test - -or by :: - - DJANGO_SETTINGS_MODULE={{cookiecutter.app_name}}.config.local SECRET_KEY=my_secret_key pytest - - -Security check -============== -Before dockerization for deployment to production, don't forget to check if by :: - - SECRET_KEY=my_secret_key python manage.py check --deploy - - -If you Use Aws -============== -Aws secret required ???:: - - APPNAME_USERNAME_PASSWD => a client API password - SECRET_KEY => the secret key - -Aws Env required:: - - AWS_REGION_NAME => default="eu-east-1" - AWS_APPNAME_SECRET_NAME =>The name of the secret bucket - -Build and run the image with Docker -=================================== - -Build the Docker image:: - - docker build -t my-drf -f Dockerfile.drf-microservice . - docker build -t my-nginx -f Dockerfile.nginx . - -Run the container:: - - docker network create my-network - docker run -d --name drf --net my-network -v /app my-drf - docker run -d --name nginx --net my-network -p "5000:80" my-nginx - -If you want to change the port binding, it's here... - - -Build and run wit docker-compose:: - - docker-compose up - - -Functionalities DONE -==================== - - support basic auth - - support token auth - - endpoint json file POST,GET - - endpoint login/logout - - endpoint get tocken - - postgreSQL support - -DevOps tools DONE -================= - - the docker-image configuration file - - the docker-compose configuration file - - endpoint get status Icinga2 - -Functionalities TODO -==================== - - AWS ssm secret - - endpoint json file DELETE,PUT? - - create differents version: - - Aws S3 support (in progress) - - Aws RDS support - - Aws Elastisearch support - - Redis support - - Aerospike support - - ... - -DevOps tools TODO -================= - - the Packer configuration file (in progress) - - the Terraform configuration file AWS (in progress) - - the Terraform configuration file GCD - - the Terraform configuration file Azure - - add getSentry support - - add Aws Cloudwatch support - - the Ansible configuration file AWS - - the Ansible configuration file GCD - - the Ansible configuration file Azure - - the Juju configuration file AWS - - the Juju configuration file GCD - - the Juju configuration file Azure +.. _Github: https://github.com/alainivars/drf-microservice +.. _Issue Tracker: https://github.com/alainivars/drf-microservice/issues diff --git a/{{cookiecutter.github_repository_name}}/manage.py b/manage.py similarity index 83% rename from {{cookiecutter.github_repository_name}}/manage.py rename to manage.py index 3c02e3a..540c6a9 100755 --- a/{{cookiecutter.github_repository_name}}/manage.py +++ b/manage.py @@ -3,7 +3,7 @@ import sys if __name__ == '__main__': - os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{{cookiecutter.app_name}}.config.common') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_api.config.common') try: from django.core.management import execute_from_command_line diff --git a/{{cookiecutter.github_repository_name}}/__init__.py b/my_api/__init__.py similarity index 100% rename from {{cookiecutter.github_repository_name}}/__init__.py rename to my_api/__init__.py diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/__init__.py b/my_api/config/__init__.py similarity index 100% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/__init__.py rename to my_api/config/__init__.py diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/common.py b/my_api/config/common.py similarity index 94% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/common.py rename to my_api/config/common.py index 45b872b..5509cfc 100644 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/common.py +++ b/my_api/config/common.py @@ -1,5 +1,5 @@ """ -Django settings for project '{{cookiecutter.app_name}}. +Django settings for project 'my_api. Generated by 'django-admin startproject' using Django 2.1.1. @@ -25,7 +25,7 @@ - DB_PASS: default 'passwd' in debug mode ssm 'db_password' in production. - DB_PORT: default '5432' - Email settings: - - {{cookiecutter.email}} + - alainivars@gmail.com - Sentry settings: - SENTRY_DSN: default is None, set to a valid DSN to enable sentry. - SENTRY_RELEASE: default 'local', set to 'stage', 'live', etc. @@ -77,13 +77,13 @@ # Allowed hosts ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '').split(',') if DEBUG: - ALLOWED_HOSTS.extend(['127.0.0.1', 'localhost']) + ALLOWED_HOSTS.extend(['127.0.0.1', 'localhost', '0.0.0.0']) # Email EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' ADMINS = ( - ('Author', '{{cookiecutter.email}}'), + ('Author', 'alainivars@gmail.com'), ) REST_FRAMEWORK = { @@ -123,7 +123,7 @@ 'rest_framework.authtoken', 'rest_auth', - '{{cookiecutter.app_name}}.rest', + 'my_api.rest', ] MIDDLEWARE = [ @@ -138,7 +138,7 @@ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] -ROOT_URLCONF = '{{cookiecutter.app_name}}.urls' +ROOT_URLCONF = 'my_api.urls' TEMPLATES = [ { @@ -156,7 +156,7 @@ }, ] -WSGI_APPLICATION = '{{cookiecutter.app_name}}.wsgi.application' +WSGI_APPLICATION = 'my_api.wsgi.application' if TESTING: DATABASES = { @@ -167,7 +167,10 @@ } else: if DEBUG: - DB_HOST = os.getenv('DB_HOST', '127.0.0.1') + if os.getenv('DOCKER_CONTAINER'): + DB_HOST = 'db' + else: + DB_HOST = os.getenv('DB_HOST', '127.0.0.1') DB_USER = os.getenv('DB_USER', 'user') DB_PASS = os.getenv('DB_PASS', 'passwd') DB_NAME = os.getenv('DB_NAME', 'project_db') @@ -180,7 +183,10 @@ }, } else: - DB_HOST = os.getenv('DB_HOST', '127.0.0.1') + if os.getenv('DOCKER_CONTAINER'): + DB_HOST = 'db' + else: + DB_HOST = os.getenv('DB_HOST', '127.0.0.1') DB_USER = os.getenv('DB_USER', 'user') DB_PASS = secrets.get('db_password', 'passwd') DB_NAME = os.getenv('DB_NAME', 'project_db') diff --git a/my_api/config/local.py b/my_api/config/local.py new file mode 100644 index 0000000..eabebd4 --- /dev/null +++ b/my_api/config/local.py @@ -0,0 +1,4 @@ +# Load the production settings that we will overwrite as needed in our user1 settings file. +from my_api.config.production import * + +# TODO diff --git a/my_api/config/production.py b/my_api/config/production.py new file mode 100644 index 0000000..e7a93df --- /dev/null +++ b/my_api/config/production.py @@ -0,0 +1,4 @@ +# Load the common settings that we will overwrite as needed in our user1 settings file. +from my_api.config.common import * + +# TODO diff --git a/my_api/config/qa.py b/my_api/config/qa.py new file mode 100644 index 0000000..eabebd4 --- /dev/null +++ b/my_api/config/qa.py @@ -0,0 +1,4 @@ +# Load the production settings that we will overwrite as needed in our user1 settings file. +from my_api.config.production import * + +# TODO diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/__init__.py b/my_api/rest/__init__.py similarity index 100% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/__init__.py rename to my_api/rest/__init__.py diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/apps.py b/my_api/rest/apps.py similarity index 100% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/apps.py rename to my_api/rest/apps.py diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/__init__.py b/my_api/rest/migrations/__init__.py similarity index 100% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/__init__.py rename to my_api/rest/migrations/__init__.py diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/models.py b/my_api/rest/models.py similarity index 100% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/models.py rename to my_api/rest/models.py diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/serializers.py b/my_api/rest/serializers.py similarity index 98% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/serializers.py rename to my_api/rest/serializers.py index 1ce8598..4ae15f5 100644 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/serializers.py +++ b/my_api/rest/serializers.py @@ -11,6 +11,7 @@ class UserSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = User fields = ('url', 'username', 'email', 'groups') + read_only_fields = ('username', ) # def create(self, validated_data): # user = User( diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/migrations/__init__.py b/my_api/rest/tests/__init__.py similarity index 100% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/migrations/__init__.py rename to my_api/rest/tests/__init__.py diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/base.py b/my_api/rest/tests/base.py similarity index 100% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/base.py rename to my_api/rest/tests/base.py diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/files/file_ko.json b/my_api/rest/tests/files/file_ko.json similarity index 100% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/files/file_ko.json rename to my_api/rest/tests/files/file_ko.json diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/files/file_ok.json b/my_api/rest/tests/files/file_ok.json similarity index 100% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/files/file_ok.json rename to my_api/rest/tests/files/file_ok.json diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/test_basic.py b/my_api/rest/tests/test_basic.py similarity index 93% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/test_basic.py rename to my_api/rest/tests/test_basic.py index 56c18c3..ed382c3 100644 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/test_basic.py +++ b/my_api/rest/tests/test_basic.py @@ -3,7 +3,7 @@ from rest_framework import status from rest_framework.reverse import reverse -from {{cookiecutter.app_name}}.rest.tests.base import BaseTestCase +from my_api.rest.tests.base import BaseTestCase class BasicTestCase(BaseTestCase): diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/test_project.py b/my_api/rest/tests/test_project.py similarity index 91% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/test_project.py rename to my_api/rest/tests/test_project.py index 1cb7c3d..6a8d8c0 100644 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/test_project.py +++ b/my_api/rest/tests/test_project.py @@ -6,7 +6,7 @@ from rest_framework.reverse import reverse from rest_framework.test import APIClient -from {{cookiecutter.app_name}}.rest.tests.base import BaseTestCase +from my_api.rest.tests.base import BaseTestCase class ViewTestCase(BaseTestCase): @@ -50,7 +50,7 @@ def test_docs(self): self.assertEqual(response.status_code, status.HTTP_200_OK) def test_api_file_with_credential_good_key(self): - with open('./{{cookiecutter.app_name}}/rest/tests/files/file_ok.json') as f: + with open('./my_api/rest/tests/files/file_ok.json') as f: file_content = f.read() json_file_content = json.loads(file_content) response = self.basics_auth_post( @@ -71,7 +71,7 @@ def test_api_file_with_credential_good_key(self): self.assertEqual(response.data, json_file_content) def test_api_file_with_credential_wrong_key(self): - with open('./{{cookiecutter.app_name}}/rest/tests/files/file_ko.json') as f: + with open('./my_api/rest/tests/files/file_ko.json') as f: file_content = f.read() json_file_content = json.loads(file_content) response = self.basics_auth_post( @@ -84,7 +84,7 @@ def test_api_file_with_credential_wrong_key(self): self.assertEqual(response.data[0], "'file' is a required field.") def test_api_file_with_token_good_key(self): - with open('./{{cookiecutter.app_name}}/rest/tests/files/file_ok.json') as f: + with open('./my_api/rest/tests/files/file_ok.json') as f: file_content = f.read() json_file_content = json.loads(file_content) response = self.token_auth_post( @@ -103,7 +103,7 @@ def test_api_file_with_token_good_key(self): self.assertEqual(response.data, json_file_content) def test_api_file_with_token_wrong_key(self): - with open('./{{cookiecutter.app_name}}/rest/tests/files/file_ko.json') as f: + with open('./my_api/rest/tests/files/file_ko.json') as f: file_content = f.read() json_file_content = json.loads(file_content) response = self.token_auth_post( diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/views.py b/my_api/rest/views.py similarity index 96% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/views.py rename to my_api/rest/views.py index 061ab26..fa35d96 100644 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/views.py +++ b/my_api/rest/views.py @@ -7,7 +7,7 @@ from rest_framework.response import Response from rest_framework import status -from {{cookiecutter.app_name}}.rest.serializers import FileToFilesystemSerializer, UserSerializer +from my_api.rest.serializers import FileToFilesystemSerializer """ diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/setup.py b/my_api/setup.py similarity index 81% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/setup.py rename to my_api/setup.py index c38a1b7..e876de3 100644 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/setup.py +++ b/my_api/setup.py @@ -9,14 +9,14 @@ long_description = f.read().strip() setup( - name='{{cookiecutter.github_repository_name}}', + name='drf-microservice', version='0.1.0', - author='{{cookiecutter.github_username}}', - author_email='{{cookiecutter.email}}', - url='http://github.com/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}}', + author='alainivars', + author_email='alainivars@gmail.com', + url='http://github.com/alainivars/drf-microservice', license='Apache License 2.0', description=''' - {{cookiecutter.description}} + The description of my drf api ''', packages=find_packages(), long_description=long_description, diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/urls.py b/my_api/urls.py similarity index 90% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/urls.py rename to my_api/urls.py index 9322d42..c1dedd8 100644 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/urls.py +++ b/my_api/urls.py @@ -4,7 +4,7 @@ https://docs.djangoproject.com/en/2.1/topics/http/urls/ Examples: Function views - 1. Add an import: from {{cookiecutter.github_repository_name}} import views + 1. Add an import: from drf-microservice import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home @@ -20,7 +20,7 @@ from django.contrib import admin from rest_framework.authtoken import views as rest_framework_views from rest_framework.documentation import include_docs_urls -from {{cookiecutter.app_name}}.rest.views import status_api, Icinga2API, FileAPI +from my_api.rest.views import status_api, Icinga2API, FileAPI urlpatterns = [ path('admin/', admin.site.urls), @@ -39,5 +39,6 @@ # the API path('api/v1/file', FileAPI.as_view(), name='api_file'), + # Some media files if you need it else remove it ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/wsgi.py b/my_api/wsgi.py similarity index 67% rename from {{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/wsgi.py rename to my_api/wsgi.py index 6c3efb8..20a912f 100644 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/wsgi.py +++ b/my_api/wsgi.py @@ -1,5 +1,5 @@ """ -WSGI config for project '{{cookiecutter.app_name}}'. +WSGI config for project 'my_api'. It exposes the WSGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{{cookiecutter.app_name}}.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_api.settings') application = get_wsgi_application() diff --git a/requirements.txt b/requirements.txt index 5da2b58..52a3c0a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,8 @@ # Core pytz==2019.1 # django dependency Django==2.2.2 +#gunicorn==19.9.0 +#newrelic==4.12.0.120 # Storages psycopg2-binary==2.7.7 @@ -24,5 +26,3 @@ coreschema==0.0.4 # coreapi dependency itypes==1.1.0 # coreapi dependency uritemplate==3.0.0 # coreapi dependency coreapi==2.3.3 - - diff --git a/setup.py b/setup.py index bfbfea5..3312351 100644 --- a/setup.py +++ b/setup.py @@ -9,14 +9,14 @@ long_description = f.read().strip() setup( - name='drf-microservice', - version='0.6.1', + name='my-drf-microservice', + version='0.7.0', author='Alain IVARS', author_email='alainivars@gmail.com', - url='http://github.com/alainivars/drf-microservice', + url='http://github.com/alainivars/my-drf-microservice', license='Apache License 2.0', description=''' - Create a REST API endpoints with Authentication and Registration. + A REST API endpoints with Authentication and Registration. Read the README.md for more information. ''', packages=find_packages(), diff --git a/tox.ini b/tox.ini index 6dd02cf..37d00a3 100644 --- a/tox.ini +++ b/tox.ini @@ -6,14 +6,16 @@ minversion=2.5 toxworkdir=.tox envlist = pep8, + {py36}-django{222}, + coverage_combine, docs [testenv] commands = - pytest --doctest-modules + /usr/bin/env SECRET_KEY=test pytest --ds=my_api.config.common --doctest-modules -v --cov my_api/rest --cov-report term-missing deps = - pycodestyle - recommonmark + -r{toxinidir}/requirements.txt + -r{toxinidir}/requirements_test.txt [testenv:docs] changedir=docs @@ -24,6 +26,13 @@ deps = commands= sphinx-build -b html -c {envtmpdir}/../../.. -d {envtmpdir}/doctrees . {envtmpdir}/html +[testenv:coverage_combine] +deps = coverage +commands= + coverage xml + coverage html + coverage erase + [testenv:pep8] skip_install = True whitelist_externals = pep8 @@ -31,4 +40,4 @@ deps = pycodestyle recommonmark commands = - pycodestyle --max-line-length 140 . + pycodestyle --max-line-length 95 my_api diff --git a/{{cookiecutter.github_repository_name}}/.travis.yml b/{{cookiecutter.github_repository_name}}/.travis.yml deleted file mode 100644 index 30cba7d..0000000 --- a/{{cookiecutter.github_repository_name}}/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -language: python -python: - - "3.6" - -sudo: false - -env: - - TOX_ENV=py36-django211 - - TOX_ENV=coverage_combine - - TOX_ENV=docs - -matrix: - #fast_finish: true - allow_failures: - - env: TOX_ENV=coverage_combine - - env: TOX_ENV=docs - -before_install: - - pip install pytest pytest-cov - - pip install coveralls - -install: - - pip install tox - -script: - - tox -e $TOX_ENV - -after_success: - - coveralls - -notifications: - email: - - {{cookiecutter.email}} - diff --git a/{{cookiecutter.github_repository_name}}/Dockerfile.drf-microservice b/{{cookiecutter.github_repository_name}}/Dockerfile.drf-microservice deleted file mode 100644 index 1978510..0000000 --- a/{{cookiecutter.github_repository_name}}/Dockerfile.drf-microservice +++ /dev/null @@ -1,34 +0,0 @@ -# -# The doc: https://docs.docker.com/engine/reference/builder/#usage -# Dockerfile-{{cookiecutter.github_repository_name}} - -FROM python:3 -#FROM python:alpine3.6 - -# Set an environment variable with the directory -# where we'll be running the project -ENV APP /{{cookiecutter.github_repository_name}} - -# Create the directory and instruct Docker to operate -# from there from now on -RUN mkdir $APP -WORKDIR $APP - -# Expose the port uWSGI will listen on -EXPOSE 8000 - -# Copy the requirements file in order to install -# Python dependencies -COPY requirements.txt . - -# Install Python dependencies -#RUN pip install -r requirements.txt -RUN python3 setup.py install - -# We copy the rest of the codebase into the image -COPY . . - -# Finally, we run uWSGI with the ini file we -# created earlier -CMD ["uwsgi", "--ini", "{{cookiecutter.github_repository_name}}.ini"] -#CMD ["gunicorn", "--workers=2", "--bind=0.0.0.0:8000", "project:project"] \ No newline at end of file diff --git a/{{cookiecutter.github_repository_name}}/Dockerfile.nginx b/{{cookiecutter.github_repository_name}}/Dockerfile.nginx deleted file mode 100644 index d394b40..0000000 --- a/{{cookiecutter.github_repository_name}}/Dockerfile.nginx +++ /dev/null @@ -1,18 +0,0 @@ -# -# The doc: https://docs.docker.com/engine/reference/builder/#usage -# The origin: https://medium.com/bitcraft/docker-composing-a-python-3-flask-app-line-by-line-93b721105777 -# -# Dockerfile-nginx - -FROM nginx:latest - -# Nginx will listen on this port -EXPOSE 80 - -# Remove the default config file that -# /etc/nginx/nginx.conf includes -RUN rm /etc/nginx/conf.d/default.conf - -# We copy the requirements file in order to install -# Python dependencies -COPY app.conf /etc/nginx/conf.d \ No newline at end of file diff --git a/{{cookiecutter.github_repository_name}}/README.md b/{{cookiecutter.github_repository_name}}/README.md deleted file mode 100644 index bd14684..0000000 --- a/{{cookiecutter.github_repository_name}}/README.md +++ /dev/null @@ -1,157 +0,0 @@ -[![Build Status](https://travis-ci.org/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}}.png?branch=master)](https://travis-ci.org/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}}) -[![PyPI version](https://badge.fury.io/py/{{cookiecutter.github_repository_name}}.svg)](https://badge.fury.io/py/{{cookiecutter.github_repository_name}}) -[![Documentation Status](https://readthedocs.org/projects/{{cookiecutter.github_repository_name}}/badge/?version=latest)](http://{{cookiecutter.github_repository_name}}.readthedocs.io/en/latest/?badge=latest) -[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}}.svg)](http://isitmaintained.com/project/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}} "Average time to resolve an issue") -[![Percentage of issues still open](http://isitmaintained.com/badge/open/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}}.svg)](http://isitmaintained.com/project/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}} "Percentage of issues still open") -[![Coverage Status](https://coveralls.io/repos/github/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}}/badge.svg?branch=master)](https://coveralls.io/github/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}}?branch=master) -[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/Django.svg) -[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -[![PyPi wheel](https://pypip.in/wheel/drf-microservice/badge.svg)](https://pypi.python.org/pypi/drf-microservice/) - - -# drf-microservice -A DRF microservice - -!!! IN PRODUCTION, use only the TokenAuthentication !!! - -Something disturb you in the code? Don't hesitate to submit a pull request and contribute. - -### Releases Notes - - - 0.6.0: start to productionize and add cookiecutter - - 0.5.2: fix dendencies security alert - - 0.5.1: fix some document presentation on github and pypi - - 0.5.0: Initial publication version - -### AWS secret required -```shell -{{cookiecutter.github_repository_name}}_USERNAME_PASSWD => a client API password -SECRET_KEY => the secret key -``` -### ENV required -```shell -AWS_REGION_NAME => default="eu-east-1" -AWS_{{cookiecutter.github_repository_name}}_SECRET_NAME =>The name of the secret bucket -``` -## To install -todo -```shell -git clone xxx -cd xxx -python3 -m venv /pass_to/venv/{{cookiecutter.github_repository_name}} -``` -- for bash, zsh -```shell -source /pass_to/venv/{{cookiecutter.github_repository_name}}/bin/activate -``` -- for fish -```shell -source /pass_to/venv/{{cookiecutter.github_repository_name}}/bin/activate.fish -``` -python setup.py test -python manage.py migrate -``` -- for bash, zsh -```shell -SECRET_KEY=my_secret_key python manage.py test -``` -- for fish -```shell -/usr/bin/env SECRET_KEY=my_secret_key python manage.py createsuperuser -``` -- then run it -```shell -SECRET_KEY=my_secret_key python manage.py runserver -``` -- if you have any problem or you want enable the debug mode -```shell -ENABLE_DEBUG=1 -``` - - -## API -To see the documentation for the API -In development mode, login at -```shell -curl --request POST \ - --url http://127.0.0.1:8000/rest-auth/login/ \ - --header 'authorization: Basic YWRtaW46YWRtaW4=' \ - --header 'content-type: application/json' \ -}' -``` -Actually the default mode is "development" (same to the state of this project) -in that mode a default login is the the db with username='admin' password='admin' -you will get back in return your token. - -Then open -```web -http://127.0.0.1:8000/docs/ -``` -## testing -You can run the tests by: -```shell -SECRET_KEY=my_secret_key python manage.py test -``` -or by -```shell -python setup.py test -``` -or by -```shell -DJANGO_SETTINGS_MODULE={{cookiecutter.github_repository_name}}.config.local SECRET_KEY=my_secret_key pytest -``` - -## Security check -Before dockerization for deployment to production, don't forget to check if by -```shell -SECRET_KEY=my_secret_key python manage.py check --deploy -``` -### Build and run the image with Docker - -#### Build the Docker image: -````shell -docker build -t my-drf -f Dockerfile.drf-microservice . -docker build -t my-nginx -f Dockerfile.nginx . -```` -#### Run the container: -````shell -docker network create my-network -docker run -d --name drf --net my-network -v /app my-drf -docker run -d --name nginx --net my-network -p "5000:80" my-nginx -```` -If you want to change the port binding, it's here... - - -### Build and run wit docker-compose -```shell -docker-compose up -``` - -### DONE - - - support basic auth removed - - support token auth - - endpoint json file POST,GET - - endpoint login/logout - - endpoint get tocken - -### TODO - - AWS ssm secret and Kms - - add getSentry support - - endpoint json file DELETE, PUT? - - add some strong auth - - create differents version: - - S3 - - RDS - - postgreSQL - - Redis - - Aerospike - - ... - -#### for different use-case - - create the docker-image file - - create the ansible file - - create the terraform file - - create the kubertes file - - create the Juju file - diff --git a/{{cookiecutter.github_repository_name}}/conf.py b/{{cookiecutter.github_repository_name}}/conf.py deleted file mode 100644 index 8a85aff..0000000 --- a/{{cookiecutter.github_repository_name}}/conf.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- - -extensions = ['recommonmark'] -templates_path = [ - '/home/docs/checkouts/readthedocs.org/readthedocs/templates/sphinx', - 'templates', '_templates', '.templates'] -source_suffix = { - '.rst': 'restructuredtext', - '.txt': 'markdown', - '.md': 'markdown', -} -master_doc = 'index' -project = u'{{cookiecutter.github_repository_name}}' -copyright = u'2019' -version = 'latest' -release = 'latest' -exclude_patterns = ['_build'] -pygments_style = 'sphinx' -htmlhelp_basename = '{{cookiecutter.github_repository_name}}' -file_insertion_enabled = False -latex_documents = [ - ('index', '{{cookiecutter.github_repository_name}}.tex', u'{{cookiecutter.github_repository_name}} Documentation', - u'', 'manual'), -] diff --git a/{{cookiecutter.github_repository_name}}/docker-compose.yml b/{{cookiecutter.github_repository_name}}/docker-compose.yml deleted file mode 100644 index 46c01b9..0000000 --- a/{{cookiecutter.github_repository_name}}/docker-compose.yml +++ /dev/null @@ -1,27 +0,0 @@ -# -# The doc: https://docs.docker.com/compose/compose-file/ -# The origin: https://medium.com/bitcraft/docker-composing-a-python-3-drf-app-line-by-line-93b721105777 -# - -# docker-compose.yml - -version: '3' -services: - - drf: - image: webapp-drf - build: - context: . - dockerfile: Dockerfile.drf-microservice - volumes: - - "./:/project" - - nginx: - image: webapp-nginx - build: - context: . - dockerfile: Dockerfile.nginx - ports: - - 8000:8000 - depends_on: - - drf diff --git a/{{cookiecutter.github_repository_name}}/docs/index.rst b/{{cookiecutter.github_repository_name}}/docs/index.rst deleted file mode 100644 index ef27003..0000000 --- a/{{cookiecutter.github_repository_name}}/docs/index.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. django Highfeature website documentation master file - -################################################################################ -Welcome to django {{cookiecutter.github_repository_name}} website documentation! -################################################################################ - -This document refers to version |release| - -.. warning:: - Please note that this Alpha Project is documented poorly. If you have any questions please contact us via - {{cookiecutter.email}} - we'd love to update the documentation and answer your question! - -************** -Contents -************** - -.. toctree:: - :maxdepth: 2 - - - -************************** -Indices and tables -************************** - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - - -.. _Github: https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}} -.. _Issue Tracker: https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}}/issues diff --git a/{{cookiecutter.github_repository_name}}/drf-microservice.ini b/{{cookiecutter.github_repository_name}}/drf-microservice.ini deleted file mode 100644 index 3d46d9c..0000000 --- a/{{cookiecutter.github_repository_name}}/drf-microservice.ini +++ /dev/null @@ -1,25 +0,0 @@ -; drf-microservice.ini -; infos at https://uwsgi-docs.readthedocs.io/en/latest/Configuration.html - -[uwsgi] -;protocol = uwsgi -module = wsgi - -; Name of Python file minus the file extension -module = {{cookiecutter.github_repository_name}} - -; Name of the variable in script that will be called -callable = {{cookiecutter.github_repository_name}} - -master = true - -; Set uWSGI to start up 3 workers -processes = 3 - -; Use the port 8000 which we will then expose on our Dockerfile -;socket = 0.0.0.0:8000 -socket = {{cookiecutter.github_repository_name}}.sock -chmod-socket = 660 -vacuum = true - -die-on-term = true diff --git a/{{cookiecutter.github_repository_name}}/gen_json_with_image.py b/{{cookiecutter.github_repository_name}}/gen_json_with_image.py deleted file mode 100644 index 0184d49..0000000 --- a/{{cookiecutter.github_repository_name}}/gen_json_with_image.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- -""" -Create a json file with a base64 file string inside -uri-scheme doc: https://en.wikipedia.org/wiki/Data_URI_scheme -""" -import argparse -import base64 -import json -import os -from pprint import pprint - - -def create_json_with_file(file, file_type, for_js): - filename = os.path.basename(file) - full_filename, file_extension = os.path.splitext(file) - b64 = base64.b64encode(open(file, "rb").read()) - try: - # Python2 - print(file + "='''\\\n" + b64 + "'''") - except TypeError: - # Python3 - print(file + "='''\\\n" + b64.decode("utf8") + "'''") - - if for_js: - my_json = { - 'file': 'data:file/{};base64,{}'.format(file_extension[1:], b64.decode("utf8")) - } - else: - my_json = { - 'filename': filename, - 'uri-scheme': 'data:{}/{};base64'.format(file_type, file_extension[1:]), - 'file': '{}'.format(b64.decode("utf8")) - } - with open(full_filename + '.json', 'w') as outfile: - json.dump(my_json, outfile) - - -def parsing_command_line(): - args = parser.parse_args() - pprint(args) - return args - - -parser = argparse.ArgumentParser() -parser.add_argument('-v', '--version', action='version', version='0.5.0') -group1 = parser.add_argument_group() -group1.add_argument('-n', '--file_name', help='the full path filename') -group1.add_argument('-t', '--file_type', help='the file type (image/pdf/...)') -group1.add_argument('-j', '--for_js', default=0, type=int, - help='for javascript framework (default: 0 (no))') - - -if __name__ == '__main__': - args = parsing_command_line() - if args.file_name: - create_json_with_file(args.file_name, args.file_type, args.for_js) diff --git a/{{cookiecutter.github_repository_name}}/index.rst b/{{cookiecutter.github_repository_name}}/index.rst deleted file mode 100644 index 016b232..0000000 --- a/{{cookiecutter.github_repository_name}}/index.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. django {{cookiecutter.github_repository_name}} documentation master file - -######################################################################## -Welcome to django {{cookiecutter.github_repository_name}} documentation! -######################################################################## - -This document refers to version |release| - -.. warning:: - Please note that this Project is documented lightly. If you have any questions please contact us via - {{cookiecutter.email}} - we'd love to update the documentation and answer your question! - -************** -Contents -************** - -.. toctree:: - :maxdepth: 2 - - - -************************** -Indices and tables -************************** - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - - -.. _Github: https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}} -.. _Issue Tracker: https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}}/issues diff --git a/{{cookiecutter.github_repository_name}}/requirements.txt b/{{cookiecutter.github_repository_name}}/requirements.txt deleted file mode 100644 index 52a73af..0000000 --- a/{{cookiecutter.github_repository_name}}/requirements.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Core -pytz==2019.1 -Django==2.2.2 - -# Storages -psycopg2-binary==2.7.7 -dj-database-url==0.5.0 - -# Rest apis -djangorestframework==3.9.4 -django-filter==2.1.0 -django-rest-auth==0.9.5 - -# AWS -boto3==1.9.166 -botocore==1.12.166 -s3transfer==0.2.1 - -# Documentations -Markdown==3.1.1 -coreapi==2.3.3 -coreschema==0.0.4 -mkdocs==1.0.4 - -# Other -atomicwrites==1.3.0 -attrs==19.1.0 -certifi==2019.3.9 -chardet==3.0.4 -click==7.0 -docutils==0.14 -idna==2.8 -itypes==1.1.0 -Jinja2==2.10.1 -jmespath==0.9.4 -MarkupSafe==1.1.1 -more-itertools==7.0.0 -pluggy==0.12.0 -py==1.8.0 -python-dateutil==2.8.0 -requests==2.22.0 -six==1.12.0 -uritemplate==3.0.0 -urllib3==1.25.3 diff --git a/{{cookiecutter.github_repository_name}}/requirements_test.txt b/{{cookiecutter.github_repository_name}}/requirements_test.txt deleted file mode 100644 index f901394..0000000 --- a/{{cookiecutter.github_repository_name}}/requirements_test.txt +++ /dev/null @@ -1,11 +0,0 @@ -django-setuptest -pygments>=2.4.2 -pytest>=4.6.3 -pytest-django>=3.4.8 -pytest-pep8>=1.0.6 -pytest-cov -coverage>=4.5.3 -pycodestyle -recommonmark -sphinx -readthedocs-sphinx-ext diff --git a/{{cookiecutter.github_repository_name}}/setup.py b/{{cookiecutter.github_repository_name}}/setup.py deleted file mode 100644 index e405a7d..0000000 --- a/{{cookiecutter.github_repository_name}}/setup.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python - -import os -from setuptools import setup, find_packages - - -here = os.path.dirname(os.path.abspath(__file__)) -with open(os.path.join(here, 'README.md')) as f: - long_description = f.read().strip() - -setup( - name='{{cookiecutter.github_repository_name}}', - version='0.6.1', - author='Alain IVARS', - author_email='{{cookiecutter.email}}', - url='http://github.com/{{cookiecutter.github_username}}/{{cookiecutter.github_repository_name}}', - license='Apache License 2.0', - description=''' - Create a REST API endpoints with Authentication and Registration. - Read the README.md for more information. - ''', - packages=find_packages(), - long_description=long_description, - long_description_content_type='text/markdown', - keywords=''' - django rest auth registration rest-framework django-registration api docker cookiecuter tox pytest - ''', - zip_safe=False, - test_suite='setuptest.setuptest.SetupTestSuite', - include_package_data=True, - # https://pypi.org/classifiers/ - classifiers=[ - 'Development Status :: 2 - Pre-Alpha', - 'Framework :: Django :: 2.1', - 'License :: OSI Approved :: Apache License, Version 2.0 (Apache-2.0)', - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Topic :: Internet :: WWW/HTTP' - ], -) diff --git a/{{cookiecutter.github_repository_name}}/tox.ini b/{{cookiecutter.github_repository_name}}/tox.ini deleted file mode 100644 index 1ece5ee..0000000 --- a/{{cookiecutter.github_repository_name}}/tox.ini +++ /dev/null @@ -1,43 +0,0 @@ -[pytest] -addopts=--tb=short - -[tox] -minversion=2.5 -toxworkdir=.tox -envlist = - pep8, - {py36}-django{222}, - coverage_combine, - docs - -[testenv] -commands = - /usr/bin/env SECRET_KEY=test pytest --ds={{cookiecutter.app_name}}.config.common --doctest-modules -v --cov {{cookiecutter.app_name}}/rest --cov-report term-missing -deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/requirements_test.txt - -[testenv:docs] -changedir=docs -#basepython=python3.6 -deps = - -r{toxinidir}/requirements_test.txt - -commands= - sphinx-build -b html -c {envtmpdir}/../../.. -d {envtmpdir}/doctrees . {envtmpdir}/html - -[testenv:coverage_combine] -deps = coverage -commands= - coverage xml - coverage html - coverage erase - -[testenv:pep8] -skip_install = True -whitelist_externals = pep8 -deps = - pycodestyle - recommonmark -commands = - pycodestyle --max-line-length 95 {{cookiecutter.app_name}} diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/local.py b/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/local.py deleted file mode 100644 index 6a19cf7..0000000 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/local.py +++ /dev/null @@ -1,3 +0,0 @@ -import {{cookiecutter.app_name}}.config.common - -# TODO diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/production.py b/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/production.py deleted file mode 100644 index 6a19cf7..0000000 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/production.py +++ /dev/null @@ -1,3 +0,0 @@ -import {{cookiecutter.app_name}}.config.common - -# TODO diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/qa.py b/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/qa.py deleted file mode 100644 index 6a19cf7..0000000 --- a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/config/qa.py +++ /dev/null @@ -1,3 +0,0 @@ -import {{cookiecutter.app_name}}.config.common - -# TODO diff --git a/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/__init__.py b/{{cookiecutter.github_repository_name}}/{{cookiecutter.app_name}}/rest/tests/__init__.py deleted file mode 100644 index e69de29..0000000