Skip to content

Commit 77c3107

Browse files
committed
FlatBlock.save should also accept the optional kwargs from the base model. Closes zerok#2
1 parent 588d49c commit 77c3107

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

buildout.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ eggs =
1111

1212
[django]
1313
recipe = djangorecipe
14-
version = 1.0.2
14+
version = 1.1
1515
test = flatblocks
1616
project = test_project
1717
settings = settings

flatblocks/__init__.py

-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +0,0 @@
1-
VERSION = (0, 3, 2, 'final')
2-
3-
def get_version():
4-
v = "%d.%d.%d" % VERSION[:3]
5-
if VERSION[3] != 'final':
6-
v = "%s%s%d" % (v, VERSION[3], VERSION[4])
7-
return v

flatblocks/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class FlatBlock(models.Model):
2222
def __unicode__(self):
2323
return u"%s" % (self.slug,)
2424

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

flatblocks/tests.py

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.test import TestCase
55
from django.core.cache import cache
66
from django.contrib.auth.models import User
7+
from django import db
78

89
from flatblocks import models
910
from flatblocks.settings import CACHE_PREFIX
@@ -38,6 +39,13 @@ def testCacheReset(self):
3839
block.save()
3940
self.assertEquals(None, cache.get(name))
4041

42+
def testSaveKwargs(self):
43+
block = models.FlatBlock()
44+
block.slug = 'missing'
45+
self.assertRaises(ValueError, block.save, force_update=True)
46+
block = models.FlatBlock.objects.get(slug='block')
47+
self.assertRaises(db.IntegrityError, block.save, force_insert=True)
48+
4149
def tearDown(self):
4250
self.testblock.delete()
4351

setup.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
use_setuptools()
66
from setuptools import setup, find_packages
77

8-
from flatblocks import get_version
9-
108
setup(
119
name = 'django-flatblocks',
12-
version = get_version(),
10+
version = '0.3.3',
1311
description = 'django-flatblocks acts like django.contrib.flatpages but '
1412
'for parts of a page; like an editable help box you want '
1513
'show alongside the main content.',

0 commit comments

Comments
 (0)