Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tests pass

  • Loading branch information...
commit 095148d7eb0419804c251436dc71b1fd4bb17225 1 parent 5145073
@andreysobol authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 testsobol/mainapp/models.py
View
23 testsobol/mainapp/models.py
@@ -1,4 +1,5 @@
from django.db import models
+from django.db.models.signals import post_save, post_delete
from utils import Render
@@ -24,3 +25,25 @@ class Request(models.Model):
date = models.DateTimeField()
url = models.CharField(max_length=250)
ip = models.CharField(max_length=250)
+
+class Log(models.Model):
+ date = models.DateTimeField(auto_now_add=True)
+ model = models.CharField(max_length=250)
+ signal = models.CharField(max_length=250)
+
+def save(sender, **kwargs):
+ if sender != Log:
+ if kwargs['created']:
+ signal='create'
+ else:
+ signal='update'
+
+ log = Log(model = sender.__name__, signal = signal)
+ log.save()
+
+def delete(sender, **kwargs):
+ log = Log(model = sender.__name__, signal = 'delete')
+ log.save()
+
+post_save.connect(save)
+post_delete.connect(delete)
Please sign in to comment.
Something went wrong with that request. Please try again.