[Python-modules-commits] [python-django-mptt] 01/06: Import python-django-mptt_0.8.5.orig.tar.gz

Thomas Goirand zigo at moszumanska.debian.org
Fri Aug 5 09:20:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

zigo pushed a commit to branch master
in repository python-django-mptt.

commit 74b1458b16004b3b50cb640c51af814de7282ba7
Author: Thomas Goirand <zigo at debian.org>
Date:   Fri Aug 5 08:43:25 2016 +0000

    Import python-django-mptt_0.8.5.orig.tar.gz
---
 MANIFEST.in                                     |   1 +
 PKG-INFO                                        |   2 +-
 README.rst                                      |   4 +-
 django_mptt.egg-info/PKG-INFO                   |   2 +-
 django_mptt.egg-info/SOURCES.txt                |  32 -----
 django_mptt.egg-info/requires.txt               |   1 -
 django_mptt.egg-info/top_level.txt              |   1 -
 docs/models.rst                                 |   5 +-
 docs/tutorial.rst                               |   9 +-
 mptt/__init__.py                                |   2 +-
 mptt/locale/ru/LC_MESSAGES/django.mo            | Bin 4380 -> 5278 bytes
 mptt/locale/ru/LC_MESSAGES/django.po            | 160 ++++++++++++++++--------
 mptt/managers.py                                |  62 ++++-----
 mptt/models.py                                  |  23 +++-
 mptt/static/mptt/draggable-admin.js             |   8 +-
 setup.py                                        |   8 +-
 tests/__init__.pyc                              | Bin 210 -> 0 bytes
 tests/__pycache__/__init__.cpython-32.pyc       | Bin 229 -> 0 bytes
 tests/__pycache__/__init__.cpython-33.pyc       | Bin 234 -> 0 bytes
 tests/__pycache__/__init__.cpython-34.pyc       | Bin 194 -> 0 bytes
 tests/__pycache__/__init__.cpython-35.pyc       | Bin 194 -> 0 bytes
 tests/__pycache__/settings.cpython-32.pyc       | Bin 729 -> 0 bytes
 tests/__pycache__/settings.cpython-33.pyc       | Bin 2197 -> 0 bytes
 tests/__pycache__/settings.cpython-34.pyc       | Bin 1500 -> 0 bytes
 tests/__pycache__/settings.cpython-35.pyc       | Bin 1525 -> 0 bytes
 tests/myapp/__init__.pyc                        | Bin 232 -> 0 bytes
 tests/myapp/__pycache__/__init__.cpython-32.pyc | Bin 235 -> 0 bytes
 tests/myapp/__pycache__/__init__.cpython-33.pyc | Bin 240 -> 0 bytes
 tests/myapp/__pycache__/__init__.cpython-34.pyc | Bin 200 -> 0 bytes
 tests/myapp/__pycache__/__init__.cpython-35.pyc | Bin 200 -> 0 bytes
 tests/myapp/__pycache__/admin.cpython-34.pyc    | Bin 497 -> 0 bytes
 tests/myapp/__pycache__/admin.cpython-35.pyc    | Bin 568 -> 0 bytes
 tests/myapp/__pycache__/models.cpython-32.pyc   | Bin 14240 -> 0 bytes
 tests/myapp/__pycache__/models.cpython-33.pyc   | Bin 15998 -> 0 bytes
 tests/myapp/__pycache__/models.cpython-34.pyc   | Bin 12127 -> 0 bytes
 tests/myapp/__pycache__/models.cpython-35.pyc   | Bin 12127 -> 0 bytes
 tests/myapp/__pycache__/tests.cpython-32.pyc    | Bin 47711 -> 0 bytes
 tests/myapp/__pycache__/tests.cpython-33.pyc    | Bin 52020 -> 0 bytes
 tests/myapp/__pycache__/tests.cpython-34.pyc    | Bin 63200 -> 0 bytes
 tests/myapp/__pycache__/tests.cpython-35.pyc    | Bin 65077 -> 0 bytes
 tests/myapp/__pycache__/urls.cpython-34.pyc     | Bin 349 -> 0 bytes
 tests/myapp/__pycache__/urls.cpython-35.pyc     | Bin 349 -> 0 bytes
 tests/myapp/admin.pyc                           | Bin 733 -> 0 bytes
 tests/myapp/doctests.txt                        |   6 +-
 tests/myapp/models.py                           |  14 +++
 tests/myapp/models.pyc                          | Bin 18839 -> 0 bytes
 tests/myapp/tests.py                            |  79 +++++++++++-
 tests/myapp/tests.pyc                           | Bin 81653 -> 0 bytes
 tests/myapp/urls.pyc                            | Bin 407 -> 0 bytes
 tests/runtests.sh                               |   8 +-
 tests/settings.pyc                              | Bin 2156 -> 0 bytes
 51 files changed, 275 insertions(+), 152 deletions(-)

diff --git a/MANIFEST.in b/MANIFEST.in
index 0cc5997..a3526cc 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -9,3 +9,4 @@ recursive-include tests *
 recursive-include mptt/templates *
 recursive-include mptt/locale *
 recursive-include mptt/static *
+global-exclude __pycache__ *.pyc
diff --git a/PKG-INFO b/PKG-INFO
index a24fcc9..58a920f 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: django-mptt
-Version: 0.8.3
+Version: 0.8.5
 Summary: Utilities for implementing Modified Preorder Tree Traversal
         with your Django Models and working with trees of Model instances.
 Home-page: http://github.com/django-mptt/django-mptt
