Skip to content

Commit

Permalink
Merge branch 'release/0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez committed May 26, 2012
2 parents 328545d + 22dbf12 commit d8d23c1
Show file tree
Hide file tree
Showing 19 changed files with 157 additions and 145 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ MANIFEST
.tox/
*.egg
docs/_build/
tests/.coverage
tests/.tox
.coverage
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: python
python:
- "2.6"
- "2.7"
before_install:
- export PIP_USE_MIRRORS=true
- export PIP_INDEX_URL=https://simple.crate.io/
- export DJANGO_SETTINGS_MODULE=sorter.test_settings
install:
- pip install -e .
- pip install -r requirements/tests.txt Django==$DJANGO
before_script:
- flake8 sorter --ignore=E501
script:
- make test
env:
- DJANGO=1.3.1
- DJANGO=1.4
branches:
only:
- develop
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011, Jannis Leidel and individual contributors.
Copyright (c) 2011-2012, Jannis Leidel and individual contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test:
coverage run --branch --source=sorter `which django-admin.py` test --settings=sorter.test_settings sorter
coverage report --omit=sorter/test*
14 changes: 13 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
Changelog
=========

v0.1 (2011-09-02)
v0.2 (2012-05-26)
-----------------

- Made sure the ordering isn't reset when no querystring parameter is passed.

- Moved to Travis for testing: http://travis-ci.org/jezdez/django-sorter

- Updated dependency of URLObject to > 2.0.1. This could backwards
incomaptible if you're using a previous version (< 2.0).

- Dropped support for Python 2.5.

v0.1 (2011-09-07)
-----------------

- Initial release, yay!
14 changes: 9 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,20 @@

# General information about the project.
project = u'django-sorter'
copyright = u'2011, Jannis Leidel and individual contributors'
copyright = u'2011-2012, Jannis Leidel and individual contributors'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1'
try:
from sorter import __version__
# The short X.Y version.
version = '.'.join(__version__.split('.')[:2])
# The full version, including alpha/beta/rc tags.
release = __version__
except ImportError:
version = release = 'dev'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 6 additions & 0 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
docutils
milkman
django-ttag>=2.3
django-discover-runner
coverage
flake8
28 changes: 19 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
from os import path
import os
import codecs
import re
from setuptools import setup

read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read()

def read(*parts):
return codecs.open(os.path.join(os.path.dirname(__file__), *parts)).read()


def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")


setup(
name='django-sorter',
version=":versiontools:sorter:",
version=find_version("sorter", "__init__.py"),
description='A helper app for sorting objects in Django templates.',
long_description=read(path.join(path.dirname(__file__), 'README.rst')),
long_description=read('README.rst'),
author='Jannis Leidel',
author_email='[email protected]',
license='BSD',
url='http://github.com/jezdez/django-sorter/',
url='http://django-sorter.readthedocs.org/',
packages=['sorter', 'sorter.templatetags'],
package_data={
'sorter': [
Expand All @@ -33,12 +46,9 @@
'Programming Language :: Python :: 2.7',
'Topic :: Utilities',
],
setup_requires=[
'versiontools >= 1.7',
],
install_requires=[
'django-appconf >= 0.4',
'django-ttag >= 2.3',
'urlobject == 0.5.1',
'URLObject >= 2.0.1',
],
)
3 changes: 1 addition & 2 deletions sorter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# following PEP 386, versiontools will pick it up
__version__ = (0, 1, 0, "final", 0)
__version__ = "0.2"
2 changes: 1 addition & 1 deletion sorter/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf import settings
from django.conf import settings # noqa
from django.core.exceptions import ImproperlyConfigured
from appconf import AppConf

Expand Down
1 change: 0 additions & 1 deletion sorter/templatetags/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

9 changes: 5 additions & 4 deletions sorter/templatetags/sorter_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from urlobject import URLObject

from django import template
from django.core.exceptions import ImproperlyConfigured
from django.template import TemplateSyntaxError
from django.template.loader import render_to_string
from django.utils.translation import ugettext as _
Expand Down Expand Up @@ -56,7 +55,9 @@ class Sort(SorterAsTag):
def as_value(self, data, context):
value = data['data']
ordering = self.ordering(context, data['with'])
return value.order_by(*ordering)
if ordering:
return value.order_by(*ordering)
return value

def ordering(self, context, name):
"""
Expand Down Expand Up @@ -113,8 +114,8 @@ class Meta:
def as_value(self, data, context):
# The queries of the current URL, not using sequences here
# since the order of sorting arguments matter
url = URLObject.parse(context['request'].get_full_path())
queries = url.query_dict(seq=False)
url = URLObject(context['request'].get_full_path())
queries = url.query.dict

name, orderings = data['with'], data['by']
query = self.find_query(queries.get(name), orderings, orderings[0])
Expand Down
10 changes: 2 additions & 8 deletions tests/settings.py → sorter/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
'django.contrib.auth',
'django.contrib.admin',
'sorter',
'sorter_tests',
]

TEST_RUNNER = 'discover_runner.DiscoverRunner'

SORTER_ALLOWED_CRITERIA = {
'sort': ['*'],
'sort_objects': ['*'],
'sort1': ['*'],
'sort2': ['*'],
'sort_others': ['*'],
}
SECRET_KEY = 'something-something'
Loading

0 comments on commit d8d23c1

Please sign in to comment.