Changes between Version 18 and Version 19 of AuditTrail
- Timestamp:
- Dec 6, 2008, 1:03:08 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AuditTrail
v18 v19 10 10 11 11 {{{ 12 #!python 12 13 from django.db import models 13 14 import audit … … 63 64 64 65 {{{ 66 #!python 65 67 def some_callback(instance): 66 68 return `random.randrange(1, 99)` + 'trackable_val' … … 81 83 82 84 {{{ 85 #!python 83 86 >>> p_hist = person.history.all() 84 87 [<PersonAudit: John Public as of 2007-08-27 09:29:14>, <PersonAudit: John Public as of 2007-08-27 09:28:57>] … … 96 99 97 100 {{{ 101 #!python 98 102 from django.db import models 99 103 … … 132 136 from django.db import models 133 137 from django.core.exceptions import ImproperlyConfigured 138 from django.contrib import admin 134 139 import copy 135 140 import re … … 139 144 except ImportError: 140 145 settings_audit = None 141 142 146 value_error_re = re.compile("^.+'(.+)'$") 143 147 … … 158 162 def _contribute(sender, **kwargs): 159 163 model = create_audit_model(sender, **self.opts) 164 if self.opts['show_in_admin']: 165 # Enable admin integration 166 # If ModelAdmin needs options or different base class, find 167 # some way to make the commented code work 168 # cls_admin_name = cls.__name__ + 'Admin' 169 # clsAdmin = type(cls_admin_name, (admin.ModelAdmin,),{}) 170 # admin.site.register(cls, clsAdmin) 171 # Otherwise, register class with default ModelAdmin 172 admin.site.register(model) 160 173 descriptor = AuditTrailDescriptor(model._default_manager, sender._meta.pk.attname) 161 174 setattr(sender, name, descriptor) … … 269 282 attrs['_audit_change_type'] = models.CharField(max_length=1) 270 283 271 if 'show_in_admin' in kwargs and kwargs['show_in_admin']:272 # Enable admin integration273 class Admin:274 pass275 attrs['Admin'] = Admin276 277 284 # Copy the fields from the existing model to the audit model 278 285 for field in cls._meta.fields: … … 320 327 tracks_found.append(track_item) 321 328 else: 322 323 329 tracks_found.append(_build_track_field(track_item)) 324 330