Skip to content

Commit

Permalink
Merge branch 'release/v1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
twidi committed Nov 3, 2016
2 parents d704c42 + 0dc65c3 commit af5b707
Show file tree
Hide file tree
Showing 9 changed files with 431 additions and 480 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
- DJANGO="Django<1.8"
- DJANGO="Django<1.9"
- DJANGO="Django<1.10"
- DJANGO="Django<1.11"

install:
- pip install -q $DJANGO
Expand Down Expand Up @@ -45,10 +46,14 @@ matrix:
env: DJANGO="Django<1.6"
- python: "3.3"
env: DJANGO="Django<1.10"
- python: "3.3"
env: DJANGO="Django<1.11"

- python: "2.6"
env: DJANGO="Django<1.8"
- python: "2.6"
env: DJANGO="Django<1.9"
- python: "2.6"
env: DJANGO="Django<1.10"
- python: "2.6"
env: DJANGO="Django<1.11"
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

Release *v1.1* - ``2016-11-03``
-------------------------------
* add the ``extract_subset`` method
* add the ``OrderedChoices`` subclass
* add support for Django 1.10
* drop retro-compatibility support

Release *v1.0.7* - ``2016-03-13``
---------------------------------
* ensure falsy values are considered as so
Expand Down
74 changes: 31 additions & 43 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ If you want these dicts to be ordered, you can pass the dict class to use to the
dict_class = OrderedDict
)
Since version ``1.1``, the new ``OrderedChoices`` class is provided, that is exactly that:
a ``Choices`` using ``OrderedDict`` by default for ``dict_class``.

You can check if a constant, value, or display name exists:

.. code-block:: python
Expand Down Expand Up @@ -260,7 +263,25 @@ You can also pass the ``argument`` to the ``Choices`` constructor to create a su
the choices entries added at the same time (it will call ``add_choices`` with the name and the
entries)
The list of existing subset names is in the ``subsets`` attributes of the parent ``Choicess`` object.
The list of existing subset names is in the ``subsets`` attributes of the parent ``Choices``
object.
If you want a subset of the choices but not save it in the original ``Choices`` object, you can
use ``extract_subset`` instead of ``add_subset``
.. code-block:: python
>>> subset = STATES.extract_subset('DRAFT', 'OFFLINE')
>>> subset
(2, 'Draft')
(3, 'Offline')
As for a subset created by ``add_subset``, you have a real ``Choices`` object, but not accessible
from the original ``Choices`` object.
Note that in ``extract_subset``, you pass the strings directly, not in a list/tuple as for the
second argument of ``add_subset``.
Notes
-----
Expand All @@ -272,46 +293,10 @@ Notes
Compatibility
-------------
The version ``1.0`` provides a totally new API, but stays fully compatible with the previous one
(``0.4.1``). So it adds a lot of attributes in each ``Choices`` instance:
* ``CHOICES``
* ``CHOICES_DICT``
* ``REVERTED_CHOICES_DICT``
* ``CHOICES_CONST_DICT``
(And 4 more for each subset)
If you don't want it, simply set the argument ``retro_compatibility`` to ``False`` when creating
a ``Choices`` instance:
.. code-block:: python
STATES = Choices(
('ONLINE', 1, 'Online'),
('DRAFT', 2, 'Draft'),
('OFFLINE', 3, 'Offline'),
retro_compatibility=False
)
This flag is currently ``True`` by default, and it will not be changed for at least 6 months
counting from the publication of this version ``1.0`` (``1st of May, 2015``, so until the
``1st of November, 2015``, AT LEAST, the compatibility will be on by default).
Then, the flag will stay but will be off by default. To keep compatibility, you'll have to
pass the ``retro_compatibility`` argument and set it to ``True``.
Then, after another period of 6 months minimum, the flag and all the retro_compatibility code
will be removed (so not before ``1st of May, 2016``).
Note that you can use a specific version by pinning it in your requirements.
The only exception to these rules, it's the support of Django ``1.4`` that was removed in version
``1.0.3`` due to some incompatibility problems with ``ugettext_lazy``.
Also, the support of ``None`` values was removed, raising a ``ValueError`` telling the user to
instead use an empty string.
The version ``1.0`` provided a totally new API, and compatibility with the previous one
(``0.4.1``) was removed in ``1.1``. The last version with the compatibility was ``1.0.7``.
If you need this compatibility, you can use a specific version by pinning it in your requirements.
License
-------
Expand All @@ -321,9 +306,9 @@ Available under the BSD_ License. See the ``LICENSE`` file included
Python 3?
---------
Of course! We support python ``2.6``, ``2.7``, ``3.3`` and `3.4`, for Django version ``1.5.x`` to
``1.8.x``, respecting the `Django matrix`_ (except for python ``2.5`` and ``3.2`` which are not
supported by ``django-extended-choices``)
Of course! We support python ``2.6``, ``2.7``, ``3.3``, ``3.4`` and ``3.5``, for Django version
``1.5.x`` to ``1.10.x``, respecting the `Django matrix`_ (except for python ``2.5`` and ``3.2``
which are not supported by ``django-extended-choices``)
Tests
Expand All @@ -339,6 +324,9 @@ We also provides some quick doctests in the code documentation. To execute them:
python -m extended_choices.choices
Note: the doctests will work only in python version not display `u` prefix for strings.
Source code
-----------
Expand Down
2 changes: 1 addition & 1 deletion extended_choices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
__author__ = 'Stephane "Twidi" Ange;'
__contact__ = "[email protected]"
__homepage__ = "https://pypi.python.org/pypi/django-extended-choices"
__version__ = "1.0.7"
__version__ = "1.1"
Loading

0 comments on commit af5b707

Please sign in to comment.