Some more stuff.
diff -r aa2b41c5212b -r c0d0779b266f gpp/templates/weblinks/latest_tag.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/templates/weblinks/latest_tag.html Sun Apr 19 20:41:37 2009 +0000
@@ -0,0 +1,10 @@
+
New Links
+{% if links %}
+
+ {% for link in links %}
+ - {{ link.title }}
+ {% endfor %}
+
+{% else %}
+
No links at this time.
+{% endif %}
diff -r aa2b41c5212b -r c0d0779b266f gpp/templates/weblinks/link_detail.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/templates/weblinks/link_detail.html Sun Apr 19 20:41:37 2009 +0000
@@ -0,0 +1,8 @@
+{% extends 'weblinks/base.html' %}
+{% block title %}Web Links: {{ link.title }}{% endblock %}
+{% block weblinks_content %}
+
Link Details: {{ link.title }}
+
+{% include 'weblinks/link.html' %}
+
+{% endblock %}
diff -r aa2b41c5212b -r c0d0779b266f gpp/weblinks/models.py
--- a/gpp/weblinks/models.py Sun Apr 19 20:10:00 2009 +0000
+++ b/gpp/weblinks/models.py Sun Apr 19 20:41:37 2009 +0000
@@ -43,11 +43,15 @@
objects = models.Manager()
public_objects = PublicLinkManager()
+ class Meta:
+ ordering = ('title', )
+
def __unicode__(self):
return self.title
- class Meta:
- ordering = ('title', )
+ @models.permalink
+ def get_absolute_url(self):
+ return ('weblinks-link_detail', [str(self.id)])
class FlaggedLinkManager(models.Manager):
diff -r aa2b41c5212b -r c0d0779b266f gpp/weblinks/templatetags/weblinks_tags.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/weblinks/templatetags/weblinks_tags.py Sun Apr 19 20:41:37 2009 +0000
@@ -0,0 +1,14 @@
+"""
+Template tags for the weblinks application.
+"""
+from django import template
+from weblinks.models import Link
+
+register = template.Library()
+
+@register.inclusion_tag('weblinks/latest_tag.html')
+def latest_weblinks():
+ links = Link.public_objects.order_by('-date_added')[:10]
+ return {
+ 'links': links,
+ }
diff -r aa2b41c5212b -r c0d0779b266f gpp/weblinks/urls.py
--- a/gpp/weblinks/urls.py Sun Apr 19 20:10:00 2009 +0000
+++ b/gpp/weblinks/urls.py Sun Apr 19 20:41:37 2009 +0000
@@ -8,6 +8,9 @@
url(r'^category/(?P
\d+)/(?Ptitle|date|rating|hits)/page/(?P\d+)/$',
'view_links',
name='weblinks-view_links'),
+ url(r'^detail/(\d+)/$',
+ 'link_detail',
+ name='weblinks-link_detail'),
(r'^new/$', 'new_links'),
(r'^popular/$', 'popular_links'),
(r'^random/$', 'random_link'),
diff -r aa2b41c5212b -r c0d0779b266f gpp/weblinks/views.py
--- a/gpp/weblinks/views.py Sun Apr 19 20:10:00 2009 +0000
+++ b/gpp/weblinks/views.py Sun Apr 19 20:41:37 2009 +0000
@@ -224,3 +224,13 @@
'search_form': SearchForm(),
},
context_instance = RequestContext(request))
+
+#######################################################################
+
+def link_detail(request, id):
+ link = get_object_or_404(Link, pk=id)
+ return render_to_response('weblinks/link_detail.html', {
+ 'link': link,
+ 'search_form': SearchForm(),
+ },
+ context_instance = RequestContext(request))