Added a Log table to keep track of changes
svn: r19838
This commit is contained in:
parent
be81cc1617
commit
974312059f
@ -839,6 +839,17 @@ class BaseRef(models.Model):
|
||||
#attributes = models.ManyToManyField("Attribute", null=True)
|
||||
private = models.BooleanField()
|
||||
|
||||
class Log(BaseRef):
|
||||
log_type = models.CharField(max_length=10) # edit, delete, add
|
||||
reason = models.TextField() # must be filled in
|
||||
cache = models.TextField(blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
"%s: %s on %s by %s" % (self.log_type,
|
||||
self.referenced_by,
|
||||
self.last_changed,
|
||||
self.last_changed_by)
|
||||
|
||||
class NoteRef(BaseRef):
|
||||
ref_object = models.ForeignKey('Note')
|
||||
|
||||
|
@ -749,7 +749,7 @@ class DjangoInterface(object):
|
||||
self.add_family_ref(person, family_handle)
|
||||
|
||||
## Export reference objects:
|
||||
|
||||
|
||||
def add_person_ref_default(self, obj, person, private=False, desc=None):
|
||||
count = person.references.count()
|
||||
person_ref = models.PersonRef(referenced_by=obj,
|
||||
|
@ -1207,3 +1207,18 @@ def parse_styled_text(text):
|
||||
parser.close()
|
||||
return (parser.text(), parser.tags())
|
||||
|
||||
def make_log(obj, log_type, last_changed_by, reason, cache):
|
||||
"""
|
||||
Makes a record of the changes performed.
|
||||
"""
|
||||
# Can also add private
|
||||
last_changed = datetime.datetime.now()
|
||||
log = models.Log(referenced_by=obj,
|
||||
log_type=log_type,
|
||||
order=0,
|
||||
reason=reason,
|
||||
last_changed=last_changed,
|
||||
last_changed_by=last_changed_by,
|
||||
cache=cache)
|
||||
log.save()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user