From da4cc8417e9f904bb5e1b5a8f6a0c81a0589f5ee Mon Sep 17 00:00:00 2001 From: erikvw Date: Tue, 1 May 2018 19:49:22 +0200 Subject: [PATCH 1/6] flake8, travis --- .gitignore | 30 +++++++++++++++++++--- .travis.yml | 39 +++++++++++++---------------- django_revision/modeladmin_mixin.py | 3 ++- django_revision/urls.py | 2 +- setup.cfg | 6 ++--- 5 files changed, 50 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 3e89460..9ee9511 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,32 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] +.pypirc +etc/* +.venv/* + +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] + +# Session +Session.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags + +.settings .project .pydevproject -.settings +test-* +db.sqlite3 +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +_build/ # C extensions *.so diff --git a/.travis.yml b/.travis.yml index 769b691..2832d4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,23 @@ language: python python: - - "2.7" -# - "3.2" - - "3.3" - - "3.4" -# - "nightly" -env: - - DJANGO_VERSION=1.6 - - DJANGO_VERSION=1.7 - - DJANGO_VERSION=1.8 - +- 3.6 +services: +- mysql +branches: + only: + - develop install: - - pip install -q Django==$DJANGO_VERSION --use-mirrors - - pip install flake8 --use-mirrors - - pip install coveralls --use-mirrors - - pip install -q -r requirements.txt --use-mirrors - +- pip install --upgrade pip +- pip install -r requirements.txt +- pip install flake8 +- pip install coveralls before_script: - - flake8 django_revision - -script: - - coverage run --source=django_revision manage.py test - +- flake8 django_revision +- mysql -e 'create database edc character set utf8;' +script: +- coverage run --source=django_revision manage.py test after_success: - - coveralls +- coveralls +notifications: + slack: + secure: sWKtDrh479nPPVsjYCSKK7+DjSfZCa32AwKfEHkU5B2EaYJyugQp+y1xmo7d+kTHEY2g/IRzuJsCDU+m0jR9j+jWys84hGms8Wz6DUX6KWmkiqi6RwNe71lwA9uFaV8d5m0CTFUraZ182lKPv0zUjuMN0M1TzQ6hgSN5fRitNMpi8tLaml4OvhZhiD/dHJjv5j522vgCdfhsQmxDosk05qFO54ac13IRYjXpzs6OkHqOGxmfIxfIfFre8ghJ5A3UYsJJzayhXGh5lPMTRfhI0h41q+G3KZ3z2KTarXWf1Klmu2riuw4Dqzo3eQkCR9q/XatN434QCvTYvy9NBfHA8iOetOlB+ENT2RgVOSwZfe0Lwe9/rL6TwaTqv8ev6z1nGTfreZHvSSKbfc8iK6i0y9VblmTkkaW/jpgN5NWztmvGH6ZKOHla7SsMjBuA5K9p/P846LXmAkKbU+Q+NItzK533RIOEaXyS+8XizO8fik4qt1hpEX5wEvhMBqVRza6bAge8knYV/UP87cguWCAMIhpWBttEIcdTAVQvGhPsb/rn/igOKRYnDyMQIStR34HdAUzoEWUv3ye2FmQeWNtJ1+U8W3os4KlPJ/iIpsyR9Snrx42CuWTJ9TQV9wtRxYwiJFYshNJFudTPLABbNxVLIxSvDQdJunaxYn/7g16FTUk= diff --git a/django_revision/modeladmin_mixin.py b/django_revision/modeladmin_mixin.py index c5e3a9d..357f26d 100644 --- a/django_revision/modeladmin_mixin.py +++ b/django_revision/modeladmin_mixin.py @@ -16,7 +16,8 @@ class ModelAdminRevisionMixin: def add_view(self, request, form_url='', extra_context=None): extra_context = extra_context or {} extra_context.update({'revision': site_revision.revision}) - return super(ModelAdminRevisionMixin, self).add_view(request, form_url=form_url, extra_context=extra_context) + return super(ModelAdminRevisionMixin, self).add_view( + request, form_url=form_url, extra_context=extra_context) def change_view(self, request, object_id, form_url='', extra_context=None): extra_context = extra_context or {} diff --git a/django_revision/urls.py b/django_revision/urls.py index b70eeb4..3df7b23 100644 --- a/django_revision/urls.py +++ b/django_revision/urls.py @@ -2,5 +2,5 @@ from django.urls.conf import path urlpatterns = [ - path(r'^admin/', admin.site.urls), + path(r'admin/', admin.site.urls), ] diff --git a/setup.cfg b/setup.cfg index 8b4bb04..606cc1f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [flake8] -ignore = E226,E302,E41,F401 -max-line-length = 120 +ignore = E226,E302,E41,F401,W503 +max-line-length = 95 max-complexity = 10 -exclude = django_revision/tests/*,edc_example/* +exclude = django_revision/tests/*,.venv/* From 5f0c7c4a96c9707f500d8bd979e4adf22c0e90ba Mon Sep 17 00:00:00 2001 From: erikvw Date: Tue, 1 May 2018 19:55:48 +0200 Subject: [PATCH 2/6] travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2832d4c..d61067c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,4 +20,4 @@ after_success: - coveralls notifications: slack: - secure: sWKtDrh479nPPVsjYCSKK7+DjSfZCa32AwKfEHkU5B2EaYJyugQp+y1xmo7d+kTHEY2g/IRzuJsCDU+m0jR9j+jWys84hGms8Wz6DUX6KWmkiqi6RwNe71lwA9uFaV8d5m0CTFUraZ182lKPv0zUjuMN0M1TzQ6hgSN5fRitNMpi8tLaml4OvhZhiD/dHJjv5j522vgCdfhsQmxDosk05qFO54ac13IRYjXpzs6OkHqOGxmfIxfIfFre8ghJ5A3UYsJJzayhXGh5lPMTRfhI0h41q+G3KZ3z2KTarXWf1Klmu2riuw4Dqzo3eQkCR9q/XatN434QCvTYvy9NBfHA8iOetOlB+ENT2RgVOSwZfe0Lwe9/rL6TwaTqv8ev6z1nGTfreZHvSSKbfc8iK6i0y9VblmTkkaW/jpgN5NWztmvGH6ZKOHla7SsMjBuA5K9p/P846LXmAkKbU+Q+NItzK533RIOEaXyS+8XizO8fik4qt1hpEX5wEvhMBqVRza6bAge8knYV/UP87cguWCAMIhpWBttEIcdTAVQvGhPsb/rn/igOKRYnDyMQIStR34HdAUzoEWUv3ye2FmQeWNtJ1+U8W3os4KlPJ/iIpsyR9Snrx42CuWTJ9TQV9wtRxYwiJFYshNJFudTPLABbNxVLIxSvDQdJunaxYn/7g16FTUk= + secure: TrzrTrCafFN7dqD/jjS0qLsLrkkwprOquFStWvHbPQ/sX44HODyDH7A8duu5f84WnPVYV0d+nHNDjJ6/6pBIyKDmwEt0bZblZSb4vQ9q1D60Qocs3gMPLQU8g2U5SZLfk5jWCKWN1JPLkP5ElKazUdNMOv4E0o58m1DmdO8WFGK1aO7geTL6rjf1qLdXdbj5q4gvRjMKZ8tv5HxARMYg1heqeTHO1t9CxXJWfGrSn4NaHNUcnWW6hCaBtZzeKtFPbUzpv2sDxpw7hEx3gNyGD5+HdmfrJpR9WtbIHfQKN/P/dbLq4cXS6zX+iE23BDjGSmeGpJrzCt/FHaKwwaFr5Aa0Jlms1ciijd/bLPCjey1lHIkYsmp298j2ow1P4JvTj9wlKJb25vyUFlHgYlQZRuUZRfFa9jPxVzslbfIVi1cgHRbW2psBHp0rHrZPKdiYW2HpGwNlgtkLaVtR7x6xJvHDG0wjmMQSnyP1IcRWMtMv63RqEC28YQGGknl7Uy+iyxxixnUauK+Z/mtAY7LrInvj66LV3oKdPFsPuIX8cjttJEyALwZn0GoS837kgJ48neoJyQcRudLDIgSa7Bh4WNoB4mWB9ZFz+cqPXV8JDnE84gHSqcdz8Dp6WCPTLxtTKp8nhS3I1/Omu7r5RgdhIqRzmE1R/VkuH4CLWzsLCaA= From 2116d15e91a91d5432e5b3fd85775d768233950f Mon Sep 17 00:00:00 2001 From: erikvw Date: Tue, 1 May 2018 19:58:41 +0200 Subject: [PATCH 3/6] readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fd4b17..fc10238 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[![Build Status](https://travis-ci.org/erikvw/django-revision.svg?branch=master)](https://travis-ci.org/erikvw/django-revision)[![Coverage Status](https://coveralls.io/repos/erikvw/django-revision/badge.svg)](https://coveralls.io/r/erikvw/django-revision) +[![Build Status](https://travis-ci.org/erikvw/django-revision.svg?branch=develop)](https://travis-ci.org/erikvw/django-revision) +[![Coverage Status](https://coveralls.io/repos/erikvw/django-revision/badge.svg)](https://coveralls.io/r/erikvw/django-revision) # django-revision From 9ca98b416bb78fb3aa57d310296204aae9399e7d Mon Sep 17 00:00:00 2001 From: Erik van Widenfelt Date: Tue, 19 Jun 2018 11:07:20 +0200 Subject: [PATCH 4/6] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fc10238..b19de9f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@ Add a Django field class to your models to track the git revision with every model instance saved. -Uses `GitPython` (does not work on python version 3.2.) +python 3.6, Django 2.0+ + +Uses `GitPython`. For example: From 8eece0d51acaa82d79be4e360988a5b3c9229fb0 Mon Sep 17 00:00:00 2001 From: erikvw Date: Fri, 20 Jul 2018 17:39:24 +0200 Subject: [PATCH 5/6] setup, convert to rst --- MANIFEST.in | 2 +- README.md => README.rst | 52 ++++++++++++++++++++++++++++++----------- VERSION | 1 + setup.py | 18 +++++++------- 4 files changed, 50 insertions(+), 23 deletions(-) rename README.md => README.rst (58%) create mode 100644 VERSION diff --git a/MANIFEST.in b/MANIFEST.in index 5e73078..2e6e4ee 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include AUTHORS CHANGES README.md LICENCE +include AUTHORS CHANGES README.rst LICENCE VERSION recursive-include docs * recursive-exclude edc_example/* recursive-exclude etc/* diff --git a/README.md b/README.rst similarity index 58% rename from README.md rename to README.rst index fc10238..c7da918 100644 --- a/README.md +++ b/README.rst @@ -1,14 +1,17 @@ -[![Build Status](https://travis-ci.org/erikvw/django-revision.svg?branch=develop)](https://travis-ci.org/erikvw/django-revision) -[![Coverage Status](https://coveralls.io/repos/erikvw/django-revision/badge.svg)](https://coveralls.io/r/erikvw/django-revision) +|pypi| |travis| |coverage| -# django-revision + +django-revision +--------------- Add a Django field class to your models to track the git revision with every model instance saved. -Uses `GitPython` (does not work on python version 3.2.) +Uses ``GitPython`` (does not work on python version 3.2.) For example: +.. code-block:: python + from django.db import models from django_revision import RevisionField @@ -17,7 +20,7 @@ For example: revision = RevisionField() -... then +.. code-block:: python >>> test_model = TestModel.objects.create() >>>test_model.revision @@ -25,12 +28,16 @@ For example: If the source is modified after the git tag was applied: +.. code-block:: python + >>> test_model = TestModel.objects.create() >>>test_model.revision >>> '0.1dev0-35-ge9f632e:develop:e9f632e92143c53411290b576487f48c15156603' Reference git information from anywhere in your app: +.. code-block:: python + >>> from django_revision import site_revision >>> site_revision.tag '0.1dev0' @@ -41,30 +48,37 @@ Reference git information from anywhere in your app: For research trial data, we need to track the source code revision at time of data collection. We deploy our source as a git branch and django-revision picks up the tag:branch:commit and updates each saved model instance as data is collected. -### Installation - -Get the latest version: - - pip install git+https://github.com/erikvw/django-revision@develop#egg=django_revision +Installation +------------ Add to settings: +.. code-block:: python + INSTALLED_APPS = [ ... 'django_revision.apps.AppConfig', ... ] -If your _git_ working directory is something other than `settings.BASE_DIR` add `GIT_DIR` to `settings` with the path to your _git_ working directory. For example: +If your `git` working directory is something other than ``settings.BASE_DIR`` add ``GIT_DIR`` to ``settings`` with the path to your `git` working directory. For example: + +.. code-block:: python GIT_DIR = BASE_DIR.ancestor(2) -If you have a deployment case where the source folder is not a _git_ repo, you can set the revision manually in settings: +If you have a deployment case where the source folder is not a `git` repo, you can set the revision manually in settings: +.. code-block:: python + REVISION = '0.1.3' -### Using in a View and Template -In the view's `get_context_data` set a context attribute to `revision.tag` or just use the `RevisionMixin`: +Using in a View and Template +---------------------------- + +In the view's ``get_context_data`` set a context attribute to ``revision.tag`` or just use the ``RevisionMixin``: + +.. code-block:: python from django_revision.views import RevisionMixin @@ -73,6 +87,8 @@ In the view's `get_context_data` set a context attribute to `revision.tag` or ju In your template: +.. code-block:: python + {% block footer %}
@@ -83,3 +99,11 @@ In your template:
{% endblock footer %} +.. |pypi| image:: https://img.shields.io/pypi/v/django-revision.svg + :target: https://pypi.python.org/pypi/django-revision + +.. |travis| image:: https://travis-ci.org/clinicedc/django-revision.svg?branch=develop + :target: https://travis-ci.org/clinicedc/django-revision + +.. |coverage| image:: https://coveralls.io/repos/github/clinicedc/django-revision/badge.svg?branch=develop + :target: https://coveralls.io/github/clinicedc/django-revision?branch=develop diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..f1f1232 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.14 \ No newline at end of file diff --git a/setup.py b/setup.py index 3ecb83a..cf593aa 100644 --- a/setup.py +++ b/setup.py @@ -4,22 +4,25 @@ from setuptools import setup from setuptools import find_packages -with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme: +with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme: README = readme.read() +with open(os.path.join(os.path.dirname(__file__), 'VERSION')) as f: + VERSION = f.read() + # allow setup.py to be run from any path os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( name='django-revision', - version='0.1.14', + version=VERSION, author=u'Erik van Widenfelt', author_email='ew2789@gmail.com', packages=find_packages(), include_package_data=True, url='http://github/erikvw/django-revision', license='GPL licence, see LICENCE', - description='Add a Django field class to your models to track the git revision with every model instance saved.', + description='Track the git revision with every model instance saved.', long_description=README, zip_safe=False, keywords='django fields git', @@ -30,12 +33,11 @@ 'Environment :: Web Environment', 'Framework :: Django', 'Intended Audience :: Developers', - 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', ], From e9e0f96f699458be299023dc119dde22145b929b Mon Sep 17 00:00:00 2001 From: erikvw Date: Fri, 20 Jul 2018 17:41:23 +0200 Subject: [PATCH 6/6] bump version -> 0.1.15 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index f1f1232..c34958a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.14 \ No newline at end of file +0.1.15