diff --git a/README.rst b/README.rst
index 737a0ee..664ce9b 100644
--- a/README.rst
+++ b/README.rst
@@ -32,9 +32,9 @@ details about how the technique itself works:
     * `Storing Hierarchical Data in a Database`_
     * `Managing Hierarchical Data in MySQL`_
 
-.. _`Trees in SQL`: http://www.ibase.ru/devinfo/DBMSTrees/sqltrees.html
+.. _`Trees in SQL`: http://www.ibase.ru/files/articles/programming/dbmstrees/sqltrees.html
 .. _`Storing Hierarchical Data in a Database`: http://www.sitepoint.com/print/hierarchical-data-database
-
+.. _`Managing Hierarchical Data in MySQL`: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/
 
 What is ``django-mptt``?
 ========================
diff --git a/django_mptt.egg-info/PKG-INFO b/django_mptt.egg-info/PKG-INFO
index a24fcc9..58a920f 100644
--- a/django_mptt.egg-info/PKG-INFO
+++ b/django_mptt.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: django-mptt
-Version: 0.8.3
+Version: 0.8.5
 Summary: Utilities for implementing Modified Preorder Tree Traversal
         with your Django Models and working with trees of Model instances.
 Home-page: http://github.com/django-mptt/django-mptt
diff --git a/django_mptt.egg-info/SOURCES.txt b/django_mptt.egg-info/SOURCES.txt
index 675959f..8a5da12 100644
--- a/django_mptt.egg-info/SOURCES.txt
+++ b/django_mptt.egg-info/SOURCES.txt
@@ -8,7 +8,6 @@ setup.py
 django_mptt.egg-info/PKG-INFO
 django_mptt.egg-info/SOURCES.txt
 django_mptt.egg-info/dependency_links.txt
-django_mptt.egg-info/requires.txt
 django_mptt.egg-info/top_level.txt
 docs/Makefile
 docs/admin.rst
@@ -79,47 +78,16 @@ mptt/templatetags/mptt_tags.py
 tests/.coveragerc
 tests/.gitignore
 tests/__init__.py
-tests/__init__.pyc
 tests/mydatabase
 tests/requirements.txt
 tests/runtests.sh
 tests/settings.py
-tests/settings.pyc
-tests/__pycache__/__init__.cpython-32.pyc
-tests/__pycache__/__init__.cpython-33.pyc
-tests/__pycache__/__init__.cpython-34.pyc
-tests/__pycache__/__init__.cpython-35.pyc
-tests/__pycache__/settings.cpython-32.pyc
-tests/__pycache__/settings.cpython-33.pyc
-tests/__pycache__/settings.cpython-34.pyc
-tests/__pycache__/settings.cpython-35.pyc
 tests/myapp/__init__.py
-tests/myapp/__init__.pyc
 tests/myapp/admin.py
-tests/myapp/admin.pyc
 tests/myapp/doctests.txt
 tests/myapp/models.py
-tests/myapp/models.pyc
 tests/myapp/tests.py
-tests/myapp/tests.pyc
 tests/myapp/urls.py
-tests/myapp/urls.pyc
-tests/myapp/__pycache__/__init__.cpython-32.pyc
-tests/myapp/__pycache__/__init__.cpython-33.pyc
-tests/myapp/__pycache__/__init__.cpython-34.pyc
-tests/myapp/__pycache__/__init__.cpython-35.pyc
-tests/myapp/__pycache__/admin.cpython-34.pyc
-tests/myapp/__pycache__/admin.cpython-35.pyc
-tests/myapp/__pycache__/models.cpython-32.pyc
-tests/myapp/__pycache__/models.cpython-33.pyc
-tests/myapp/__pycache__/models.cpython-34.pyc
-tests/myapp/__pycache__/models.cpython-35.pyc
-tests/myapp/__pycache__/tests.cpython-32.pyc
-tests/myapp/__pycache__/tests.cpython-33.pyc
-tests/myapp/__pycache__/tests.cpython-34.pyc
-tests/myapp/__pycache__/tests.cpython-35.pyc
-tests/myapp/__pycache__/urls.cpython-34.pyc
-tests/myapp/__pycache__/urls.cpython-35.pyc
 tests/myapp/fixtures/categories.json
 tests/myapp/fixtures/genres.json
 tests/myapp/fixtures/items.json
diff --git a/django_mptt.egg-info/requires.txt b/django_mptt.egg-info/requires.txt
deleted file mode 100644
index 531dd9b..0000000
--- a/django_mptt.egg-info/requires.txt
+++ /dev/null
@@ -1 +0,0 @@
-Django>=1.8
diff --git a/django_mptt.egg-info/top_level.txt b/django_mptt.egg-info/top_level.txt
index 5f89f8d..7c545e2 100644
--- a/django_mptt.egg-info/top_level.txt
+++ b/django_mptt.egg-info/top_level.txt
@@ -1,2 +1 @@
 mptt
-tests
diff --git a/docs/models.rst b/docs/models.rst
index 358edbb..dc8a4b1 100644
--- a/docs/models.rst
+++ b/docs/models.rst
@@ -328,7 +328,7 @@ These may come in useful on other models that relate to your tree model in some
 
 
 .. note::
-   You can't use a many-to-many as your 'parent' field. That's because 
+   You can't use a many-to-many as your 'parent' field. That's because
    the mptt algorithm only handles trees, not arbitrary graphs. A tree where nodes
    can have multiple parents isn't really a tree at all.
 
@@ -367,6 +367,9 @@ Rebuilds the mptt fields for the entire table. This can be handy:
  * if your tree gets corrupted somehow.
  * After large bulk operations, when you've used ``disable_mptt_updates``
 
