From: Brandon King Date: Wed, 22 Apr 2009 19:00:00 +0000 (+0000) Subject: Now using django-reversion to audit changes to django objects. X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=cda349428c1bce12c7c714906d91b2598906722c Now using django-reversion to audit changes to django objects. --- diff --git a/README b/README index 5f97167..1a73ad5 100644 --- a/README +++ b/README @@ -3,5 +3,6 @@ Authors: * Brandon W. King Debian Dependencies: - * python-django >= 1.0.x + * python-django >= 1.0.2 + * django-reversion == 1.1.1 * python-json diff --git a/samplebc/samples/admin.py b/samplebc/samples/admin.py index 9a5dae2..05fc92e 100644 --- a/samplebc/samples/admin.py +++ b/samplebc/samples/admin.py @@ -1,19 +1,20 @@ from django.contrib import admin from samplebc.samples.models import Owner, Sample, Freezer, Container, SampleType +from reversion.admin import VersionAdmin -class OwnerAdmin(admin.ModelAdmin): +class OwnerAdmin(VersionAdmin): pass -class SampleAdmin(admin.ModelAdmin): +class SampleAdmin(VersionAdmin): pass -class FreezerAdmin(admin.ModelAdmin): +class FreezerAdmin(VersionAdmin): pass -class ContainerAdmin(admin.ModelAdmin): +class ContainerAdmin(VersionAdmin): pass -class SampleTypeAdmin(admin.ModelAdmin): +class SampleTypeAdmin(VersionAdmin): pass diff --git a/samplebc/samples/models.py b/samplebc/samples/models.py index 8d53407..86ed323 100644 --- a/samplebc/samples/models.py +++ b/samplebc/samples/models.py @@ -1,14 +1,20 @@ from django.db import models +from django.db.models import signals +from django.contrib.auth.models import User, Group -# Create your models here. +#AUDIT_TYPES = [('Create', 'Create'), +# ('Update', 'Update'), +# ('Delete', 'Delete')] EXP_TYPES = [('RNASeq', 'RNASeq'), ('ChIPSeq','ChIPSeq'), ('DeNovoSeq','DeNovoSeq'), ('MethylSeq','MethylSeq')] + FREEZER_BUILDINGS = [('Kerckhoff', 'Kerckhoff')] + class Owner(models.Model): name = models.CharField(max_length=32) @@ -23,6 +29,8 @@ class Freezer(models.Model): loc_desc = models.CharField(max_length=256, blank=True, null=True) temperature = models.FloatField(help_text='Celsius') + notes = models.TextField(blank=True, null=True) + uuid = models.CharField(max_length=32, unique=True) def __unicode__(self): @@ -31,7 +39,7 @@ class Freezer(models.Model): @models.permalink def get_absolute_url(self): return ('samplebc.samples.views.freezer_summary', [str(self.uuid)]) - + class SampleType(models.Model): name = models.CharField(max_length=256) @@ -46,6 +54,8 @@ class Container(models.Model): max_items = models.IntegerField() freezer = models.ForeignKey(Freezer) + notes = models.TextField(blank=True, null=True) + uuid = models.CharField(max_length=32, unique=True) def __unicode__(self): @@ -67,6 +77,9 @@ class Sample(models.Model): sampleid = models.CharField(max_length=64, unique=True) sample_type = models.ForeignKey(SampleType) owner = models.ForeignKey(Owner) + + description = models.TextField() + # Concentration in ng/ul concentration = models.FloatField(help_text='ng/ul', blank=True, null=True) volume = models.FloatField(help_text='ul', blank=True, null=True) @@ -78,3 +91,4 @@ class Sample(models.Model): @models.permalink def get_absolute_url(self): return ('samplebc.samples.views.sample_summary', [str(self.sampleid)]) + diff --git a/samplebc/settings.py b/samplebc/settings.py index 4aa9dad..7569b8b 100644 --- a/samplebc/settings.py +++ b/samplebc/settings.py @@ -81,6 +81,7 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', + 'reversion', 'samplebc.samples', 'samplebc.bcmagic' )