Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into python-3

  • Loading branch information...
commit b777dd74c8c3fb4f4aef741380c75d3396b4eb76 2 parents cdb6679 + dbc8c2e
Julien Fache authored
2  .travis.yml
View
@@ -4,6 +4,6 @@ python:
- "2.7"
install:
- python bootstrap.py
- - ./bin/buildout
+ - ./bin/buildout -c ci/travis.cfg
script:
- ./bin/test
2  MANIFEST.in
View
@@ -4,10 +4,12 @@ include versions.cfg
include buildout.cfg
include bootstrap.py
recursive-include docs *
+recursive-include demo *
recursive-include zinnia/fixtures *.json
recursive-include zinnia/locale *
recursive-include zinnia/static *
recursive-include zinnia/templates *.txt *.html *.xml *.js
+exclude demo/demo.db
prune docs/build
prune docs/coverage
prune zinnia/static/zinnia/.sass-cache
26 ci/shiningpanda.cfg
View
@@ -0,0 +1,26 @@
+[buildout]
+extends = ../buildout.cfg
+
+develop = ..
+
+bin-directory = ../bin
+
+parts-directory = ../parts
+
+eggs-directory = ../eggs
+
+develop-eggs-directory = ../develop-eggs
+
+parts = cover
+ pep8
+ pyflakes
+
+eggs -= tweepy
+ gdata
+ feedparser
+ South
+ akismet
+ PyMollom
+ pdbpp
+ nose-progressive
+
29 ci/travis.cfg
View
@@ -0,0 +1,29 @@
+[buildout]
+extends = ../buildout.cfg
+
+develop = ..
+
+bin-directory = ../bin
+
+parts-directory = ../parts
+
+eggs-directory = ../eggs
+
+develop-eggs-directory = ../develop-eggs
+
+parts = test
+
+eggs -= tweepy
+ gdata
+ feedparser
+ South
+ akismet
+ PyMollom
+ pdbpp
+ coverage
+ nosexcover
+ nose-progressive
+
+[test]
+defaults = --with-sfd
+
2  docs/development/tests.rst
View
@@ -51,7 +51,7 @@ Coverage
Despite my best efforts, some functionnalities are not yet tested, that's why
I need your help !
-As I write these lines the **160** tests in Zinnia cover **96%** of the code
+As I write these lines the **164** tests in Zinnia cover **96%** of the code
bundled in Zinnia. A real effort has been made to obtain this percentage,
for ensuring the quality of the code.
7 docs/getting-started/install.rst
View
@@ -18,9 +18,11 @@ Make sure to install these packages prior to installation :
* `django-tagging`_ >= 0.3.1
* `beautifulsoup4`_ >= 4.1.3
-The packages below are optionnal but needed for run the full test suite.
+The packages below are optionnal but needed for run the full test suite or
+migrate the database.
* `pytz`_
+* `South`_ >= 0.7.6
* `pyparsing`_ >= 1.5.5 < 2.0.0
* `django-xmlrpc`_ >= 0.1.3
@@ -151,7 +153,7 @@ project directory to sync the models with the database. ::
$ python manage.py syncdb
-If you are using South to manage your database, you will have to do the
+If you are using `South`_ to manage your database, you will have to do the
following. ::
$ python manage.py syncdb --migrate
@@ -166,3 +168,4 @@ following. ::
.. _`pytz`: http://pytz.sourceforge.net/
.. _`pyparsing`: http://pyparsing.wikispaces.com/
.. _`django-xmlrpc`: https://github.com/Fantomas42/django-xmlrpc
+.. _`South`: http://south.aeracode.org/
4 zinnia/models_bases/entry.py
View
@@ -134,7 +134,9 @@ def get_absolute_url(self):
Builds and returns the entry's URL based on
the slug and the creation date.
"""
- creation_date = timezone.localtime(self.creation_date)
+ creation_date = self.creation_date
+ if timezone.is_aware(creation_date):
+ creation_date = timezone.localtime(creation_date)
return ('zinnia_entry_detail', (), {
'year': creation_date.strftime('%Y'),
'month': creation_date.strftime('%m'),
2  zinnia/static/zinnia/js/wymeditor/lang/eu.js
View
@@ -23,7 +23,7 @@ WYMeditor.STRINGS['eu'] = {
Heading_6: '6 Goiburua',
Preformatted: 'Aurreformatua',
Blockquote: 'Aipamena',
- Table_Header: 'Taula goiburua,
+ Table_Header: 'Taula goiburua',
URL: 'URL',
Title: 'Izenburua',
Alternative_Text: 'Testu alternatiboa',
22 zinnia/templatetags/zbreadcrumbs.py
View
@@ -4,6 +4,7 @@
from datetime import datetime
from django.utils.dateformat import format
+from django.utils.timezone import is_aware
from django.utils.timezone import localtime
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
@@ -41,6 +42,17 @@ def day_crumb(creation_date):
args=[year, month, day]))
+def entry_breadcrumbs(entry):
+ """Breadcrumbs for an Entry"""
+ creation_date = entry.creation_date
+ if is_aware(creation_date):
+ creation_date = localtime(creation_date)
+ return [year_crumb(creation_date),
+ month_crumb(creation_date),
+ day_crumb(creation_date),
+ Crumb(entry.title)]
+
+
ZINNIA_ROOT_URL = lambda: reverse('zinnia_entry_archive_index')
MODEL_BREADCRUMBS = {'Tag': lambda x: [Crumb(_('Tags'),
@@ -48,16 +60,12 @@ def day_crumb(creation_date):
Crumb(x.name)],
'Author': lambda x: [Crumb(_('Authors'),
reverse('zinnia_author_list')),
- Crumb(x.username)],
+ Crumb(x.__unicode__())],
'Category': lambda x: [Crumb(
_('Categories'), reverse('zinnia_category_list'))] +
- [Crumb(anc.title, anc.get_absolute_url())
+ [Crumb(anc.__unicode__(), anc.get_absolute_url())
for anc in x.get_ancestors()] + [Crumb(x.title)],
- 'Entry': lambda x: [
- year_crumb(localtime(x.creation_date)),
- month_crumb(localtime(x.creation_date)),
- day_crumb(localtime(x.creation_date)),
- Crumb(x.title)]}
+ 'Entry': entry_breadcrumbs}
ARCHIVE_REGEXP = re.compile(
r'.*(?P<year>\d{4})/(?P<month>\d{2})?/(?P<day>\d{2})?.*')
3  zinnia/tests/__init__.py
View
@@ -5,6 +5,7 @@
from zinnia.tests.entry import EntryTestCase
from zinnia.tests.entry import EntryHtmlContentTestCase
+from zinnia.tests.entry import EntryAbsoluteUrlTestCase
from zinnia.tests.entry import EntryGetBaseModelTestCase
from zinnia.tests.signals import SignalsTestCase
from zinnia.tests.category import CategoryTestCase
@@ -54,7 +55,7 @@ def suite():
MixinTestCase, LongEnoughTestCase,
AuthorTestCase, FlagsTestCase,
AuthorListFilterTestCase, CategoryListFilterTestCase,
- TranslatedURLsTestCase)
+ TranslatedURLsTestCase, EntryAbsoluteUrlTestCase)
if 'django_xmlrpc' in settings.INSTALLED_APPS:
test_cases += (PingBackTestCase, MetaWeblogTestCase)
24 zinnia/tests/entry.py
View
@@ -9,6 +9,7 @@
from django.core.urlresolvers import reverse
from django.utils.translation import activate
from django.utils.translation import deactivate
+from django.test.utils import override_settings
from django.contrib.comments.models import CommentFlag
from django.contrib.auth.tests.utils import skipIfCustomUser
@@ -305,6 +306,29 @@ def test_html_content_restructuredtext(self):
self.assertEquals(html_content, self.entry.content)
+class EntryAbsoluteUrlTestCase(TestCase):
+
+ def check_get_absolute_url(self, creation_date, url_expected):
+ params = {'title': 'My entry',
+ 'content': 'My content',
+ 'slug': 'my-entry',
+ 'creation_date': creation_date}
+ entry = Entry.objects.create(**params)
+ self.assertEquals(entry.get_absolute_url(), url_expected)
+
+ @override_settings(USE_TZ=False)
+ def test_get_absolute_url_no_timezone(self):
+ self.check_get_absolute_url(datetime(2013, 1, 1, 12, 0),
+ '/2013/01/01/my-entry/')
+
+ @override_settings(USE_TZ=True, TIME_ZONE='Europe/Paris')
+ def test_get_absolute_url_with_timezone(self):
+ self.check_get_absolute_url(datetime(2013, 1, 1, 12, 0),
+ '/2013/01/01/my-entry/')
+ self.check_get_absolute_url(datetime(2013, 1, 1, 23, 0),
+ '/2013/01/02/my-entry/')
+
+
class EntryGetBaseModelTestCase(TestCase):
def setUp(self):
45 zinnia/tests/views.py
View
@@ -25,6 +25,10 @@
@skipIfCustomUser
+@override_settings(
+ TEMPLATE_CONTEXT_PROCESSORS=(
+ 'django.core.context_processors.request',
+ ))
class ViewsBaseCase(TestCase):
"""
Setup and utility function base case.
@@ -101,11 +105,6 @@ def check_capabilities(self, url, mimetype, queries=0):
self.assertEquals(response['Content-Type'], mimetype)
self.assertTrue('protocol' in response.context)
-ViewsBaseCase = override_settings(
- TEMPLATE_CONTEXT_PROCESSORS=(
- 'django.core.context_processors.request',
- ))(ViewsBaseCase)
-
class ZinniaViewsTestCase(ViewsBaseCase):
"""
@@ -124,7 +123,8 @@ def tearDown(self):
except AttributeError:
pass
- def test_zinnia_entry_archive_index(self):
+ @override_settings(USE_TZ=False)
+ def test_zinnia_entry_archive_index_no_timezone(self):
template_name_today = 'zinnia/archives/%s/entry_archive.html' % \
date.today().strftime('%Y/%m/%d')
setup_test_template_loader(
@@ -134,6 +134,18 @@ def test_zinnia_entry_archive_index(self):
self.assertTemplateUsed(response, template_name_today)
restore_template_loaders()
+ @override_settings(USE_TZ=True, TIME_ZONE='Europe/Paris')
+ def test_zinnia_entry_archive_index_with_timezone(self):
+ template_name_today = 'zinnia/archives/%s/entry_archive.html' % \
+ timezone.localtime(timezone.now()
+ ).strftime('%Y/%m/%d')
+ setup_test_template_loader(
+ {template_name_today: ''})
+ response = self.check_publishing_context(
+ '/', 2, 3, 'entry_list', 2)
+ self.assertTemplateUsed(response, template_name_today)
+ restore_template_loaders()
+
def test_zinnia_entry_archive_year(self):
setup_test_template_loader(
{'zinnia/archives/2010/entry_archive_year.html': ''})
@@ -193,14 +205,29 @@ def test_zinnia_entry_archive_day(self):
self.assertEquals(response.context['next_day'], None)
restore_template_loaders()
- def test_zinnia_entry_archive_today(self):
+ @override_settings(USE_TZ=False)
+ def test_zinnia_entry_archive_today_no_timezone(self):
setup_test_template_loader(
{'zinnia/entry_archive_today.html': ''})
with self.assertNumQueries(5):
response = self.client.get('/today/')
- self.assertEquals(response.context['day'], timezone.localtime(
- timezone.now()).date())
self.assertTemplateUsed(response, 'zinnia/entry_archive_today.html')
+ self.assertEquals(response.context['day'].date(), date.today())
+ self.assertEquals(response.context['previous_month'], date(2010, 6, 1))
+ self.assertEquals(response.context['next_month'], None)
+ self.assertEquals(response.context['previous_day'], date(2010, 6, 1))
+ self.assertEquals(response.context['next_day'], None)
+ restore_template_loaders()
+
+ @override_settings(USE_TZ=True, TIME_ZONE='Europe/Paris')
+ def test_zinnia_entry_archive_today_with_timezone(self):
+ setup_test_template_loader(
+ {'zinnia/entry_archive_today.html': ''})
+ with self.assertNumQueries(5):
+ response = self.client.get('/today/')
+ self.assertTemplateUsed(response, 'zinnia/entry_archive_today.html')
+ self.assertEquals(response.context['day'].date(), timezone.localtime(
+ timezone.now()).date())
self.assertEquals(response.context['previous_month'], date(2010, 6, 1))
self.assertEquals(response.context['next_month'], None)
self.assertEquals(response.context['previous_day'], date(2010, 6, 1))
6 zinnia/views/archives.py
View
@@ -99,6 +99,8 @@ def get_dated_items(self):
And defines self.year/month/day for
EntryQuerysetArchiveTemplateResponseMixin.
"""
- today = timezone.localtime(timezone.now()).date()
- self.year, self.month, self.day = today.isoformat().split('-')
+ today = timezone.now()
+ if timezone.is_aware(today):
+ today = timezone.localtime(today)
+ self.year, self.month, self.day = today.date().isoformat().split('-')
return self._get_dated_items(today)
5 zinnia/views/mixins/templates.py
View
@@ -139,5 +139,8 @@ def get_archive_part_value(self, part):
'week': self.week_format,
'day': '%d'}
if self.today is None:
- self.today = timezone.localtime(timezone.now()).date()
+ today = timezone.now()
+ if timezone.is_aware(today):
+ today = timezone.localtime(today)
+ self.today = today
return self.today.strftime(parts_dict[part])
Please sign in to comment.
Something went wrong with that request. Please try again.