annotate apps/bundle/views.py @ 63:d5ebcf4a249f

Added some urls for the bundle links, and a template
author Rettaw
date Thu, 06 Oct 2011 23:40:01 +0200
parents ba2dad0d7f2a
children c7be7def8b57
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37
ba2dad0d7f2a Do license framework (need to create an SQL fixture for them)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 35
diff changeset
1 from django.shortcuts import get_object_or_404
4
069cabdaf8b2 Define stub template and admin site
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 2
diff changeset
2 from agora.apps.bundle.models import *
37
ba2dad0d7f2a Do license framework (need to create an SQL fixture for them)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 35
diff changeset
3 from django.views.generic.simple import direct_to_template
63
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
4 from django.http import HttpResponse
4
069cabdaf8b2 Define stub template and admin site
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 2
diff changeset
5
069cabdaf8b2 Define stub template and admin site
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 2
diff changeset
6 def detail(request, user, bundle):
6
c83460992637 Elaborate on stub bundle template
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 4
diff changeset
7 b = get_object_or_404(Bundle, uploader__username=user, name=bundle)
c83460992637 Elaborate on stub bundle template
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 4
diff changeset
8 f = BundleFile.objects.filter(bundle=b)
c83460992637 Elaborate on stub bundle template
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 4
diff changeset
9
63
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
10 return direct_to_template(request, 'bundle/bundle.djhtml',
35
290dd9208cc4 Implement editing user profiles and fix bugs related to the login/logout buttons. Implement 403 exception
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 6
diff changeset
11 {
290dd9208cc4 Implement editing user profiles and fix bugs related to the login/logout buttons. Implement 403 exception
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 6
diff changeset
12 'bundle':b,
290dd9208cc4 Implement editing user profiles and fix bugs related to the login/logout buttons. Implement 403 exception
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 6
diff changeset
13 'files': f,
290dd9208cc4 Implement editing user profiles and fix bugs related to the login/logout buttons. Implement 403 exception
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 6
diff changeset
14 },
290dd9208cc4 Implement editing user profiles and fix bugs related to the login/logout buttons. Implement 403 exception
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 6
diff changeset
15 )
63
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
16
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
17 def index(request):
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
18 try:
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
19 b = Bundle.objects.all().order_by('pub_date')[:5]
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
20 except Bundle.DoesNotExist:
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
21 raise Http404
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
22
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
23 return direct_to_template(request, 'bundle/index.djhtml',
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
24 {
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
25 'bundles':b,
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
26 },
d5ebcf4a249f Added some urls for the bundle links, and a template
Rettaw
parents: 37
diff changeset
27 )