summaryrefslogtreecommitdiffstats
path: root/links/models.py
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2011-10-17 01:34:04 +0200
committerGravatar Tom Willemsen2011-10-17 01:34:04 +0200
commit4b29603d79cc1f79c66786684f27ec9abfbaa825 (patch)
tree655c321b7ee3b0cc919ab3b7bf937b50fc13c69c /links/models.py
downloaddotfiles-4b29603d79cc1f79c66786684f27ec9abfbaa825.tar.gz
dotfiles-4b29603d79cc1f79c66786684f27ec9abfbaa825.zip
Initial commit
Diffstat (limited to 'links/models.py')
-rw-r--r--links/models.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/links/models.py b/links/models.py
new file mode 100644
index 0000000..50319a2
--- /dev/null
+++ b/links/models.py
@@ -0,0 +1,35 @@
+from django.db import models
+from main.models import Tag, Activity
+from django.db.models.signals import post_save, post_delete
+
+class Bookmark(models.Model):
+ url = models.URLField(primary_key=True, max_length=255)
+ date = models.DateTimeField(auto_now_add=True)
+ name = models.CharField(max_length=255)
+ description = models.TextField()
+# tags = models.ManyToManyField(Tag, null=True, blank=True)
+ priority = models.IntegerField(null=True, blank=True)
+
+ def __unicode__(self):
+ return self.name
+
+def bookmark_saved_callback(sender, **kwargs):
+ if kwargs['created']:
+ acttype = 'add'
+ else:
+ acttype = 'edit'
+
+ a = Activity(actcategory='link',
+ actdescription=kwargs["instance"].name,
+ acttype = acttype,
+ objpk = kwargs["instance"].pk)
+ a.save()
+
+def bookmark_deleted_callback(sender, **kwargs):
+ a = Activity(actcategory='link',
+ actdescription=kwargs["instance"].name,
+ acttype = 'delete')
+ a.save()
+
+post_save.connect(bookmark_saved_callback, sender=Bookmark)
+post_delete.connect(bookmark_deleted_callback, sender=Bookmark)