Skip to content
Merged
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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ deb_dist
.coverage
coverage.xml
pep8.txt
Pipfile
Pipfile.lock
27 changes: 1 addition & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
language: python
python:
- 2.7
env:
- DJANGO=">=1.6,<1.7"
- DJANGO=">=1.7,<1.8"
- DJANGO=">=1.8,<1.9"
- DJANGO=">=1.9,<1.10"
- DJANGO=">=1.10,<1.11"
- DJANGO=">=1.11,<1.12"
install:
- pip install gitversion
- pip install "Django${DJANGO}"
- pip install .
- pip install coveralls
script:
- python setup.py test
after_success:
- coveralls
matrix:
include:
- python: 2.6
env: DJANGO=">=1.4,<1.5"
- python: 3.3
- python: 3.4
env: DJANGO=">=1.8,<1.9"
- python: 3.4
env: DJANGO=">=1.9,<1.10"
Expand All @@ -33,14 +19,3 @@ matrix:
env: DJANGO=">=1.8,<1.9"
- python: pypy
env: DJANGO=">=1.9,<1.10"
deploy:
provider: pypi
user: ocadotechnology
password:
secure: kdfRG0+3xsH4DSlTtVi8WT8/vhTzlfC58c0gP/MhsrN7k7ffGs6fjxkUoKpIGPZXV+v9kI5elYkFs4wInOrtq5ZgPHKMTpaHxQLrDtCkurYY7mD0e9KP2xVjvPEDQxDrynn1/x75Doi0Oe9StJ5E2odUJ0HcOwqhlKXJuOZa19M=
distributions: "bdist_wheel sdist"
on:
all_branches: true
repo: ocadotechnology/django-closuretree
tags: true
condition: "$DJANGO = '>=1.11,<1.12'"
39 changes: 13 additions & 26 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,20 @@ django-closuretree
******************


.. image:: https://travis-ci.org/ocadotechnology/django-closuretree.svg
:target: https://travis-ci.org/ocadotechnology/django-closuretree
.. image:: https://travis-ci.com/ykiu/django-closuretree.svg?branch=master
:target: https://travis-ci.com/ykiu/django-closuretree
:alt: Build Status
.. image:: https://landscape.io/github/ocadotechnology/django-closuretree/master/landscape.svg?style=flat
:target: https://landscape.io/github/ocadotechnology/django-closuretree/master
:alt: Code Health Badge
.. image:: https://readthedocs.org/projects/django-closuretree/badge/?version=latest
:target: http://django-closuretree.readthedocs.org/en/latest/
:alt: Documentation Status
.. image:: https://coveralls.io/repos/ocadotechnology/django-closuretree/badge.svg
:target: https://coveralls.io/r/ocadotechnology/django-closuretree
.. image:: https://landscape.io/github/ykiu/django-closuretree/master/landscape.svg?style=flat
:target: https://landscape.io/github/ykiu/django-closuretree/master
:alt: Code Health
.. image:: https://coveralls.io/repos/github/ykiu/django-closuretree/badge.svg?branch=master
:target: https://coveralls.io/github/ykiu/django-closuretree?branch=master
:alt: Test Coverage
.. image:: https://pypip.in/v/django-closuretree/badge.svg?style=flat
:target: https://pypi.python.org/pypi/django-closuretree/
:alt: Version Badge
.. image:: https://pypip.in/license/django-closuretree/badge.svg?style=flat
:target: https://pypi.python.org/pypi/django-closuretree/
:alt: License Badge


``django-closuretree`` is an implementation of the `closure tree <http://homepages.inf.ed.ac.uk/libkin/papers/tc-sql.pdf>`_ technique for `Django <https://djangoproject.com>`_ applications designed to provide efficient querying of `tree-based structures <http://en.wikipedia.org/wiki/Tree_%28data_structure%29>`_ in a relational database. Its goal is to reduce the number of queries required when querying the children or parents of a given object.

This is a folk of `the original work by Ocado Technology<https://github.com/ocadotechnology/django-closuretree>`_ with a few extra features.

Given the following model:

.. code-block:: python
Expand Down Expand Up @@ -60,7 +52,7 @@ A single query will obtain all the descendants.
Quick Start
===========

* Install ``django-closuretree`` with ``pip install django-closuretree``.
* Install ``django-closuretree`` with ``pip install git+https://github.com/ykiu/django-closuretree.git``.
* Inherit your models from ``closuretree.models.ClosureModel`` instead of ``django.db.models.Model``.

That's it. You can now use ``get_descendants()`` and ``get_ancestors()`` on a model instance.
Expand All @@ -75,14 +67,9 @@ If you're adding this to an existing application that already has data in the da
Contributing
============

The following workflow assumes you are using pipenv.

1. Fork the repo and create your branch from master.
2. Enter into a virtual environment (``pipenv shell``).
3. Install gitversion (``pipenv install gitversion``).
4. Install the remaining dependencies (``setup.py install``).
5. Do your work.
6. Run tests (``setup.py test``).
7. Make a PR.
2. Do your work.
3. Run tests (``setup.py test``). Dependencies will be installed into `./.eggs/`. No need to explicitly activate a virtual environment.
4. Make a PR.

We ask that contributors adhere to `PEP8 <https://www.python.org/dev/peps/pep-0008/>`_ standards, and include full tests for all their code.
9 changes: 7 additions & 2 deletions closuretree/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
from gitversion import rewritable_git_version
__VERSION__ = rewritable_git_version(__file__)
from pkg_resources import get_distribution, DistributionNotFound

try:
__VERSION__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
pass
14 changes: 0 additions & 14 deletions run_tests.py

This file was deleted.

35 changes: 24 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,47 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Setup file for django-closuretree."""
from setuptools import setup, find_packages
"""Setup file for django-closuretree.

from closuretree.version import __VERSION__
See also:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""
from setuptools import setup, find_packages

setup(
name='django-closuretree',
version=__VERSION__,

# getting version info from git tags
use_scm_version = True,
# (the following will be installed into ./.eggs/)
setup_requires=['setuptools_scm'],

# specifying packages to install
packages=find_packages(),

# dependencies
# (the following will be installed into ./.eggs/)
install_requires=['django >= 1.8, < 2.0'],

# test
# (the following will be installed into ./.eggs/)
tests_require=['django-setuptest >= 0.2'],
test_suite='setuptest.setuptest.SetupTestSuite',

# meta data
author='Mike Bryant',
author_email='mike.bryant@ocado.com',
description='Efficient tree-based datastructure for Django',
long_description=open('README.rst').read(),
url='https://github.com/ocadotechnology/django-closuretree/',
install_requires=[
'django >= 1.4, < 1.12',
'django-autoconfig',
],
tests_require=['django-setuptest >= 0.2'],
test_suite='setuptest.setuptest.SetupTestSuite',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
Expand Down
1 change: 0 additions & 1 deletion test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@
},
}
INSTALLED_APPS = ['closuretree']
ROOT_URLCONF = 'django_autoconfig.autourlconf'
SECRET_KEY = 'foobar'