+It is recommended to rebuild the tree inside a ``transaction.atomic()`` block
+for safety and better performance.
+
 ``add_related_count(queryset, rel_cls, rel_field, count_attr, cumulative=False)``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
diff --git a/docs/tutorial.rst b/docs/tutorial.rst
index 4fd9b30..858ac87 100644
--- a/docs/tutorial.rst
+++ b/docs/tutorial.rst
@@ -65,10 +65,10 @@ Set up your model
 -----------------
 
 Start with a basic subclass of MPTTModel, something like this::
-   
+
     from django.db import models
     from mptt.models import MPTTModel, TreeForeignKey
-    
+
     class Genre(MPTTModel):
         name = models.CharField(max_length=50, unique=True)
         parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True)
@@ -83,9 +83,10 @@ other fields: ``level``, ``lft``, ``rght``, and ``tree_id``. These fields are ma
 
 That ``MPTTMeta`` class adds some tweaks to ``django-mptt`` - in this case, just ``order_insertion_by``. This indicates the natural ordering of the data in the tree.
 
-Now create your table in the database::
+Now create and apply the migrations to create the table in the database::
 
-    python manage.py syncdb
+    python manage.py makemigrations <your_app>
+    python manage.py migrate
 
 
 Create some data
diff --git a/mptt/__init__.py b/mptt/__init__.py
index f3a8209..c67eb72 100644
--- a/mptt/__init__.py
+++ b/mptt/__init__.py
@@ -1,6 +1,6 @@
 from __future__ import unicode_literals
 
-VERSION = (0, 8, 3)
+VERSION = (0, 8, 5)
 __version__ = '.'.join(str(v) for v in VERSION)
 
 
diff --git a/mptt/locale/ru/LC_MESSAGES/django.mo b/mptt/locale/ru/LC_MESSAGES/django.mo
index bed7c40..ef08271 100644
Binary files a/mptt/locale/ru/LC_MESSAGES/django.mo and b/mptt/locale/ru/LC_MESSAGES/django.mo differ
diff --git a/mptt/locale/ru/LC_MESSAGES/django.po b/mptt/locale/ru/LC_MESSAGES/django.po
index 7335c2d..81aa367 100644
--- a/mptt/locale/ru/LC_MESSAGES/django.po
+++ b/mptt/locale/ru/LC_MESSAGES/django.po
@@ -2,13 +2,14 @@
 # This file is distributed under the same license as the django-mptt package.
 # Translators:
 # Sergey Vishnikin <armicron at yandex.ru>, 2013.
+# Rafael Kamashev <wizzzet at gmail.com>, 2016.
 msgid ""
 msgstr ""
 "Project-Id-Version: django-mptt\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-08-28 17:46+0400\n"
+"POT-Creation-Date: 2016-03-02 12:10+0300\n"
 "PO-Revision-Date: 2013-08-28 19:49+0400\n"
-"Last-Translator: Sergey Vishnikin <armicron at yandex.ru>\n"
+"Last-Translator: Rafael Kamashev <wizzzet at gmail.com>\n"
 "Language-Team: \n"
 "Language: ru_RU\n"
 "MIME-Version: 1.0\n"
@@ -17,133 +18,192 @@ msgstr ""
 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
 "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
 
-#: admin.py:91
-msgid "Database error"
-msgstr "Ошибка базы данных"
+#: admin.py:80
+#, python-format
+#| msgid "Successfully deleted %s items."
+msgid "Successfully deleted %(count)d items."
+msgstr "Успешно удалено %(count)d узлов."
 
-#: admin.py:127
+#: admin.py:93
 #, python-format
-msgid "%(count)s %(name)s was changed successfully."
-msgid_plural "%(count)s %(name)s were changed successfully."
-msgstr[0] "%(count)s %(name)s успешно изменен."
-msgstr[1] "%(count)s %(name)s успешно изменены."
-msgstr[2] "%(count)s %(name)s успешно изменено."
+msgid "Delete selected %(verbose_name_plural)s"
+msgstr "Удалить выбранное %(verbose_name_plural)s"
+
+#: admin.py:175
+msgid "title"
+msgstr "заголовок"
 
-#: admin.py:197 admin.py:199
-msgid "Add child"
-msgstr "Добавить потомка"
+#: admin.py:205
+msgid "Did not understand moving instruction."
+msgstr "Изучите инструкцию по перемещению узлов."
 
-#: admin.py:205 admin.py:207
-msgid "View on site"
-msgstr "Перейти на сайт"
+#: admin.py:213
+msgid "Objects have disappeared, try again."
+msgstr "Объекты пропали, повторите еще раз."
 
-#: admin.py:219
+#: admin.py:217
+msgid "No permission"
+msgstr "Нет доступа"
+
+#: admin.py:226
 #, python-format
-msgid "Successfully deleted %s items."
-msgstr "Успешно удалено %s узлов."
+#| msgid "Database error"
+msgid "Database error: %s"
+msgstr "Ошибка базы данных: %s"
 
-#: admin.py:224
+#: admin.py:231
 #, python-format
-msgid "Delete selected %(verbose_name_plural)s"
-msgstr "Удалить выбранное %(verbose_name_plural)s"
+msgid "%s has been successfully moved."
+msgstr "%s был успешно перемещен."
 
