diff options
author | Dan McGee <dan@archlinux.org> | 2010-06-22 19:09:22 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-06-22 19:09:22 +0200 |
commit | 081ed6c8661bbec81cdbb9029e4832b34805f37b (patch) | |
tree | e5e22d2e52453df32aa7f8a3425125efda4b7c25 | |
parent | 4c96b53f2ed9551028457ad6e0b26692c3cf385b (diff) | |
download | archweb-081ed6c8661bbec81cdbb9029e4832b34805f37b.tar.gz archweb-081ed6c8661bbec81cdbb9029e4832b34805f37b.tar.xz |
Add 'never_cache' decorator in a bunch of places
Now that we cache everything, we need to ensure anyone doing edits and
such gets the live data and not some cached version that was already
updated and is now stale. Add the never_cache decorator to any of the
CUD screens as well as a few others that might benefit from always being
regenerated.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | devel/views.py | 4 | ||||
-rw-r--r-- | news/views.py | 4 | ||||
-rw-r--r-- | packages/views.py | 4 | ||||
-rw-r--r-- | todolists/views.py | 4 |
4 files changed, 16 insertions, 0 deletions
diff --git a/devel/views.py b/devel/views.py index edbe4ca..4215c0d 100644 --- a/devel/views.py +++ b/devel/views.py @@ -7,6 +7,7 @@ from django.shortcuts import render_to_response from django.template import RequestContext from django.core.mail import send_mail from django.db.models import Q +from django.views.decorators.cache import never_cache from main.models import Package, Todolist from main.models import Arch, Repo @@ -20,6 +21,7 @@ pwletters = ascii_letters + digits @login_required +@never_cache def index(request): '''the Developer dashboard''' inner_q = PackageRelation.objects.filter(user=request.user).values('pkgbase') @@ -58,6 +60,7 @@ class ProfileForm(forms.Form): return self.cleaned_data @login_required +@never_cache def change_profile(request): if request.POST: form = ProfileForm(request.POST) @@ -110,6 +113,7 @@ Password: %s""" % (domain, user.username, pw), fail_silently=False) @user_passes_test(lambda u: u.is_superuser) +@never_cache def new_user_form(request): if request.POST: form = NewUserForm(request.POST) diff --git a/news/views.py b/news/views.py index e6a6d83..2fe3743 100644 --- a/news/views.py +++ b/news/views.py @@ -2,6 +2,7 @@ from django import forms from django.contrib.auth.decorators import permission_required from django.shortcuts import render_to_response, redirect from django.template import RequestContext +from django.views.decorators.cache import never_cache from django.views.generic import list_detail, create_update from main.models import News @@ -23,6 +24,7 @@ class NewsForm(forms.ModelForm): exclude=('id', 'author', 'postdate') @permission_required('main.add_news') +@never_cache def add(request): if request.POST: form = NewsForm(request.POST) @@ -37,6 +39,7 @@ def add(request): RequestContext(request, { 'form': form })) @permission_required('main.delete_news') +@never_cache def delete(request, newsid): return create_update.delete_object(request, News, @@ -46,6 +49,7 @@ def delete(request, newsid): template_object_name='news') @permission_required('main.change_news') +@never_cache def edit(request, newsid): return create_update.update_object(request, object_id=newsid, diff --git a/packages/views.py b/packages/views.py index eb2276a..cf37361 100644 --- a/packages/views.py +++ b/packages/views.py @@ -8,6 +8,7 @@ from django.shortcuts import get_object_or_404 from django.contrib.auth.models import User from django.contrib.auth.decorators import permission_required from django.contrib.admin.widgets import AdminDateWidget +from django.views.decorators.cache import never_cache from django.views.decorators.vary import vary_on_headers from django.views.generic import list_detail from django.db.models import Q @@ -218,6 +219,7 @@ def unflag(request, name='', repo='', arch=''): return HttpResponseRedirect(pkg.get_absolute_url()) @permission_required('main.change_package') +@never_cache def signoffs(request): packages = Package.objects.select_related('arch', 'repo', 'signoffs').filter(repo__testing=True).order_by("pkgname") package_list = [] @@ -238,6 +240,7 @@ def signoffs(request): RequestContext(request, {'packages': package_list})) @permission_required('main.change_package') +@never_cache def signoff_package(request, arch, pkgname): pkg = get_object_or_404(Package, arch__name=arch, @@ -272,6 +275,7 @@ class FlagForm(forms.Form): widget=forms.TextInput(attrs={'style': 'display:none;'}), required=False) +@never_cache def flag(request, name='', repo='', arch=''): pkg = get_object_or_404(Package, pkgname=name, repo__name__iexact=repo, arch__name=arch) diff --git a/todolists/views.py b/todolists/views.py index 653b511..cdf503a 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -5,6 +5,7 @@ from django.template import RequestContext from django.core.mail import send_mail from django.shortcuts import get_object_or_404, render_to_response from django.contrib.auth.decorators import login_required, permission_required +from django.views.decorators.cache import never_cache from django.views.decorators.vary import vary_on_headers from django.views.generic.create_update import delete_object from django.template import Context, loader @@ -60,6 +61,7 @@ def list(request): RequestContext(request, {'lists':lists})) @permission_required('main.add_todolist') +@never_cache def add(request): if request.POST: form = TodoListForm(request.POST) @@ -86,6 +88,7 @@ def add(request): RequestContext(request, page_dict)) @permission_required('main.change_todolist') +@never_cache def edit(request, list_id): todo_list = get_object_or_404(Todolist, id=list_id) if request.POST: @@ -124,6 +127,7 @@ def edit(request, list_id): return render_to_response('general_form.html', RequestContext(request, page_dict)) @permission_required('main.delete_todolist') +@never_cache def delete_todolist(request, object_id): return delete_object(request, object_id=object_id, model=Todolist, template_name="todolists/todolist_confirm_delete.html", |