From 547c6529b237c50476a3a14a5ed9ed28a74cc143 Mon Sep 17 00:00:00 2001 From: Horst Gutmann Date: Fri, 13 Jan 2012 21:22:11 +0100 Subject: [PATCH 1/2] Some code cleanup --- flatblocks/admin.py | 5 +++-- flatblocks/forms.py | 1 + flatblocks/models.py | 7 ++++--- flatblocks/urls.py | 5 +++-- flatblocks/views.py | 9 +++++---- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/flatblocks/admin.py b/flatblocks/admin.py index 32660cf..d54e68b 100644 --- a/flatblocks/admin.py +++ b/flatblocks/admin.py @@ -1,8 +1,9 @@ from django.contrib import admin from flatblocks.models import FlatBlock - + + class FlatBlockAdmin(admin.ModelAdmin): - ordering = ['slug',] + ordering = ['slug', ] list_display = ('slug', 'header') search_fields = ('slug', 'header', 'content') diff --git a/flatblocks/forms.py b/flatblocks/forms.py index 8a593ea..d7ec2df 100644 --- a/flatblocks/forms.py +++ b/flatblocks/forms.py @@ -2,6 +2,7 @@ from flatblocks.models import FlatBlock + class FlatBlockForm(ModelForm): class Meta: model = FlatBlock diff --git a/flatblocks/models.py b/flatblocks/models.py index 2780cb4..a749308 100644 --- a/flatblocks/models.py +++ b/flatblocks/models.py @@ -11,17 +11,18 @@ class FlatBlock(models.Model): basically a piece of content with a given name (slug) and an optional title (header) which you can, for example, use in a sidebar of a website. """ - slug = models.CharField(max_length=255, unique=True, + slug = models.CharField(max_length=255, unique=True, verbose_name=_('Slug'), help_text=_("A unique name used for reference in the templates")) header = models.CharField(blank=True, null=True, max_length=255, verbose_name=_('Header'), help_text=_("An optional header for this content")) - content = models.TextField(verbose_name=_('Content'), blank=True, null=True) + content = models.TextField(verbose_name=_('Content'), blank=True, + null=True) def __unicode__(self): return u"%s" % (self.slug,) - + def save(self, *args, **kwargs): super(FlatBlock, self).save(*args, **kwargs) # Now also invalidate the cache used in the templatetag diff --git a/flatblocks/urls.py b/flatblocks/urls.py index c596cbb..de7df9f 100644 --- a/flatblocks/urls.py +++ b/flatblocks/urls.py @@ -1,7 +1,8 @@ -from django.conf.urls.defaults import * +from django.conf.urls.defaults import patterns, url from django.contrib.admin.views.decorators import staff_member_required from flatblocks.views import edit urlpatterns = patterns('', - url('^edit/(?P\d+)/$', staff_member_required(edit), name='flatblocks-edit') + url('^edit/(?P\d+)/$', staff_member_required(edit), + name='flatblocks-edit') ) diff --git a/flatblocks/views.py b/flatblocks/views.py index 62782e7..eda214e 100644 --- a/flatblocks/views.py +++ b/flatblocks/views.py @@ -1,6 +1,7 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext -from django.http import HttpResponseRedirect, HttpResponseForbidden, HttpResponse +from django.http import HttpResponseRedirect, HttpResponseForbidden,\ + HttpResponse from django.utils.translation import ugettext as _ from flatblocks.models import FlatBlock @@ -17,7 +18,7 @@ def edit(request, pk, modelform_class=FlatBlockForm, permission_check=None, keyword-argument. The other entry point helps you check permissions: Pass a simple function - via the ``permission_check`` keyword-argument in order to check + via the ``permission_check`` keyword-argument in order to check permissions on the flatblock-level:: def my_perm_check(request, flatblock): @@ -33,7 +34,7 @@ def my_perm_check(request, flatblock): The contract here is pretty simple: If the function returns False, the view will return HttpResponseForbidden. Otherwise it will pass. So if you want to do some fancy redirects if the permissions are wrong, return your - own HttpResponse-object/-subclass. + own HttpResponse-object/-subclass. If everything is alright with the permissions, simply return True. """ @@ -47,7 +48,7 @@ def my_perm_check(request, flatblock): session_key = 'flatblock.origin.%d' % (int(pk), ) if request.method == 'POST': - origin = request.session.get(session_key, + origin = request.session.get(session_key, request.META.get('HTTP_REFERER', '/')) form = modelform_class(request.POST, instance=flatblock) if form.is_valid(): From 946f1fdf69b6975e2375026d15a4b9ccd5a6c048 Mon Sep 17 00:00:00 2001 From: Horst Gutmann Date: Fri, 13 Jan 2012 21:30:32 +0100 Subject: [PATCH 2/2] Updates the release info as well as the version number --- README.rst | 5 ++++- setup.py | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 6e8a228..e302e59 100644 --- a/README.rst +++ b/README.rst @@ -165,10 +165,13 @@ the `django-better-chunks`_ fork (``django.contrib.site``- and i18n-support). Releases -------- -0.6.0 (incoming): +0.6.0: * South support * Installation and upgrade instructions + Note: This is primarily a transitional release to get South in here and + open this project up for some database changes in the future. + 0.5.1 * Removed rendering of the content attribute from the admin list by Michael Fladischer * PyBabel compatibility by Michael Fladischer diff --git a/setup.py b/setup.py index 0b7aa1d..6f23e19 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name = 'django-flatblocks', - version = '0.5.1', + version = '0.6.0', description = 'django-flatblocks acts like django.contrib.flatpages but ' 'for parts of a page; like an editable help box you want ' 'show alongside the main content.', @@ -31,4 +31,3 @@ include_package_data = True, zip_safe = False, ) -