Mercurial > public > sg101
comparison core/views.py @ 591:1982996ce365
Created a "fixed page" facility.
Reworked the last few commits. We now generate HTML snippets from
restructured text files. These are {% include'd %} by a fixed
page template. This is for bitbucket issue #8.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 12 May 2012 14:57:45 -0500 |
parents | ee87ea74d46b |
children | 89b240fe9297 |
comparison
equal
deleted
inserted
replaced
590:ce73771b6cd0 | 591:1982996ce365 |
---|---|
3 used by multiple applications. | 3 used by multiple applications. |
4 """ | 4 """ |
5 from django.contrib.auth.models import User | 5 from django.contrib.auth.models import User |
6 from django.http import HttpResponse | 6 from django.http import HttpResponse |
7 from django.shortcuts import render_to_response | 7 from django.shortcuts import render_to_response |
8 from django.template import RequestContext | |
9 from django.contrib.auth.decorators import login_required | 8 from django.contrib.auth.decorators import login_required |
10 from django.views.decorators.http import require_GET | 9 from django.views.decorators.http import require_GET |
10 from django.views.generic import TemplateView | |
11 import django.utils.simplejson as json | 11 import django.utils.simplejson as json |
12 | 12 |
13 | 13 |
14 @login_required | 14 @login_required |
15 @require_GET | 15 @require_GET |
34 | 34 |
35 limit = int(request.GET.get('limit', 10)) | 35 limit = int(request.GET.get('limit', 10)) |
36 users = User.objects.filter(is_active=True, | 36 users = User.objects.filter(is_active=True, |
37 username__istartswith=q).values_list('username', flat=True)[:limit] | 37 username__istartswith=q).values_list('username', flat=True)[:limit] |
38 return HttpResponse(json.dumps(list(users)), content_type='application/json') | 38 return HttpResponse(json.dumps(list(users)), content_type='application/json') |
39 | |
40 | |
41 class FixedView(TemplateView): | |
42 """ | |
43 For displaying our "fixed" views generated with the custom command | |
44 make_fixed_page. | |
45 | |
46 """ | |
47 template_name = 'fixed/base.html' | |
48 title = '' | |
49 content_template = '' | |
50 | |
51 def get_context_data(self, **kwargs): | |
52 context = super(FixedView, self).get_context_data(**kwargs) | |
53 context['title'] = self.title | |
54 context['content_template'] = self.content_template | |
55 return context |