Mercurial > hg > agora-dellsystem
changeset 63:d5ebcf4a249f
Added some urls for the bundle links, and a template
author | Rettaw |
---|---|
date | Thu, 06 Oct 2011 23:40:01 +0200 |
parents | 7886e9c7fa50 |
children | 29802e95fe96 9c1e26cc80e3 |
files | apps/bundle/urls.py apps/bundle/views.py settings.py templates/bundle/index.djhtml urls.py |
diffstat | 5 files changed, 36 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/apps/bundle/urls.py +++ b/apps/bundle/urls.py @@ -2,5 +2,6 @@ urlpatterns = patterns('agora.apps.bundle.views', (r'^(?P<user>.*)/(?P<bundle>.*)/$', 'detail'), + (r'^$', 'index'), )
--- a/apps/bundle/views.py +++ b/apps/bundle/views.py @@ -1,14 +1,27 @@ from django.shortcuts import get_object_or_404 from agora.apps.bundle.models import * from django.views.generic.simple import direct_to_template +from django.http import HttpResponse def detail(request, user, bundle): b = get_object_or_404(Bundle, uploader__username=user, name=bundle) f = BundleFile.objects.filter(bundle=b) - return direct_to_template(request, 'bundle/index.djhtml', + return direct_to_template(request, 'bundle/bundle.djhtml', { 'bundle':b, 'files': f, }, ) + +def index(request): + try: + b = Bundle.objects.all().order_by('pub_date')[:5] + except Bundle.DoesNotExist: + raise Http404 + + return direct_to_template(request, 'bundle/index.djhtml', + { + 'bundles':b, + }, + )
--- a/settings.py +++ b/settings.py @@ -136,9 +136,11 @@ 'django.contrib.messages', 'django.contrib.admindocs', 'django.contrib.admin', + 'django.contrib.comments', #Third-party apps 'registration', + 'threadedcomments', #Agora apps 'agora.apps.profile', @@ -148,5 +150,7 @@ 'agora.apps.mptt', ) +COMMENTS_APP = 'threadedcomments' + LOGIN_REDIRECT_URL='/' AUTH_PROFILE_MODULE = 'profile.Profile'
--- a/templates/bundle/index.djhtml +++ b/templates/bundle/index.djhtml @@ -1,33 +1,24 @@ {% extends "whitebox.djhtml" %} {% block content %} -<div class="info"> - <h3> - {{bundle.name}} by <a href="/{{bundle.uploader}}/">{{bundle.uploader}}</a> - </h3> +<h1> Latest bundles </h1> - {% if files %} +{% if bundles|length > 0 %} - <div class="whitebox"> - <p> - files: - </p> - <ul> - {% for f in files%} - <li><a href="/{{f.bundle_file}}">{{f}}</a></li> - {% endfor %} - </ul> - </div> +{% for bundle in bundles %} + <div class="info"> + <h3> + {{bundle.name}} by <a href="/{{bundle.uploader}}/">{{bundle.uploader}}</a> + </h3> + <div class="whitebox"> + <p> + Bundle published the {{bundle.pub_date}} under the {{bundle.free_license}}. + </p> + </div> + {% endfor %} - {% else %} - - <div class="whitebox"> - <p> - No files in this bundle! - </p> - </div> - - {% endif %} - +{% else %} + No bundles registered yet! +{% endif %} </div> {% endblock %}