Skip to content

Commit

Permalink
update README, add example models for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jul 3, 2016
1 parent 5a35bee commit 954f614
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,26 @@ For example:

revision = RevisionField()

... then

>>> test_model = TestModel.objects.create()
>>>test_model.revision
'0.1dev0'

If the source is modified after the git tag was applied:

>>> test_model = TestModel.objects.create()
>>>test_model.revision
>>> '0.1dev0-35-ge9f632e:develop:e9f632e92143c53411290b576487f48c15156603'

Reference git information from anywhere in your app:

>>> from django_revision import site_revision
>>> site_revision.tag
'1.0'
'0.1dev0'
>>>site_revision.revision
'master:4c9c7f4f40e8db109d2b7b6d234defbe9d065d74'
'0.1dev0'


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.
Expand Down
3 changes: 2 additions & 1 deletion django_revision/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_revision'
'django_revision',
'example'
)

MIDDLEWARE_CLASSES = (
Expand Down
11 changes: 2 additions & 9 deletions django_revision/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
from git.exc import InvalidGitRepositoryError

from django.conf import settings
from django.db import models
from django.test.testcases import TransactionTestCase
from django_revision import site_revision, Revision, RevisionField
from django_revision import site_revision, Revision


class TestModel(models.Model):

revision_field = RevisionField()

class Meta:
app_label = 'django_revision'
from example.models import TestModel


class TestRevision(TransactionTestCase):
Expand Down
Empty file added example/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions example/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.db import models

from django_revision import RevisionField


class TestModel(models.Model):

revision_field = RevisionField()

class Meta:
app_label = 'example'

0 comments on commit 954f614

Please sign in to comment.