Skip to content
This repository has been archived by the owner on Dec 9, 2019. It is now read-only.

Commit

Permalink
FlatBlock.save should also accept the optional kwargs from the base m…
Browse files Browse the repository at this point in the history
…odel. Closes #2
  • Loading branch information
zerok committed Sep 26, 2009
1 parent 588d49c commit 77c3107
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion buildout.cfg
Expand Up @@ -11,7 +11,7 @@ eggs =


[django] [django]
recipe = djangorecipe recipe = djangorecipe
version = 1.0.2 version = 1.1
test = flatblocks test = flatblocks
project = test_project project = test_project
settings = settings settings = settings
Expand Down
7 changes: 0 additions & 7 deletions flatblocks/__init__.py
@@ -1,7 +0,0 @@
VERSION = (0, 3, 2, 'final')

def get_version():
v = "%d.%d.%d" % VERSION[:3]
if VERSION[3] != 'final':
v = "%s%s%d" % (v, VERSION[3], VERSION[4])
return v
4 changes: 2 additions & 2 deletions flatblocks/models.py
Expand Up @@ -22,8 +22,8 @@ class FlatBlock(models.Model):
def __unicode__(self): def __unicode__(self):
return u"%s" % (self.slug,) return u"%s" % (self.slug,)


def save(self): def save(self, *args, **kwargs):
super(FlatBlock, self).save() super(FlatBlock, self).save(*args, **kwargs)
# Now also invalidate the cache used in the templatetag # Now also invalidate the cache used in the templatetag
cache.delete('%s%s' % (CACHE_PREFIX, self.slug, )) cache.delete('%s%s' % (CACHE_PREFIX, self.slug, ))


Expand Down
8 changes: 8 additions & 0 deletions flatblocks/tests.py
Expand Up @@ -4,6 +4,7 @@
from django.test import TestCase from django.test import TestCase
from django.core.cache import cache from django.core.cache import cache
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django import db


from flatblocks import models from flatblocks import models
from flatblocks.settings import CACHE_PREFIX from flatblocks.settings import CACHE_PREFIX
Expand Down Expand Up @@ -38,6 +39,13 @@ def testCacheReset(self):
block.save() block.save()
self.assertEquals(None, cache.get(name)) self.assertEquals(None, cache.get(name))


def testSaveKwargs(self):
block = models.FlatBlock()
block.slug = 'missing'
self.assertRaises(ValueError, block.save, force_update=True)
block = models.FlatBlock.objects.get(slug='block')
self.assertRaises(db.IntegrityError, block.save, force_insert=True)

def tearDown(self): def tearDown(self):
self.testblock.delete() self.testblock.delete()


Expand Down
4 changes: 1 addition & 3 deletions setup.py
Expand Up @@ -5,11 +5,9 @@
use_setuptools() use_setuptools()
from setuptools import setup, find_packages from setuptools import setup, find_packages


from flatblocks import get_version

setup( setup(
name = 'django-flatblocks', name = 'django-flatblocks',
version = get_version(), version = '0.3.3',
description = 'django-flatblocks acts like django.contrib.flatpages but ' description = 'django-flatblocks acts like django.contrib.flatpages but '
'for parts of a page; like an editable help box you want ' 'for parts of a page; like an editable help box you want '
'show alongside the main content.', 'show alongside the main content.',
Expand Down

0 comments on commit 77c3107

Please sign in to comment.