-#: forms.py:65
+#: admin.py:242
+msgid "move node before node"
+msgstr "переместить узел до узла"
+
+#: admin.py:243
+msgid "move node to child position"
+msgstr "переместить узел в подчиненную позицию"
+
+#: admin.py:244
+msgid "move node after node"
+msgstr "переместить узел после узла"
+
+#: admin.py:245
+msgid "Collapse tree"
+msgstr "Свернуть дерево"
+
+#: admin.py:246
+msgid "Expand tree"
+msgstr "Развернуть дерево"
+
+#: forms.py:63
 msgid "First child"
 msgstr "Первый потомок"
 
-#: forms.py:66
+#: forms.py:64
 msgid "Last child"
 msgstr "Последний потомок"
 
-#: forms.py:67
+#: forms.py:65
 msgid "Left sibling"
 msgstr "Левый брат"
 
-#: forms.py:68
+#: forms.py:66
 msgid "Right sibling"
 msgstr "Правый брат"
 
-#: managers.py:200
+#: forms.py:184
+msgid "Invalid parent"
+msgstr "Неверный родительский узел"
+
+#: managers.py:514
 msgid "Cannot insert a node which has already been saved."
 msgstr "Невозможно добавить элемент, который уже был сохранён."
 
-#: managers.py:379 managers.py:551 managers.py:587 managers.py:742
+#: managers.py:743 managers.py:916 managers.py:952 managers.py:1116
 #, python-format
 msgid "An invalid position was given: %s."
 msgstr "Была дана неверная позиция: %s."
 
-#: managers.py:537 managers.py:722
+#: managers.py:902 managers.py:1096
 msgid "A node may not be made a sibling of itself."
 msgstr "Элемент не может быть дочерним самому себе."
 
-#: managers.py:701 managers.py:823
+#: managers.py:1075 managers.py:1200
 msgid "A node may not be made a child of itself."
 msgstr "Элемент не может быть потомком самому себе."
 
-#: managers.py:703 managers.py:825
+#: managers.py:1077 managers.py:1202
 msgid "A node may not be made a child of any of its descendants."
 msgstr "Элемент не может быть потомком своего наследника."
 
-#: managers.py:724
+#: managers.py:1098
 msgid "A node may not be made a sibling of any of its descendants."
 msgstr "Элемент не может быть дочерним своему наследнику."
 
-#: templatetags/mptt_tags.py:28
+#: models.py:291
+msgid "register() expects a Django model class argument"
+msgstr "register() ожидает модель Django в качестве аргумента"
+
+#: templatetags/mptt_tags.py:31
 #, python-format
 msgid "full_tree_for_model tag was given an invalid model: %s"
 msgstr "для full_tree_for_model была дана неверная модель: %s"
 
-#: templatetags/mptt_tags.py:49
+#: templatetags/mptt_tags.py:55
 #, python-format
 msgid "drilldown_tree_for_node tag was given an invalid model: %s"
 msgstr "для drilldown_tree_for_node была дана неверная модель: %s"
 
-#: templatetags/mptt_tags.py:53
+#: templatetags/mptt_tags.py:62
 #, python-format
 msgid "drilldown_tree_for_node tag was given an invalid model field: %s"
 msgstr "для drilldown_tree_for_node было дано неверное поле модели: %s"
 
-#: templatetags/mptt_tags.py:78
+#: templatetags/mptt_tags.py:89
 #, python-format
 msgid "%s tag requires three arguments"
 msgstr "%s требует три аргумента"
 
-#: templatetags/mptt_tags.py:80 templatetags/mptt_tags.py:132
+#: templatetags/mptt_tags.py:91 templatetags/mptt_tags.py:146
 #, python-format
 msgid "second argument to %s tag must be 'as'"
 msgstr "вторым аргуметом для %s должен быть 'as'"
 
-#: templatetags/mptt_tags.py:130
+#: templatetags/mptt_tags.py:143
 #, python-format
 msgid "%s tag requires either three, seven or eight arguments"
 msgstr "%s требует три, семь или восемь аргументов"
 
-#: templatetags/mptt_tags.py:135
+#: templatetags/mptt_tags.py:150
 #, python-format
 msgid "if seven arguments are given, fourth argument to %s tag must be 'with'"
-msgstr "если дано семь аргументов, то четвёртый аргумент для %s должен быть 'with'"
+msgstr ""
+"если дано семь аргументов, то четвёртый аргумент для %s должен быть 'with'"
 
-#: templatetags/mptt_tags.py:137
+#: templatetags/mptt_tags.py:154
 #, python-format
 msgid "if seven arguments are given, sixth argument to %s tag must be 'in'"
 msgstr "если дано семь аргументов, то шестой для %s должен быть 'in'"
 
-#: templatetags/mptt_tags.py:141
+#: templatetags/mptt_tags.py:160
 #, python-format
-msgid "if eight arguments are given, fourth argument to %s tag must be 'cumulative'"
-msgstr "если дано восемь аргументов, то четвёртый аргумент для %s должен быть 'cumulative'"
+msgid ""
+"if eight arguments are given, fourth argument to %s tag must be 'cumulative'"
+msgstr ""
+"если дано восемь аргументов, то четвёртый аргумент для %s должен быть "
+"'cumulative'"
 
-#: templatetags/mptt_tags.py:143
+#: templatetags/mptt_tags.py:164
 #, python-format
 msgid "if eight arguments are given, fifth argument to %s tag must be 'count'"
-msgstr "если дано восемь аргументов, то пятый аргумент для %s должен быть 'count'"
+msgstr ""
+"если дано восемь аргументов, то пятый аргумент для %s должен быть 'count'"
 
-#: templatetags/mptt_tags.py:145
+#: templatetags/mptt_tags.py:168
 #, python-format
 msgid "if eight arguments are given, seventh argument to %s tag must be 'in'"
