Mercurial > public > sg101
changeset 23:a5f27f25fa52
Added a latest_downloads template tag. Made the comments view the details view for a download. Changed get_absolute_url to point to this new view.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 19 Apr 2009 21:16:59 +0000 (2009-04-19) |
parents | 42f22c56ab05 |
children | c284c0e5c5db |
files | gpp/downloads/models.py gpp/downloads/templatetags/downloads_tags.py gpp/downloads/urls.py gpp/downloads/views.py gpp/templates/downloads/download.html gpp/templates/downloads/download_comments.html gpp/templates/downloads/download_detail.html gpp/templates/downloads/latest_tag.html gpp/templates/home.html |
diffstat | 9 files changed, 56 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/downloads/models.py Sun Apr 19 21:01:15 2009 +0000 +++ b/gpp/downloads/models.py Sun Apr 19 21:16:59 2009 +0000 @@ -69,7 +69,7 @@ @models.permalink def get_absolute_url(self): - return ('downloads-download', [str(self.id)]) + return ('downloads-details', [str(self.id)]) def save(self, force_insert=False, force_update=False): html = render_to_string('downloads/markdown.html', {'data': self.description})
--- a/gpp/downloads/templatetags/downloads_tags.py Sun Apr 19 21:01:15 2009 +0000 +++ b/gpp/downloads/templatetags/downloads_tags.py Sun Apr 19 21:16:59 2009 +0000 @@ -4,6 +4,7 @@ from django import template from downloads.forms import SearchForm +from downloads.models import Download register = template.Library() @@ -11,3 +12,10 @@ @register.inclusion_tag('downloads/navigation.html') def downloads_navigation(): return {'search_form': SearchForm()} + +@register.inclusion_tag('downloads/latest_tag.html') +def latest_downloads(): + downloads = Download.public_objects.order_by('-date_added')[:10] + return { + 'downloads': downloads, + }
--- a/gpp/downloads/urls.py Sun Apr 19 21:01:15 2009 +0000 +++ b/gpp/downloads/urls.py Sun Apr 19 21:16:59 2009 +0000 @@ -9,7 +9,7 @@ url(r'^category/(?P<category>\d+)/(?P<sort>title|date|rating|hits)/page/(?P<page>\d+)/$', 'category', name='downloads-category'), - url(r'^comments/(\d+)/$', 'comments', name='downloads-comments'), + url(r'^details/(\d+)/$', 'details', name='downloads-details'), url(r'^(\d+)/$', 'download', name='downloads-download'), url(r'^new/$', 'new', name='downloads-new'), url(r'^popular/$', 'popular', name='downloads-popular'),
--- a/gpp/downloads/views.py Sun Apr 19 21:01:15 2009 +0000 +++ b/gpp/downloads/views.py Sun Apr 19 21:16:59 2009 +0000 @@ -129,11 +129,11 @@ ####################################################################### @login_required -def comments(request, id): +def details(request, id): download = Download.public_objects.get(pk=id) if download is None: raise Http404 - return render_to_response('downloads/download_comments.html', { + return render_to_response('downloads/download_detail.html', { 'download' : download, }, context_instance = RequestContext(request))
--- a/gpp/templates/downloads/download.html Sun Apr 19 21:01:15 2009 +0000 +++ b/gpp/templates/downloads/download.html Sun Apr 19 21:16:59 2009 +0000 @@ -19,7 +19,7 @@ <tr> <th>Rating:</th><td><div class="rating" id="rating-{{ download.id }}">{{ download.average_score|floatformat }}</div></td> <th><img src="{{ MEDIA_URL }}icons/comments.png" alt="Comments" title="Comments" /> - <a href="{% url downloads-comments download.id %}">Comments</a>:</th><td>{{ comment_count }}</td> + <a href="{% url downloads-details download.id %}">Comments</a>:</th><td>{{ comment_count }}</td> </tr> </table> </dd>
--- a/gpp/templates/downloads/download_comments.html Sun Apr 19 21:01:15 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -{% extends 'base.html' %} -{% load downloads_tags %} -{% load comment_tags %} -{% load script_tags %} -{% block title %}Downloads Comments{% endblock %} -{% block custom_css %} -<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/comments.css" /> -<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/downloads.css" /> -{% endblock %} -{% block custom_js %} -{% script_tags "markitup" %} -<script type="text/javascript" src="{{ MEDIA_URL }}js/comments.js"></script> -<script type="text/javascript" src="{{ MEDIA_URL }}js/downloads/rating.js"></script> -{% endblock %} -{% block content %} -<h2>Downloads</h2> -{% downloads_navigation %} -<h3>Download Comments For {{ download.title }}</h3> - -<dl> -{% include 'downloads/download.html' %} -</dl> - -{% get_comment_count for download as comment_count %} -<p>This download has <span id="comment-count">{{ comment_count }}</span> comment{{ comment_count|pluralize }}.</p> -<hr /> -{% render_comment_list download %} -{% render_comment_form for download %} -{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/downloads/download_detail.html Sun Apr 19 21:16:59 2009 +0000 @@ -0,0 +1,29 @@ +{% extends 'base.html' %} +{% load downloads_tags %} +{% load comment_tags %} +{% load script_tags %} +{% block title %}Downloads Details{% endblock %} +{% block custom_css %} +<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/comments.css" /> +<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/downloads.css" /> +{% endblock %} +{% block custom_js %} +{% script_tags "markitup" %} +<script type="text/javascript" src="{{ MEDIA_URL }}js/comments.js"></script> +<script type="text/javascript" src="{{ MEDIA_URL }}js/downloads/rating.js"></script> +{% endblock %} +{% block content %} +<h2>Downloads</h2> +{% downloads_navigation %} +<h3>Download Details For {{ download.title }}</h3> + +<dl> +{% include 'downloads/download.html' %} +</dl> + +{% get_comment_count for download as comment_count %} +<p>This download has <span id="comment-count">{{ comment_count }}</span> comment{{ comment_count|pluralize }}.</p> +<hr /> +{% render_comment_list download %} +{% render_comment_form for download %} +{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/downloads/latest_tag.html Sun Apr 19 21:16:59 2009 +0000 @@ -0,0 +1,10 @@ +<h3>New Downloads</h3> +{% if downloads %} +<ol> + {% for dl in downloads %} + <li><a href="{{ dl.get_absolute_url }}">{{ dl.title }}</a></li> + {% endfor %} +</ol> +{% else %} +<p>No downloads at this time.</p> +{% endif %}
--- a/gpp/templates/home.html Sun Apr 19 21:01:15 2009 +0000 +++ b/gpp/templates/home.html Sun Apr 19 21:16:59 2009 +0000 @@ -1,5 +1,6 @@ {% extends 'base.html' %} {% load weblinks_tags %} +{% load downloads_tags %} {% block title %}Home{% endblock %} {% block content %} <h2>Welcome to SurfGuitar101!</h2> @@ -15,10 +16,10 @@ permanent. The site (content, user accounts, etc.) may be wiped at any time while we fix bugs and add features. Also, I hope that the look and feel of this site can be greatly improved to something really cool! I'll need lots of help for this aspect, as I'm more of a coder than a designer.</p> -<div class="span-9"> +<div class="span-9 append-1"> {% latest_weblinks %} </div> -<div class="span-10 last"> - Some more stuff. +<div class="span-9 last"> + {% latest_downloads %} </div> {% endblock %}