aboutsummaryrefslogtreecommitdiffstats
path: root/archive
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-06-24 16:39:42 +0800
committerWeitian LI <liweitianux@gmail.com>2014-06-24 16:39:42 +0800
commited3d74e61300f91818eeff9dad7e9d35c556f75a (patch)
tree62c96fd6e158068567eebb5072406911e99db47d /archive
parenta64eb136b0d8710ff132551f149a39b3a45da1f9 (diff)
downloaddjango-skaschool-ed3d74e61300f91818eeff9dad7e9d35c556f75a.tar.bz2
Added app schedule, tools and archive/templatetags; updated settings.
* Added app 'schedule' to provides a more generic schedule page * Added fake app 'tools' to holds generic utilities * Moved notice/templatetags to tools/templatetags * Small change to archive.models.Archive display format * Added archive/templatetags * Small update to introduction page
Diffstat (limited to 'archive')
-rw-r--r--archive/models.py3
-rw-r--r--archive/templatetags/__init__.py0
-rw-r--r--archive/templatetags/archive_utils.py32
3 files changed, 34 insertions, 1 deletions
diff --git a/archive/models.py b/archive/models.py
index 791750a..47903e4 100644
--- a/archive/models.py
+++ b/archive/models.py
@@ -30,7 +30,8 @@ class Archive(models.Model):
ordering = ['category', '-pubtime', 'id']
def __unicode__(self):
- return u'Archive %s: %s' % (self.category.name, self.title)
+ return u'Archive #%s: (%s) %s' % (
+ self.id, self.category.name, self.title)
def show_pubtime(self):
# used in 'list_notice.html' template
diff --git a/archive/templatetags/__init__.py b/archive/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/archive/templatetags/__init__.py
diff --git a/archive/templatetags/archive_utils.py b/archive/templatetags/archive_utils.py
new file mode 100644
index 0000000..1f44fd1
--- /dev/null
+++ b/archive/templatetags/archive_utils.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+#
+# utilities to use with app 'archive'
+#
+
+from django import template
+
+from archive.models import Archive
+
+
+register = template.Library()
+
+@register.filter
+def get_archive_title(id):
+ archive = Archive.objects.get(id=id)
+ return archive.title
+
+@register.filter
+def get_archive_description(id):
+ archive = Archive.objects.get(id=id)
+ return archive.description
+
+@register.filter
+def get_archive_url(id):
+ archive = Archive.objects.get(id=id)
+ return archive.file.url
+
+@register.filter
+def get_archive_category(id):
+ archive = Archive.objects.get(id=id)
+ return archive.category.name
+