summaryrefslogtreecommitdiffstats
path: root/links
diff options
context:
space:
mode:
Diffstat (limited to 'links')
-rw-r--r--links/__init__.py0
-rw-r--r--links/admin.py4
-rw-r--r--links/models.py35
-rw-r--r--links/tests.py16
-rw-r--r--links/urls.py5
-rw-r--r--links/views.py12
6 files changed, 72 insertions, 0 deletions
diff --git a/links/__init__.py b/links/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/links/__init__.py
diff --git a/links/admin.py b/links/admin.py
new file mode 100644
index 0000000..29b8674
--- /dev/null
+++ b/links/admin.py
@@ -0,0 +1,4 @@
+from links.models import Bookmark
+from django.contrib import admin
+
+admin.site.register(Bookmark)
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)
diff --git a/links/tests.py b/links/tests.py
new file mode 100644
index 0000000..501deb7
--- /dev/null
+++ b/links/tests.py
@@ -0,0 +1,16 @@
+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.assertEqual(1 + 1, 2)
diff --git a/links/urls.py b/links/urls.py
new file mode 100644
index 0000000..25d8cc8
--- /dev/null
+++ b/links/urls.py
@@ -0,0 +1,5 @@
+from django.conf.urls.defaults import patterns
+
+urlpatterns = patterns('links.views',
+ (r'^$', 'index'),
+)
diff --git a/links/views.py b/links/views.py
new file mode 100644
index 0000000..fe0d89d
--- /dev/null
+++ b/links/views.py
@@ -0,0 +1,12 @@
+from links.models import Bookmark
+from django.http import HttpResponse
+from django.template import Context, loader
+
+def index(request):
+ bookmark_list = Bookmark.objects.all().order_by("-date")[:100]
+ t = loader.get_template("links/links.html")
+ c = Context({
+ 'bookmarklist': bookmark_list,
+ })
+
+ return HttpResponse(t.render(c))