-msgstr "если дано восемь аргументов, то седьмой аргумент для %s должен быть 'in'"
+msgstr ""
+"если дано восемь аргументов, то седьмой аргумент для %s должен быть 'in'"
 
-#: templatetags/mptt_tags.py:296
+#: templatetags/mptt_tags.py:287
 #, python-format
 msgid "%s tag requires a queryset"
 msgstr "для %s требуется queryset"
+
+#: utils.py:240
+#, python-format
+msgid "Node %s not in depth-first order"
+msgstr "Узел %s имеет уровень меньше первого уровня"
+
+#~ msgid "%(count)s %(name)s was changed successfully."
+#~ msgid_plural "%(count)s %(name)s were changed successfully."
+#~ msgstr[0] "%(count)s %(name)s успешно изменен."
+#~ msgstr[1] "%(count)s %(name)s успешно изменены."
+#~ msgstr[2] "%(count)s %(name)s успешно изменено."
+
+#~ msgid "Add child"
+#~ msgstr "Добавить потомка"
+
+#~ msgid "View on site"
+#~ msgstr "Перейти на сайт"
diff --git a/mptt/managers.py b/mptt/managers.py
index 657624e..a216429 100644
--- a/mptt/managers.py
+++ b/mptt/managers.py
@@ -2,6 +2,7 @@
 A custom manager for working with trees of objects.
 """
 from __future__ import unicode_literals
+import functools
 import contextlib
 from itertools import groupby
 
@@ -59,7 +60,20 @@ CUMULATIVE_COUNT_SUBQUERY_M2M = """(
 )"""
 
 
+def delegate_manager(method):
+    """
+    Delegate method calls to base manager, if exists.
+    """
+    @functools.wraps(method)
+    def wrapped(self, *args, **kwargs):
+        if self._base_manager:
+            return getattr(self._base_manager, method.__name__)(*args, **kwargs)
+        return method(self, *args, **kwargs)
+    return wrapped
+
+
 class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
+
     """
     A manager for working with trees of objects.
     """
@@ -384,25 +398,21 @@ class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
             new_lookups[join_parts(new_parts)] = v
         return new_lookups
 
+    @delegate_manager
     def _mptt_filter(self, qs=None, **filters):
         """
         Like ``self.filter()``, but translates name-agnostic filters for MPTT
         fields.
         """
-        if self._base_manager:
-            return self._base_manager._mptt_filter(qs=qs, **filters)
-
         if qs is None:
             qs = self
         return qs.filter(**self._translate_lookups(**filters))
 
+    @delegate_manager
     def _mptt_update(self, qs=None, **items):
         """
         Like ``self.update()``, but translates name-agnostic MPTT fields.
         """
-        if self._base_manager:
-            return self._base_manager._mptt_update(qs=qs, **items)
-
         if qs is None:
             qs = self
         return qs.update(**self._translate_lookups(**items))
@@ -486,6 +496,7 @@ class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
                 }
         return queryset.extra(select={count_attr: subquery})
 
+    @delegate_manager
     def insert_node(self, node, target, position='last-child', save=False,
                     allow_existing_pk=False, refresh_target=True):
         """
