models.py
1.42 KB
# -*- coding: utf-8 -*-
from django.contrib.auth.models import User
from django.db.models import Model, CharField, DateTimeField, ForeignKey, \
TextField, IntegerField
from dictionary.models import Lexeme
from patterns.models import Pattern
class History(Model):
table_name = CharField(max_length=120, db_column='table_name_')
column_name = CharField(
max_length=120, db_column='column_name_', blank=True)
timestamp = DateTimeField(db_column='timestamp_')
user = ForeignKey(User, db_column='user_id_', db_index=True)
old_value = TextField(db_column='old_value_', blank=True)
new_value = TextField(db_column='new_value_', blank=True)
lexeme = ForeignKey(
Lexeme, db_column='lexeme_id_', null=True, blank=True, db_index=True)
pattern = ForeignKey(
Pattern, db_column='pattern_id_', null=True, blank=True, db_index=True)
row_id = IntegerField(db_column='id_')
operation = CharField(max_length=120, db_column='operation_')
table_oid = IntegerField(db_column='table_oid_')
column_ord = IntegerField(db_column='ordinal_position_of_column_')
transaction_began = DateTimeField(
db_column='transaction_began_', db_index=True)
def __unicode__(self):
return '%s %s.%s %s -> %s' % (
self.operation, self.table_name, self.column_name,
repr(self.old_value),
repr(self.new_value))
class Meta:
db_table = 'history'