diff --git a/.travis.yml b/.travis.yml index 3f55eeb22b..9f63351f98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,9 @@ python: - 3.4 before_install: - - pip install pep8 - - pip install django - - pip install djangorestframework - + - make setup + - make setup_ci + script: - - python pep_check.py - - python InvenTree/manage.py check - - python InvenTree/manage.py test --noinput \ No newline at end of file + - make style + - make test diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 8585f5b911..ab2205a296 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -20,6 +20,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! +# TODO: remove this SECRET_KEY = 'oc2z%5)lu#jsxi#wpg)700z@v48)2aa_yn(a(3qg!z!fw&tr9f' # SECURITY WARNING: don't run with debug turned on in production! @@ -40,7 +41,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - + # InvenTree apps 'part.apps.PartConfig', 'project.apps.ProjectConfig', diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..307922603a --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +clean: + find . -path '*/__pycache__/*' -delete + find . -type d -name '__pycache__' -empty -delete + find . -name *.pyc -o -name *.pyo -delete + rm -rf *.egg-info + rm -rf .cache + rm -rf .tox + rm -f .coverage + +style: + flake8 + +test: + python InvenTree/manage.py test --noinput + +setup: + # TODO: replace this with a proper setup.py + pip install -U -r requirements/base.txt + python InvenTree/manage.py migrate --run-syncdb + python InvenTree/manage.py check + +setup_ci: + pip install -U -r requirements/build.txt + +develop: + pip install -U -r requirements/dev.txt + +superuser: + python InvenTree/manage.py createsuperuser diff --git a/README.md b/README.md index b8b975b804..18c67aebbf 100644 --- a/README.md +++ b/README.md @@ -4,18 +4,22 @@ Open Source Inventory Management System [![Build Status](https://travis-ci.org/inventree/InvenTree.svg?branch=master)](https://travis-ci.org/inventree/InvenTree) ## Installation -When first installing InvenTree, initial database configuration must be performed. This is handled by the `install.py` script, which performs the following actions: +It is recommended to set up a clean Python 3.4+ virtual environment first: +`mkdir ~/.env && python3 -m venv ~/.env/InvenTree && source ~/.env/InvenTree/bin/activate` -1. Installs required django packages (requires [pip](https://pypi.python.org/pypi/pip)) +You can then continue running `make setup` (which will be replaced by a proper setup.py soon). This will do the following: + +1. Installs required Python dependencies (requires [pip](https://pypi.python.org/pypi/pip), should be part of your virtual environment by default) 1. Performs initial database setup 1. Updates database tables for all InvenTree components -This script can also be used to update the installation if changes have been made to the database configuration. +This command can also be used to update the installation if changes have been made to the database configuration. -To create an initial user account, run the command `python InvenTree/manage.py createsuperuser` +To create an initial user account, run the command `make superuser`. ## Documentation For project code documentation, refer to the online [documentation](http://inventree.readthedocs.io/en/latest/) (auto-generated) ## Coding Style -All python code should conform to the [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide. Run the *pep_check.py* script which will compare all source (.py) files against the PEP 8 style. +If you'd like to contribute, install our development dependencies using `make develop`. +All Python code should conform to the [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide. Run `make style` which will compare all source (.py) files against the PEP 8 style. Tests can be run using `make test`. diff --git a/install.py b/install.py deleted file mode 100644 index 090fdd3e79..0000000000 --- a/install.py +++ /dev/null @@ -1,44 +0,0 @@ -from __future__ import print_function - -import subprocess -import argparse - -def manage(*arg): - args = ["python", "InvenTree/manage.py"] - - for a in arg: - args.append(a) - - subprocess.call(args) - -parser = argparse.ArgumentParser(description="Install InvenTree inventory management system") - -parser.add_argument('-u', '--update', help='Update only, do not try to install required components', action='store_true') - -args = parser.parse_args() - -# If 'update' is specified, don't perform initial installation -if not args.update: - # Install django requirements - subprocess.call(["pip", "install", "django", "-q"]) - subprocess.call(["pip", "install", "djangorestframework", "-q"]) - - # Initial database setup - manage("migrate") - -# Make migrations for all apps -manage("makemigrations", "part") -manage("makemigrations", "stock") -manage("makemigrations", "supplier") -manage("makemigrations", "project") -manage("makemigrations", "track") - -# Update the database -manage("migrate") - -# Check for errors -manage("check") - -if not args.update: - print("\n\nAdmin account:\nIf a superuser is not already installed,") - print("run the command 'python InvenTree/manage.py createsuperuser'") diff --git a/pep_check.py b/pep_check.py deleted file mode 100644 index 71ce27db68..0000000000 --- a/pep_check.py +++ /dev/null @@ -1,12 +0,0 @@ -""" -Checks all source files (.py) against PEP8 coding style. -The following rules are ignored: - - W293 - blank lines contain whitespace - - E501 - line too long (82 characters) - -Run this script before submitting a Pull-Request to check your code. -""" - -import subprocess - -subprocess.call(['pep8', '--exclude=migrations', '--ignore=W293,E501', 'InvenTree']) diff --git a/requirements/base.txt b/requirements/base.txt new file mode 100644 index 0000000000..1a4283d80d --- /dev/null +++ b/requirements/base.txt @@ -0,0 +1,2 @@ +Django==1.11 +djangorestframework==3.6.2 diff --git a/requirements/build.txt b/requirements/build.txt new file mode 100644 index 0000000000..c400442ceb --- /dev/null +++ b/requirements/build.txt @@ -0,0 +1,2 @@ +-r base.txt +flake8==3.3.0 diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 0000000000..3ec7263b93 --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,4 @@ +-r build.txt +django-extensions==1.7.8 +graphviz==0.6 +ipython==5.3.0 diff --git a/roadmap.md b/roadmap.md new file mode 100644 index 0000000000..af9964f7b0 --- /dev/null +++ b/roadmap.md @@ -0,0 +1,28 @@ +## InvenTree Roadmap + +### Design Goals + +InvenTree is intened to provide a stand-alone stock-management system that runs completely offline. + +It is designed to be run on a local server, and should not require the use of plugins/scripts that phone-home or load external content. + +(This ignores the use of bespoke plugins that may be implemented down the line, e.g. for OctoPart integration, etc) + +### 0.1 Release + +The goals for the initial release should be limited to the following: + +1. Fully implement a JSON API for the various apps and models +1. Design an initial front-end for querying data using this API + * Single-pase design is preferred, for the sake of responsiveness and intuitive interaction + * Investigate JS/AJAX engine - Angular? Bootstrap? +1. Allow users to view part category tree +1. Allow users to view all parts in a given category +1. "" edit parts +1. "" add new parts + +### TODO + +Research needed! + +django-restful in combination with angular seems the way to go. Extra tools provided via https://github.com/jrief/django-angular diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000..ea418b2daf --- /dev/null +++ b/setup.cfg @@ -0,0 +1,8 @@ +[flake8] +ignore = + # - W293 - blank lines contain whitespace + W293, + # - E501 - line too long (82 characters) + E501 +exclude = .git,__pycache__ +max-complexity = 10