@@ -506,10 +517,6 @@ class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
         set the node's parent and let mptt call this during save.
         """
 
-        if self._base_manager:
-            return self._base_manager.insert_node(
-                node, target, position=position, save=save, allow_existing_pk=allow_existing_pk)
-
         if node.pk and not allow_existing_pk and self.filter(pk=node.pk).exists():
             raise ValueError(_('Cannot insert a node which has already been saved.'))
 
@@ -566,11 +573,8 @@ class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
             node.save()
         return node
 
+    @delegate_manager
     def _move_node(self, node, target, position='last-child', save=True, refresh_target=True):
-        if self._base_manager:
-            return self._base_manager._move_node(node, target, position=position,
-                                                 save=save, refresh_target=refresh_target)
-
         if self.tree_model._mptt_is_tracking:
             # delegate to insert_node and clean up the gaps later.
             return self.insert_node(node, target, position=position, save=save,
@@ -614,32 +618,25 @@ class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
         node_moved.send(sender=node.__class__, instance=node,
                         target=target, position=position)
 
+    @delegate_manager
     def root_node(self, tree_id):
         """
         Returns the root node of the tree with the given id.
         """
-        if self._base_manager:
-            return self._base_manager.root_node(tree_id)
-
         return self._mptt_filter(tree_id=tree_id, parent=None).get()
 
+    @delegate_manager
     def root_nodes(self):
         """
         Creates a ``QuerySet`` containing root nodes.
         """
-        if self._base_manager:
-            return self._base_manager.root_nodes()
-
         return self._mptt_filter(parent=None)
 
+    @delegate_manager
     def rebuild(self):
         """
         Rebuilds all trees in the database table using `parent` link.
         """
-
-        if self._base_manager:
-            return self._base_manager.rebuild()
-
         opts = self.model._mptt_meta
 
         qs = self._mptt_filter(parent=None)
@@ -654,13 +651,12 @@ class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
             rebuild_helper(pk, 1, idx)
     rebuild.alters_data = True
 
+    @delegate_manager
     def partial_rebuild(self, tree_id):
         """
         Partially rebuilds a tree i.e. It rebuilds only the tree with given
         ``tree_id`` in database table using ``parent`` link.
         """
-        if self._base_manager:
-            return self._base_manager.partial_rebuild(tree_id)
         opts = self.model._mptt_meta
 
         qs = self._mptt_filter(parent=None, tree_id=tree_id)
@@ -847,7 +843,7 @@ class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
             gap_target_left, gap_size,
             left, right, left_right_change,
             gap_target_left, gap_size,
-            node.pk,
+            node._meta.pk.get_db_prep_value(node.pk, connection),
             getattr(node, self.tree_id_attr)
         ]
         if parent_pk is not None:
@@ -1040,8 +1036,10 @@ class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
         # Make space for the subtree which will be moved
         self._create_space(tree_width, space_target, new_tree_id)
         # Move the subtree
+        connection = self._get_connection(instance=node)
         self._inter_tree_move_and_close_gap(
-            node, level_change, left_right_change, new_tree_id, parent.pk)
+            node, level_change, left_right_change, new_tree_id,
+            parent._meta.pk.get_db_prep_value(parent.pk, connection))
 
         # Update the node to be consistent with the updated
         # tree in the database.
@@ -1169,7 +1167,8 @@ class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
             left_boundary, right_boundary, gap_size,
             left, right, left_right_change,
             left_boundary, right_boundary, gap_size,
-            node.pk, parent.pk,
+            node._meta.get_field(node._meta.pk.name).get_db_prep_value(node.pk, connection),
+            parent._meta.get_field(parent._meta.pk.name).get_db_prep_value(parent.pk, connection),
             tree_id])
 
         # Update the node to be consistent with the updated
@@ -1236,7 +1235,10 @@ class TreeManager(models.Manager.from_queryset(TreeQuerySet)):
         cursor = connection.cursor()
         cursor.execute(move_tree_query, [
             level_change, left_right_change, left_right_change,
-            new_tree_id, node.pk, parent.pk, left, right, tree_id])
+            new_tree_id,
+            node._meta.pk.get_db_prep_value(node.pk, connection),
+            parent._meta.pk.get_db_prep_value(parent.pk, connection),
+            left, right, tree_id])
 
         # Update the former root node to be consistent with the updated
         # tree in the database.
diff --git a/mptt/models.py b/mptt/models.py
index 0f84009..1442124 100644
--- a/mptt/models.py
+++ b/mptt/models.py
@@ -131,10 +131,11 @@ class MPTTOptions(object):
                 if f[0] == '-':
                     f = f[1:]
                 field_names.add(f)
+        deferred_fields = instance.get_deferred_fields()
         for field_name in field_names:
-            if instance._deferred:
+            if deferred_fields:
                 field = instance._meta.get_field(field_name)
-                if field.attname in instance.get_deferred_fields() \
+                if field.attname in deferred_fields \
                         and field.attname not in instance.__dict__:
                     # deferred attribute (i.e. via .only() or .defer())
                     # It'd be silly to cache this (that'd do a database query)
@@ -211,7 +212,7 @@ class MPTTOptions(object):
                 # Fall back on tree id ordering if multiple root nodes have
                 # the same values.
                 order_by.append(opts.tree_id_attr)
-            queryset = node.__class__._tree_manager.filter(filters).order_by(*order_by)
+            queryset = node.__class__._tree_manager.db_manager(node._state.db).filter(filters).order_by(*order_by)
             if node.pk:
                 queryset = queryset.exclude(pk=node.pk)
             try:
@@ -345,8 +346,13 @@ class MPTTModelBase(ModelBase):
 
                 # make sure we have a tree manager somewhere
                 tree_manager = None
-                cls_managers = cls._meta.concrete_managers + cls._meta.abstract_managers
-                for __, __, cls_manager in cls_managers:
+                if hasattr(cls._meta, 'concrete_managers'):  # Django < 1.10
+                    cls_managers = cls._meta.concrete_managers + cls._meta.abstract_managers
+                    cls_managers = [r[2] for r in cls_managers]
+                else:
+                    cls_managers = cls._meta.managers
+
+                for cls_manager in cls_managers:
                     if isinstance(cls_manager, TreeManager):
                         # prefer any locally defined manager (i.e. keep going if not local)
                         if cls_manager.model is cls:
@@ -388,6 +394,7 @@ class MPTTModel(six.with_metaclass(MPTTModelBase, models.Model)):
     def __init__(self, *args, **kwargs):
         super(MPTTModel, self).__init__(*args, **kwargs)
         self._mptt_meta.update_mptt_cached_fields(self)
+        self._tree_manager = self._tree_manager.db_manager(self._state.db)
 
     def _mpttfield(self, fieldname):
         translated_fieldname = getattr(self._mptt_meta, fieldname + '_attr')
@@ -901,7 +908,11 @@ class MPTTModel(six.with_metaclass(MPTTModelBase, models.Model)):
                         # If we aren't already a descendant of the new parent,
                         # we need to update the parent.rght so things like
                         # get_children and get_descendant_count work correctly.
-                        update_cached_parent = (
+                        #
+                        # parent might be None if parent_id was assigned
+                        # directly -- then we certainly do not have to update
+                        # the cached parent.
+                        update_cached_parent = parent and (
                             getattr(self, opts.tree_id_attr) != getattr(parent, opts.tree_id_attr) or  # noqa
                             getattr(self, opts.left_attr) < getattr(parent, opts.left_attr) or
                             getattr(self, opts.right_attr) > getattr(parent, opts.right_attr))
diff --git a/mptt/static/mptt/draggable-admin.js b/mptt/static/mptt/draggable-admin.js
index ec141ad..23018a2 100644
--- a/mptt/static/mptt/draggable-admin.js
+++ b/mptt/static/mptt/draggable-admin.js
@@ -268,7 +268,7 @@ django.jQuery(function($){
     /* Every time the user expands or collapses a part of the tree, we remember
        the current state of the tree so we can restore it on a reload. */
     function storeCollapsedNodes(nodes) {
-        window.sessionStorage && window.sessionStorage.setItem(
+        window.localStorage && window.localStorage.setItem(
             DraggableMPTTAdmin.storageName,
             JSON.stringify(nodes)
         );
@@ -276,7 +276,7 @@ django.jQuery(function($){
 
     function retrieveCollapsedNodes() {
         try {
-            return JSON.parse(window.sessionStorage.getItem(
+            return JSON.parse(window.localStorage.getItem(
                 DraggableMPTTAdmin.storageName
             ));
         } catch(e) {
@@ -352,6 +352,10 @@ django.jQuery(function($){
     };
 
     function keyboardNavigationHandler(event) {
+        // On form element? Ignore.
+        if (/textarea|select|input/i.test(event.target.nodeName))
+            return;
+
         // console.log('keydown', this, event.keyCode);
         switch (event.keyCode) {
             case 40: // down
diff --git a/setup.py b/setup.py
index f54ce55..4034645 100755
--- a/setup.py
+++ b/setup.py
@@ -12,14 +12,8 @@ setup(
     author_email='craig.ds at gmail.com',
     url='http://github.com/django-mptt/django-mptt',
     license='MIT License',
-    packages=find_packages(),
+    packages=find_packages(exclude=['tests', 'tests.*']),
     include_package_data=True,
-    install_requires=(
-        'Django>=1.8',
-    ),
-    test_requires=(
-        'mock-django>=0.6.7',
-    ),
     classifiers=[
         'Development Status :: 4 - Beta',
         'Environment :: Web Environment',
diff --git a/tests/__init__.pyc b/tests/__init__.pyc
deleted file mode 100644
index 612200f..0000000
Binary files a/tests/__init__.pyc and /dev/null differ
diff --git a/tests/__pycache__/__init__.cpython-32.pyc b/tests/__pycache__/__init__.cpython-32.pyc
deleted file mode 100644
index 89bbdaf..0000000
Binary files a/tests/__pycache__/__init__.cpython-32.pyc and /dev/null differ
diff --git a/tests/__pycache__/__init__.cpython-33.pyc b/tests/__pycache__/__init__.cpython-33.pyc
deleted file mode 100644
index a160ac3..0000000
Binary files a/tests/__pycache__/__init__.cpython-33.pyc and /dev/null differ
diff --git a/tests/__pycache__/__init__.cpython-34.pyc b/tests/__pycache__/__init__.cpython-34.pyc
deleted file mode 100644
index 534a018..0000000
Binary files a/tests/__pycache__/__init__.cpython-34.pyc and /dev/null differ
diff --git a/tests/__pycache__/__init__.cpython-35.pyc b/tests/__pycache__/__init__.cpython-35.pyc
deleted file mode 100644
index a18127e..0000000
Binary files a/tests/__pycache__/__init__.cpython-35.pyc and /dev/null differ
diff --git a/tests/__pycache__/settings.cpython-32.pyc b/tests/__pycache__/settings.cpython-32.pyc
deleted file mode 100644
index c720650..0000000
Binary files a/tests/__pycache__/settings.cpython-32.pyc and /dev/null differ
diff --git a/tests/__pycache__/settings.cpython-33.pyc b/tests/__pycache__/settings.cpython-33.pyc
deleted file mode 100644
index 6042819..0000000
Binary files a/tests/__pycache__/settings.cpython-33.pyc and /dev/null differ
diff --git a/tests/__pycache__/settings.cpython-34.pyc b/tests/__pycache__/settings.cpython-34.pyc
deleted file mode 100644
index 1f14c85..0000000
Binary files a/tests/__pycache__/settings.cpython-34.pyc and /dev/null differ
diff --git a/tests/__pycache__/settings.cpython-35.pyc b/tests/__pycache__/settings.cpython-35.pyc
deleted file mode 100644
index 0209a22..0000000
Binary files a/tests/__pycache__/settings.cpython-35.pyc and /dev/null differ
diff --git a/tests/myapp/__init__.pyc b/tests/myapp/__init__.pyc
deleted file mode 100644
index 8688114..0000000
Binary files a/tests/myapp/__init__.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/__init__.cpython-32.pyc b/tests/myapp/__pycache__/__init__.cpython-32.pyc
deleted file mode 100644
index 0bd850b..0000000
Binary files a/tests/myapp/__pycache__/__init__.cpython-32.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/__init__.cpython-33.pyc b/tests/myapp/__pycache__/__init__.cpython-33.pyc
deleted file mode 100644
index a723988..0000000
Binary files a/tests/myapp/__pycache__/__init__.cpython-33.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/__init__.cpython-34.pyc b/tests/myapp/__pycache__/__init__.cpython-34.pyc
deleted file mode 100644
index 9780d5e..0000000
Binary files a/tests/myapp/__pycache__/__init__.cpython-34.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/__init__.cpython-35.pyc b/tests/myapp/__pycache__/__init__.cpython-35.pyc
deleted file mode 100644
index eda3a09..0000000
Binary files a/tests/myapp/__pycache__/__init__.cpython-35.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/admin.cpython-34.pyc b/tests/myapp/__pycache__/admin.cpython-34.pyc
deleted file mode 100644
index efca309..0000000
Binary files a/tests/myapp/__pycache__/admin.cpython-34.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/admin.cpython-35.pyc b/tests/myapp/__pycache__/admin.cpython-35.pyc
deleted file mode 100644
index fd9339d..0000000
Binary files a/tests/myapp/__pycache__/admin.cpython-35.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/models.cpython-32.pyc b/tests/myapp/__pycache__/models.cpython-32.pyc
deleted file mode 100644
index 99b19c0..0000000
Binary files a/tests/myapp/__pycache__/models.cpython-32.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/models.cpython-33.pyc b/tests/myapp/__pycache__/models.cpython-33.pyc
deleted file mode 100644
index f65b7a0..0000000
Binary files a/tests/myapp/__pycache__/models.cpython-33.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/models.cpython-34.pyc b/tests/myapp/__pycache__/models.cpython-34.pyc
deleted file mode 100644
index 6112ad8..0000000
Binary files a/tests/myapp/__pycache__/models.cpython-34.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/models.cpython-35.pyc b/tests/myapp/__pycache__/models.cpython-35.pyc
deleted file mode 100644
index 487fa87..0000000
Binary files a/tests/myapp/__pycache__/models.cpython-35.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/tests.cpython-32.pyc b/tests/myapp/__pycache__/tests.cpython-32.pyc
deleted file mode 100644
index 275d373..0000000
Binary files a/tests/myapp/__pycache__/tests.cpython-32.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/tests.cpython-33.pyc b/tests/myapp/__pycache__/tests.cpython-33.pyc
deleted file mode 100644
index bbc0fdf..0000000
Binary files a/tests/myapp/__pycache__/tests.cpython-33.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/tests.cpython-34.pyc b/tests/myapp/__pycache__/tests.cpython-34.pyc
deleted file mode 100644
index 2838723..0000000
Binary files a/tests/myapp/__pycache__/tests.cpython-34.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/tests.cpython-35.pyc b/tests/myapp/__pycache__/tests.cpython-35.pyc
deleted file mode 100644
index 7bc2c19..0000000
Binary files a/tests/myapp/__pycache__/tests.cpython-35.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/urls.cpython-34.pyc b/tests/myapp/__pycache__/urls.cpython-34.pyc
deleted file mode 100644
index 4df1614..0000000
Binary files a/tests/myapp/__pycache__/urls.cpython-34.pyc and /dev/null differ
diff --git a/tests/myapp/__pycache__/urls.cpython-35.pyc b/tests/myapp/__pycache__/urls.cpython-35.pyc
deleted file mode 100644
index 9ed2cb0..0000000
Binary files a/tests/myapp/__pycache__/urls.cpython-35.pyc and /dev/null differ
diff --git a/tests/myapp/admin.pyc b/tests/myapp/admin.pyc
deleted file mode 100644
index 533bda0..0000000
Binary files a/tests/myapp/admin.pyc and /dev/null differ
diff --git a/tests/myapp/doctests.txt b/tests/myapp/doctests.txt
index fc0bc6b..607331e 100644
--- a/tests/myapp/doctests.txt
+++ b/tests/myapp/doctests.txt
@@ -176,7 +176,7 @@
 
 >>> form = MoveNodeForm(Genre.objects.get(pk=7))
 >>> print(form['target'])
-<select id="id_target" name="target" size="10">
+<select id="id_target" name="target" size="10"...>
 <option value="" selected="selected">---------</option>
 <option value="1"> Action</option>
 <option value="2">--- Platformer</option>
@@ -189,7 +189,7 @@
 
 >>> form = MoveNodeForm(Genre.objects.get(pk=7), level_indicator=u'+--', target_select_size=5)
 >>> print(form['target'])
-<select id="id_target" name="target" size="5">
+<select id="id_target" name="target" size="5"...>
 <option value="" selected="selected">---------</option>
 <option value="1"> Action</option>
 <option value="2">+-- Platformer</option>
@@ -202,7 +202,7 @@
 
 >>> form = MoveNodeForm(Genre.objects.get(pk=7), position_choices=(('left', 'left'),))
 >>> print(form['position'])
-<select id="id_position" name="position">
+<select id="id_position" name="position"...>
 <option value="left">left</option>
 </select>
 
diff --git a/tests/myapp/models.py b/tests/myapp/models.py
index 90fe6c5..d86c1e5 100644
--- a/tests/myapp/models.py
+++ b/tests/myapp/models.py
@@ -1,6 +1,7 @@
 from __future__ import unicode_literals
 from django.db import models
 from django.utils.encoding import python_2_unicode_compatible
+from uuid import uuid4
 
 import mptt
 from mptt.fields import TreeForeignKey, TreeOneToOneField, TreeManyToManyField
@@ -10,11 +11,13 @@ from django.db.models.query import QuerySet
 
 
 class CustomTreeQueryset(QuerySet):
+
     def custom_method(self):
         pass
 
 
 class CustomTreeManager(TreeManager):
+
     def get_query_set(self):
         return CustomTreeQueryset(model=self.model, using=self._db)
 
@@ -113,6 +116,15 @@ class Node(MPTTModel):
         tree_id_attr = 'work'
 
 
+class UUIDNode(MPTTModel):
+    parent = models.ForeignKey('self', null=True, blank=True, related_name='children')
+    uuid = models.UUIDField(primary_key=True, default=uuid4)
+    name = models.CharField(max_length=50)
+
+    def __str__(self):
+        return self.name
+
+
 @python_2_unicode_compatible
 class OrderedInsertion(MPTTModel):
     name = models.CharField(max_length=50)
@@ -226,6 +238,7 @@ class ConcreteModel(AbstractModel):
 
 class AbstractConcreteAbstract(ConcreteModel):
... 290 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django-mptt.git



More information about the Python-modules-commits mailing list