[Python-modules-commits] [django-sitetree] 01/03: Import django-sitetree_1.5.0.orig.tar.gz
Michael Fladischer
fladi at moszumanska.debian.org
Thu Nov 19 12:04:44 UTC 2015
This is an automated email from the git hooks/post-receive script.
fladi pushed a commit to branch master
in repository django-sitetree.
commit 8f1f79ad2a0414d60d39a71205aff0e343cc0ce0
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date: Thu Nov 19 11:22:18 2015 +0100
Import django-sitetree_1.5.0.orig.tar.gz
---
.codeclimate.yml | 11 +
.gitignore | 1 +
.travis.yml | 24 +-
AUTHORS | 5 +
CHANGELOG | 11 +
README.rst | 19 +-
docs/source/apps.rst | 38 +--
docs/source/models.rst | 35 ++-
docs/source/quickstart.rst | 7 +-
docs/source/tags.rst | 13 +
setup.py | 9 +-
sitetree/__init__.py | 2 +-
sitetree/locale/nb/LC_MESSAGES/django.mo | Bin 0 -> 5806 bytes
sitetree/locale/nb/LC_MESSAGES/django.po | 275 +++++++++++++++++++++
.../management/commands/sitetree_resync_apps.py | 18 +-
sitetree/runtests.py | 2 +-
sitetree/settings.py | 6 +
sitetree/sitetreeapp.py | 123 ++++++---
sitetree/templatetags/sitetree.py | 119 +++++----
sitetree/tests.py | 114 +++++++--
sitetree/utils.py | 14 +-
tox.ini | 16 +-
22 files changed, 688 insertions(+), 174 deletions(-)
diff --git a/.codeclimate.yml b/.codeclimate.yml
new file mode 100644
index 0000000..c219d7e
--- /dev/null
+++ b/.codeclimate.yml
@@ -0,0 +1,11 @@
+languages:
+ JavaScript: true
+ Python: true
+
+exclude_paths:
+- "sitetree/runtests.py"
+- "sitetree/tests.py"
+- "sitetree/tests/*"
+- "sitetree/migrations/*"
+- "sitetree/south_migrations/*"
+- "docs/*"
diff --git a/.gitignore b/.gitignore
index f295052..ce35507 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
.idea
.tox
django_sitetree.egg-info
+docs/build
diff --git a/.travis.yml b/.travis.yml
index f3c981e..fe56aa4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,13 +1,15 @@
language: python
python:
+ - 3.5
- 3.4
- 3.3
- 2.7
- 2.6
env:
- - DJANGO="Django>=1.8,<1.9"
+ - DJANGO="Django==1.9b1"
+ - DJANGO="Django>=1.8.6,<1.9"
- DJANGO="Django>=1.7,<1.8"
- DJANGO="Django>=1.6,<1.7"
- DJANGO="Django>=1.4,<1.5"
@@ -20,22 +22,30 @@ script: coverage run -a --source=sitetree sitetree/runtests.py
matrix:
exclude:
+ - python: 3.5
+ env: DJANGO="Django>=1.7,<1.8"
+ - python: 3.5
+ env: DJANGO="Django>=1.6,<1.7"
+ - python: 3.5
+ env: DJANGO="Django>=1.4,<1.5"
+
- python: 3.4
env: DJANGO="Django>=1.4,<1.5"
+
+ - python: 3.3
+ env: DJANGO="Django==1.9b1"
- python: 3.3
env: DJANGO="Django>=1.4,<1.5"
+
+ - python: 2.6
+ env: DJANGO="Django==1.9b1"
- python: 2.6
- env: DJANGO="Django>=1.8,<1.9"
+ env: DJANGO="Django>=1.8.6,<1.9"
- python: 2.6
env: DJANGO="Django>=1.7,<1.8"
- python: 2.6
env: DJANGO="Django>=1.6,<1.7"
- include:
- - python: 3.4
- env: DJANGO="Django>=1.7,<1.8"
- - python: 3.4
- env: DJANGO="Django>=1.8,<1.9"
after_success:
coveralls
diff --git a/AUTHORS b/AUTHORS
index 45d614d..2f02b1c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -30,6 +30,10 @@ Erika Reinhardt <https://github.com/embreinhardt>
Dmitry Voronin <https://github.com/dimka665>
Dave Pretty <https://github.com/dpretty>
Alexander Artemenko <https://github.com/svetlyak40wt>
+ibooj <https://github.com/ibooj>
+Patrick Altman <https://github.com/paltman>
+Ben Cole <https://github.com/wengole>
+Vitaliy Ivanov <https://github.com/vit-ivanov>
Translators
@@ -40,3 +44,4 @@ Ukranian: Sergiy Gavrylov <sergiovana at bigmir.net>
German: Danilo Bargen <https://www.transifex.com/accounts/profile/gwrtheyrn/>
Persian: Ali Javadi <https://www.transifex.com/accounts/profile/rohamn/>
Spanish: Adrián López Calvo <https://www.transifex.com/accounts/profile/AdrianLC/>
+Norwegian: Eirik Krogstad <https://github.com/tangram>
diff --git a/CHANGELOG b/CHANGELOG
index 54c4a8c..f968c8f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,17 @@
django-sitetree changelog
=========================
+v1.5.0
+------
++ Added Norwegian translation.
++ Added SITETREE_RAISE_ITEMS_ERRORS_ON_DEBUG setting (see #157).
++ Exposed SITETREE_CACHE_TIMEOUT setting.
++ Added `as` clause support for `sitetree_page_title`, `sitetree_page_description` and `sitetree_page_hint` template tags.
+* Fixed cache problems when using sitetree_resync_apps (see #135, #166).
+* Fixed disappearing tree items for guests in Admin contrib (Django 1.8) (see #164).
+* Fix deprecation warning in Django 1.8 (see #178).
+* Fixed permissions check for dynamic tree items (see #165).
+
v1.4.0
------
diff --git a/README.rst b/README.rst
index 7db4079..be98488 100644
--- a/README.rst
+++ b/README.rst
@@ -2,19 +2,22 @@ django-sitetree
===============
http://github.com/idlesign/django-sitetree
-.. image:: https://badge.fury.io/py/django-sitetree.png
- :target: http://badge.fury.io/py/django-sitetree
+.. image:: https://img.shields.io/pypi/v/django-sitetree.svg
+ :target: https://pypi.python.org/pypi/django-sitetree
-.. image:: https://pypip.in/d/django-sitetree/badge.png
- :target: https://crate.io/packages/django-sitetree
-
-.. image:: https://coveralls.io/repos/idlesign/django-sitetree/badge.png
+.. image:: https://img.shields.io/pypi/dm/django-sitetree.svg
+ :target: https://pypi.python.org/pypi/django-sitetree
+
+.. image:: https://img.shields.io/pypi/l/django-sitetree.svg
+ :target: https://pypi.python.org/pypi/django-sitetree
+
+.. image:: https://img.shields.io/coveralls/idlesign/django-sitetree/master.svg
:target: https://coveralls.io/r/idlesign/django-sitetree
-.. image:: https://travis-ci.org/idlesign/django-sitetree.svg?branch=master
+.. image:: https://img.shields.io/travis/idlesign/django-sitetree/master.svg
:target: https://travis-ci.org/idlesign/django-sitetree
-.. image:: https://landscape.io/github/idlesign/django-sitetree/master/landscape.svg?style=plastic
+.. image:: https://landscape.io/github/idlesign/django-sitetree/master/landscape.svg?style=flat
:target: https://landscape.io/github/idlesign/django-sitetree/master
diff --git a/docs/source/apps.rst b/docs/source/apps.rst
index 1c62c5b..d45f530 100644
--- a/docs/source/apps.rst
+++ b/docs/source/apps.rst
@@ -16,24 +16,29 @@ Let's suppose you have `books` application and want do define a sitetree for it.
.. code-block:: python
- from sitetree.utils import tree, item
+ from sitetree.utils import tree, item
+
+ # Be sure you defined `sitetrees` in your module.
+ sitetrees = (
+ # Define a tree with `tree` function.
+ tree('books', items=[
+ # Then define items and their children with `item` function.
+ item('Books', 'books-listing', children=[
+ item('Book named "{{ book.title }}"', 'books-details', in_menu=False, in_sitetree=False),
+ item('Add a book', 'books-add'),
+ item('Edit "{{ book.title }}"', 'books-edit', in_menu=False, in_sitetree=False)
+ ])
+ ]),
+ # ... You can define more than one tree for your app.
+ )
+
- # Be sure you defined `sitetrees` in your module.
- sitetrees = (
- # Define a tree with `tree` function.
- tree('books', items=[
- # Then define items and their children with `item` function.
- item('Books', 'books-listing', children=[
- item('Book named "{{ book.title }}"', 'books-details', in_menu=False, in_sitetree=False),
- item('Add a book', 'books-add'),
- item('Edit "{{ book.title }}"', 'books-edit', in_menu=False, in_sitetree=False)
- ])
- ]),
- # ... You can define more than one tree for your app.
- )
+Please see `tree` and `item` signatures for possible options.
+.. note::
- Please consider `tree` and `item` signatures for possible options.
+ If you added extra fields to the Tree and TreeItem models,
+ then you can specify their values when instantiating `item` see :ref:`custom-model-sitetree`
Export sitetree to DB
@@ -59,7 +64,8 @@ Optionally you can structure app-defined sitetrees into existing or new trees ru
Basically one should compose a dynamic tree with `compose_dynamic_tree()` and register it with `register_dynamic_trees()`.
-Let's suppose the following code is in `setting.py` of your project
+Let's suppose the following code is in `setting.py` (for Django < 1.7; or for Djagno >= 1.7 somewhere where app registry
+is already created, e.g. `urls.py`) of your project.
.. code-block:: python
diff --git a/docs/source/models.rst b/docs/source/models.rst
index b3165f8..023da58 100644
--- a/docs/source/models.rst
+++ b/docs/source/models.rst
@@ -31,7 +31,7 @@ and `TreeItemBase` classes respectively:
class MyTreeItem(TreeItemBase):
"""And that's a tree item model with additional `css_class` field."""
- css_class = models.IntegerField('Tree item CSS class', default=50)
+ css_class = models.CharField('Tree item CSS class', max_length=50)
@@ -57,7 +57,40 @@ to instruct Django to use them for your project instead of built-in ones:
See :ref:`Overriding SiteTree Admin representation <admin-ext>` for more information.
+.. _custom-model-sitetree:
+Sitetree definition with custom models
+--------------------------------------
+
+Given the example model given above, you can now use the extra fields when defining a sitetree programmatically:
+
+.. code-block:: python
+
+ from sitetree.utils import tree, item
+
+ # Be sure you defined `sitetrees` in your module.
+ sitetrees = (
+ # Define a tree with `tree` function.
+ tree('books', items=[
+ # Then define items and their children with `item` function.
+ item('Books', 'books-listing', children=[
+ item('Book named "{{ book.title }}"',
+ 'books-details',
+ in_menu=False,
+ in_sitetree=False,
+ css_class='book-detail'),
+ item('Add a book',
+ 'books-add',
+ css_class='book-add'),
+ item('Edit "{{ book.title }}"',
+ 'books-edit',
+ in_menu=False,
+ in_sitetree=False,
+ css_class='book-edit')
+ ])
+ ]),
+ # ... You can define more than one tree for your app.
+ )
.. _models_referencing:
diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst
index f6aadbb..e03c6df 100644
--- a/docs/source/quickstart.rst
+++ b/docs/source/quickstart.rst
@@ -2,7 +2,8 @@ Getting started
===============
1. Add the **sitetree** application to INSTALLED_APPS in your settings file (usually 'settings.py').
-2. Check that *django.core.context_processors.request* is enabled in TEMPLATE_CONTEXT_PROCESSORS in your settings file.
+2. Check that *django.core.context_processors.request* is added to TEMPLATE_CONTEXT_PROCESSORS in your settings file.
+ For Django 1.8+: *django.template.context_processors.request* should be defined in ``TEMPLATES/OPTIONS/context_processors``.
3. Check that *django.contrib.auth.context_processors.auth* is enabled in TEMPLATE_CONTEXT_PROCESSORS too.
4. Run ``./manage.py syncdb`` to install sitetree tables into database (``./manage.py migrate`` for Django 1.7+).
@@ -35,7 +36,7 @@ Making tree
Taken from `StackOverflow <http://stackoverflow.com/questions/4766807/how-to-use-django-sitetree/4887916#4887916>`_.
-In this tutoral we create sitetree that could handle URI like */categoryname/entryname*.
+In this tutorial we create sitetree that could handle URI like */categoryname/entryname*.
------------
@@ -68,7 +69,7 @@ To create a tree:
In 'Additional settings': check 'URL as Pattern' checkbox.
8. Put '{% load sitetree %}' into yor template to have access to sitetree tags.
-9. Put '{% sitetree_menu from "maintree" %}' into your template to render menu.
+9. Put '{% sitetree_menu from "maintree" include "trunk" %}' into your template to render menu from tree trunk.
10. Put '{% sitetree_breadcrumbs from "maintree" %}' into your template to render breadcrumbs.
------------
diff --git a/docs/source/tags.rst b/docs/source/tags.rst
index b21709f..df1797a 100644
--- a/docs/source/tags.rst
+++ b/docs/source/tags.rst
@@ -168,3 +168,16 @@ Usage example::
{% sitetree_page_description from "mytree" %}
This command renders current page description from tree named 'mytree'.
+
+
+
+.. _tag-ignore-errors:
+
+SITETREE_RAISE_ITEMS_ERRORS_ON_DEBUG
+------------------------------------
+
+DEFAULT: True
+
+There are some rare occasions when you want to turn off errors that are thrown by sitetree even during debug.
+
+Setting SITETREE_RAISE_ITEMS_ERRORS_ON_DEBUG = False will turn them off.
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 7e7eeab..8def38f 100755
--- a/setup.py
+++ b/setup.py
@@ -9,14 +9,19 @@ f.close()
setup(
name='django-sitetree',
version='.'.join(map(str, VERSION)),
+ url='http://github.com/idlesign/django-sitetree',
+
description='This reusable Django app introduces site tree, menu and breadcrumbs navigation elements',
long_description=readme,
- author="Igor 'idle sign' Starikov",
+ license='BSD 3-Clause License',
+
+ author='Igor `idle sign` Starikov',
author_email='idlesign at yandex.ru',
- url='http://github.com/idlesign/django-sitetree',
+
packages=['sitetree'],
include_package_data=True,
zip_safe=False,
+
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
diff --git a/sitetree/__init__.py b/sitetree/__init__.py
index a324acb..57d1053 100644
--- a/sitetree/__init__.py
+++ b/sitetree/__init__.py
@@ -1,4 +1,4 @@
-VERSION = (1, 4, 0)
+VERSION = (1, 5, 0)
default_app_config = 'sitetree.config.SitetreeConfig'
diff --git a/sitetree/locale/nb/LC_MESSAGES/django.mo b/sitetree/locale/nb/LC_MESSAGES/django.mo
new file mode 100644
index 0000000..3b718fa
Binary files /dev/null and b/sitetree/locale/nb/LC_MESSAGES/django.mo differ
diff --git a/sitetree/locale/nb/LC_MESSAGES/django.po b/sitetree/locale/nb/LC_MESSAGES/django.po
new file mode 100644
index 0000000..d90c1bd
--- /dev/null
+++ b/sitetree/locale/nb/LC_MESSAGES/django.po
@@ -0,0 +1,275 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+#
+# Translators:
+# Eirik Krogstad <eirikkr at gmail.com>, 2015
+msgid ""
+msgstr ""
+"Project-Id-Version: django-sitetree\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-09-25 22:11+0700\n"
+"PO-Revision-Date: 2015-04-27 22:49+0000\n"
+"Last-Translator: Eirik Krogstad <eirikkr at gmail.com>\n"
+"Language-Team: Norwegian Bokmål (http://www.transifex.com/projects/p/django-sitetree/language/nb/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: nb\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: admin.py:81
+msgid "Basic settings"
+msgstr "Grunninnstillinger"
+
+#: admin.py:84
+msgid "Access settings"
+msgstr "Tilgangsinnstillinger"
+
+#: admin.py:88
+msgid "Display settings"
+msgstr "Visningsinnstillinger"
+
+#: admin.py:92
+msgid "Additional settings"
+msgstr "Tilleggsinnstillinger"
+
+#: admin.py:153
+msgid ""
+"You are seeing this warning because \"URL as Pattern\" option is active and "
+"pattern entered above seems to be invalid. Currently registered URL pattern "
+"names and parameters: "
+msgstr "Du ser denne advarselen fordi \"URL som mønster\" er aktivert, og mønsteret over ser ut til å være ugyldig. Registrerte navn og parametre for URL-mønstre er som følger:"
+
+#: admin.py:230
+msgid "Item's parent left unchanged. Item couldn't be parent to itself."
+msgstr "Menypunktets forelder er uforandret. Menypunkt kan ikke være forelder til seg selv."
+
+#: models.py:31 models.py:56 templates/admin/sitetree/tree/change_form.html:41
+msgid "Title"
+msgstr "Tittel"
+
+#: models.py:31
+msgid "Site tree title for presentational purposes."
+msgstr "Menytreets visningstittel"
+
+#: models.py:32 models.py:62
+msgid "Alias"
+msgstr "Alias"
+
+#: models.py:32
+msgid ""
+"Short name to address site tree from templates.<br /><b>Note:</b> change "
+"with care."
+msgstr "Kort navn for å referere til menytreet fra maler.<br /><b>Merk:</b> Endre med omhu."
+
+#: models.py:36 models.py:60
+msgid "Site Tree"
+msgstr "Menytre"
+
+#: models.py:37
+msgid "Site Trees"
+msgstr "Menytrær"
+
+#: models.py:52
+msgid "Any"
+msgstr "Noen"
+
+#: models.py:53
+msgid "All"
+msgstr "Alle"
+
+#: models.py:56
+msgid ""
+"Site tree item title. Can contain template variables E.g.: {{ mytitle }}."
+msgstr "Visningstittel for menypunkt. Kan inneholde malvariabler, f.eks. {{ title }}."
+
+#: models.py:57
+msgid "Hint"
+msgstr "Hint"
+
+#: models.py:57
+msgid "Some additional information about this item that is used as a hint."
+msgstr "Tilleggsinformasjon for dette menypunktet, gjerne brukt som et hint."
+
+#: models.py:58 templates/admin/sitetree/tree/change_form.html:42
+msgid "URL"
+msgstr "URL"
+
+#: models.py:58
+msgid "Exact URL or URL pattern (see \"Additional settings\") for this item."
+msgstr "Eksakt nettadresse eller URL-mønster (se \"Tilleggsinnstillinger\") for dette menypunktet"
+
+#: models.py:59
+msgid "URL as Pattern"
+msgstr "URL som mønster"
+
+#: models.py:59
+msgid ""
+"Whether the given URL should be treated as a pattern.<br /><b>Note:</b> "
+"Refer to Django \"URL dispatcher\" documentation (e.g. \"Naming URL "
+"patterns\" part)."
+msgstr "Angir om gitt URL skal håndteres som et mønster.<br /><b>Merk:</b> Referer til Djangos dokumentasjon for \"URL dispatcher\" (f.eks. \"Naming URL patterns\")."
+
+#: models.py:60
+msgid "Site tree this item belongs to."
+msgstr "Menypunkt dette punktet hører inn under"
+
+#: models.py:61 templates/admin/sitetree/tree/change_form.html:34
+msgid "Hidden"
+msgstr "Skjult"
+
+#: models.py:61
+msgid "Whether to show this item in navigation."
+msgstr "Angir om dette menypunktet skal skjules i navigasjon"
+
+#: models.py:62
+#, python-format
+msgid ""
+"Short name to address site tree item from a template.<br /><b>Reserved "
+"aliases:</b> \"%s\"."
+msgstr "Kort navn for å referere til menypunkt fra maler.<br /><b>Reserverte alias:</b> \"%s\"."
+
+#: models.py:63
+msgid "Description"
+msgstr "Beskrivelse"
+
+#: models.py:63
+msgid "Additional comments on this item."
+msgstr "Tilleggskommentarer for dette menypunktet"
+
+#: models.py:64
+msgid "Show in menu"
+msgstr "Vis i meny"
+
+#: models.py:64
+msgid "Whether to show this item in a menu."
+msgstr "Angir om dette menypunktet skal vises i menyer"
+
+#: models.py:65
+msgid "Show in breadcrumb path"
+msgstr "Vis i navigasjonssti"
+
+#: models.py:65
+msgid "Whether to show this item in a breadcrumb path."
+msgstr "Angir om dette menypunktet skal vises i navigasjonsstier"
+
+#: models.py:66
+msgid "Show in site tree"
+msgstr "Vis i nettstedskart"
+
+#: models.py:66
+msgid "Whether to show this item in a site tree."
+msgstr "Angir om dette menypunktet skal vises i kart over nettstedet"
+
+#: models.py:67
+msgid "Logged in only"
+msgstr "Kun innlogget"
+
+#: models.py:67
+msgid "Check it to grant access to this item to authenticated users only."
+msgstr "Angir at menypunktet kun er synlig for autentiserte brukere"
+
+#: models.py:68 templates/admin/sitetree/tree/change_form.html:40
+msgid "Guests only"
+msgstr "Kun gjester"
+
+#: models.py:68
+msgid "Check it to grant access to this item to guests only."
+msgstr "Angir at menypunktet kun er synlig for gjester"
+
+#: models.py:69
+msgid "Restrict access to permissions"
+msgstr "Begrens tilgang med tillatelser"
+
+#: models.py:69
+msgid ""
+"Check it to restrict user access to this item, using Django permissions "
+"system."
+msgstr "Angir at brukers tilgang til menypunktet er avhengig av rettigheter etter Djangos rettighetssystem"
+
+#: models.py:70
+msgid "Permissions granting access"
+msgstr "Rettigheter som gir tilgang"
+
+#: models.py:71
+msgid "Permissions interpretation"
+msgstr "Tolkning av rettigheter"
+
+#: models.py:71
+msgid ""
+"<b>Any</b> — user should have any of chosen permissions. <b>All</b> "
+"— user should have all chosen permissions."
+msgstr "<b>Noen</b> — brukeren må ha en eller flere valgte rettigheter. <b>Alle</b> — brukeren må ha alle valgte rettigheter."
+
+#: models.py:74
+msgid "Parent"
+msgstr "Forelder"
+
+#: models.py:74
+msgid "Parent site tree item."
+msgstr "Forelder til dette menypunktet"
+
+#: models.py:75 templates/admin/sitetree/tree/change_form.html:43
+msgid "Sort order"
+msgstr "Sortering"
+
+#: models.py:75
+msgid "Item position among other site tree items under the same parent."
+msgstr "Menypunktets posisjon blant andre menypunkter under samme forelder"
+
+#: models.py:89
+msgid "Site Tree Item"
+msgstr "Menypunkt"
+
+#: models.py:90 templates/admin/sitetree/tree/change_form.html:17
+msgid "Site Tree Items"
+msgstr "Menypunkter"
+
+#: templates/admin/sitetree/tree/change_form.html:24
+msgid "Add Site Tree item"
+msgstr "Legg til menypunkt"
+
+#: templates/admin/sitetree/tree/change_form.html:35
+msgid "Menu"
+msgstr "Meny"
+
+#: templates/admin/sitetree/tree/change_form.html:36
+msgid "Breadcrumbs"
+msgstr "Navigasjonssti"
+
+#: templates/admin/sitetree/tree/change_form.html:37
+msgid "Tree"
+msgstr "Tre"
+
+#: templates/admin/sitetree/tree/change_form.html:38
+msgid "Restricted"
+msgstr "Avgrenset"
+
+#: templates/admin/sitetree/tree/change_form.html:39
+msgid "Users only"
+msgstr "Kun brukere"
+
+#: templates/admin/sitetree/tree/tree.html:23
+msgid "Move up"
+msgstr "Flytt opp"
+
+#: templates/admin/sitetree/tree/tree.html:25
+msgid "Move down"
+msgstr "Flytt ned"
+
+#: templates/admin/sitetree/treeitem/breadcrumbs.html:5
+msgid "Home"
+msgstr "Hjem"
+
+#: templates/admin/sitetree/treeitem/breadcrumbs.html:11
+msgid "Delete"
+msgstr "Slett"
+
+#: templates/admin/sitetree/treeitem/breadcrumbs.html:15
+msgid "History"
+msgstr "Historikk"
+
+#: templates/admin/sitetree/treeitem/breadcrumbs.html:17
+msgid "Add"
+msgstr "Legg til"
\ No newline at end of file
diff --git a/sitetree/management/commands/sitetree_resync_apps.py b/sitetree/management/commands/sitetree_resync_apps.py
index bfda768..b389b32 100644
--- a/sitetree/management/commands/sitetree_resync_apps.py
+++ b/sitetree/management/commands/sitetree_resync_apps.py
@@ -5,6 +5,7 @@ from django.db import DEFAULT_DB_ALIAS
from sitetree.utils import get_tree_model, import_project_sitetree_modules
from sitetree.settings import APP_MODULE_NAME
+from sitetree.sitetreeapp import Cache
MODEL_TREE_CLASS = get_tree_model()
@@ -12,12 +13,17 @@ MODEL_TREE_CLASS = get_tree_model()
class Command(BaseCommand):
- help = 'Places sitetrees of the project applications (defined in `app_name.sitetree.py`) into DB, replacing old ones if any.'
+ help = 'Places sitetrees of the project applications (defined in `app_name.sitetree.py`) into DB, ' \
+ 'replacing old ones if any.'
+
args = '[app_name app_name ...]'
+
option_list = BaseCommand.option_list + (
- make_option('--database', action='store', dest='database',
- default=DEFAULT_DB_ALIAS, help='Nominates a specific database to place trees and items into. Defaults to the "default" database.'),
- )
+ make_option(
+ '--database', action='store', dest='database', default=DEFAULT_DB_ALIAS,
+ help='Nominates a specific database to place trees and items into. Defaults to the "default" database.'
+ ),
+ )
def handle(self, *apps, **options):
using = options.get('database', DEFAULT_DB_ALIAS)
@@ -30,7 +36,7 @@ class Command(BaseCommand):
for module in tree_modules:
sitetrees = getattr(module, 'sitetrees', None)
app = module.__dict__['__package__']
- if not apps or (apps and app in apps):
+ if not apps or app in apps:
if sitetrees is not None:
self.stdout.write('Sitetrees found in `%s` app ...\n' % app)
for tree in sitetrees:
@@ -52,3 +58,5 @@ class Command(BaseCommand):
# Copy permissions to M2M field once `item`
# has been saved
item.access_permissions = item.permissions
+
+ Cache.reset()
diff --git a/sitetree/runtests.py b/sitetree/runtests.py
index 4c355b4..90d67bf 100755
--- a/sitetree/runtests.py
+++ b/sitetree/runtests.py
@@ -17,7 +17,7 @@ def main():
DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3'}},
ROOT_URLCONF = 'sitetree.tests',
MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES, # Prevents Django 1.7 warning.
- TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
+ TEMPLATE_CONTEXT_PROCESSORS=tuple(global_settings.TEMPLATE_CONTEXT_PROCESSORS) + (
'django.core.context_processors.request',
)
)
diff --git a/sitetree/settings.py b/sitetree/settings.py
index 1f51caa..218bde5 100644
--- a/sitetree/settings.py
+++ b/sitetree/settings.py
@@ -8,6 +8,12 @@ APP_MODULE_NAME = getattr(settings, 'SITETREE_APP_MODULE_NAME', 'sitetrees')
UNRESOLVED_ITEM_MARKER = getattr(settings, 'SITETREE_UNRESOLVED_ITEM_MARKER', u'#unresolved')
+RAISE_ITEMS_ERRORS_ON_DEBUG = getattr(settings, 'SITETREE_RAISE_ITEMS_ERRORS_ON_DEBUG', True)
+
+# Sitetree objects are stored in Django cache for a year (60 * 60 * 24 * 365 = 31536000 sec).
+# Cache is only invalidated on sitetree or sitetree item change.
+CACHE_TIMEOUT = getattr(settings, 'SITETREE_CACHE_TIMEOUT', 31536000)
+
# Reserved tree items aliases.
ALIAS_TRUNK = 'trunk'
ALIAS_THIS_CHILDREN = 'this-children'
diff --git a/sitetree/sitetreeapp.py b/sitetree/sitetreeapp.py
index 70417a7..2f79c64 100644
--- a/sitetree/sitetreeapp.py
+++ b/sitetree/sitetreeapp.py
@@ -5,6 +5,7 @@ import warnings
from collections import defaultdict
from copy import copy, deepcopy
from threading import local
+from functools import partial
from django.conf import settings
from django import VERSION
@@ -24,17 +25,19 @@ from django.template.defaulttags import url as url_tag
from .utils import get_tree_model, get_tree_item_model, import_app_sitetree_module, generate_id_for
from .settings import (
ALIAS_TRUNK, ALIAS_THIS_CHILDREN, ALIAS_THIS_SIBLINGS, ALIAS_THIS_PARENT_SIBLINGS, ALIAS_THIS_ANCESTOR_CHILDREN,
- UNRESOLVED_ITEM_MARKER)
+ UNRESOLVED_ITEM_MARKER, RAISE_ITEMS_ERRORS_ON_DEBUG, CACHE_TIMEOUT)
+
+
+if VERSION >= (1, 9, 0):
+ get_lexer = partial(Lexer)
+else:
+ get_lexer = partial(Lexer, origin=UNKNOWN_SOURCE)
MODEL_TREE_CLASS = get_tree_model()
MODEL_TREE_ITEM_CLASS = get_tree_item_model()
-# Sitetree objects are stored in Django cache for a year (60 * 60 * 24 * 365 = 31536000 sec).
-# Cache is only invalidated on sitetree or sitetree item change.
-CACHE_TIMEOUT = 31536000
-
# Holds tree items processor callable or None.
_ITEMS_PROCESSOR = None
# Holds aliases of trees that support internationalization.
@@ -188,7 +191,9 @@ def register_dynamic_trees(trees, *args, **kwargs):
reset_cache = kwargs.get('reset_cache', False)
if reset_cache:
- get_sitetree().cache_empty()
+ cache = get_sitetree().cache
+ cache.empty()
+ cache.reset()
def get_dynamic_trees():
@@ -243,7 +248,7 @@ class LazyTitle(object):
self.title = title
def __str__(self):
- my_lexer = Lexer(self.title, UNKNOWN_SOURCE)
+ my_lexer = get_lexer(self.title)
my_tokens = my_lexer.tokenize()
# Deliberately strip off template tokens that are not text or variable.
@@ -258,51 +263,73 @@ class LazyTitle(object):
return self.__str__() == other
-class SiteTree(object):
-
- _global_context = Context()
+class Cache(object):
+ """Contains cache-related stuff."""
def __init__(self):
self.cache = None
+
+ cache_empty = self.empty
# Listen for signals from the models.
- signals.post_save.connect(self.cache_empty, sender=MODEL_TREE_CLASS)
- signals.post_save.connect(self.cache_empty, sender=MODEL_TREE_ITEM_CLASS)
- signals.post_delete.connect(self.cache_empty, sender=MODEL_TREE_ITEM_CLASS)
+ signals.post_save.connect(cache_empty, sender=MODEL_TREE_CLASS)
+ signals.post_save.connect(cache_empty, sender=MODEL_TREE_ITEM_CLASS)
+ signals.post_delete.connect(cache_empty, sender=MODEL_TREE_ITEM_CLASS)
# Listen to the changes in item permissions table.
- signals.m2m_changed.connect(self.cache_empty, sender=MODEL_TREE_ITEM_CLASS.access_permissions)
+ signals.m2m_changed.connect(cache_empty, sender=MODEL_TREE_ITEM_CLASS.access_permissions)
- def cache_init(self):
+ @classmethod
+ def reset(cls):
+ """Instructs sitetree to drop and recreate cache.
+
+ Could be used to show up tree changes made in a different process.
+
+ """
+ cache.get('sitetrees_reset', True)
+
+ def init(self):
"""Initializes local cache from Django cache."""
+
+ # Drop cache flag set by .reset() method.
+ cache.get('sitetrees_reset') and self.empty()
+
cache_ = cache.get('sitetrees')
if cache_ is None:
# Init cache dictionary with predefined entries.
cache_ = {'sitetrees': {}, 'urls': {}, 'parents': {}, 'items_by_ids': {}, 'tree_aliases': {}}
self.cache = cache_
- def cache_save(self):
+ def save(self):
"""Saves sitetree data to Django cache."""
cache.set('sitetrees', self.cache, CACHE_TIMEOUT)
- def cache_empty(self, **kwargs):
+ def empty(self, **kwargs):
"""Empties cached sitetree data."""
self.cache = None
cache.delete('sitetrees')
- cache.delete('tree_aliases')
+ cache.delete('sitetrees_reset')
- def get_cache_entry(self, entry_name, key):
+ def get_entry(self, entry_name, key):
"""Returns cache entry parameter value by its name."""
return self.cache[entry_name].get(key, False)
- def update_cache_entry_value(self, entry_name, key, value):
+ def update_entry_value(self, entry_name, key, value):
"""Updates cache entry parameter with new data."""
if key not in self.cache[entry_name]:
self.cache[entry_name][key] = {}
self.cache[entry_name][key].update(value)
- def set_cache_entry(self, entry_name, key, value):
+ def set_entry(self, entry_name, key, value):
"""Replaces entire cache entry parameter data by its name with new data."""
self.cache[entry_name][key] = value
+
+class SiteTree(object):
+
+ _global_context = Context()
+
+ def __init__(self):
+ self.cache = Cache()
+
@classmethod
def set_global_context(cls, context):
"""Saves context as global context if not already set or if changed.
@@ -325,10 +352,10 @@ class SiteTree(object):
if alias in _I18N_TREES:
current_language_code = self.lang_get().replace('_', '-').split('-')[0]
i18n_tree_alias = '%s_%s' % (alias, current_language_code)
- trees_count = self.get_cache_entry('tree_aliases', i18n_tree_alias)
+ trees_count = self.cache.get_entry('tree_aliases', i18n_tree_alias)
if trees_count is False:
trees_count = MODEL_TREE_CLASS.objects.filter(alias=i18n_tree_alias).count()
- self.set_cache_entry('tree_aliases', i18n_tree_alias, trees_count)
+ self.cache.set_entry('tree_aliases', i18n_tree_alias, trees_count)
if trees_count:
alias = i18n_tree_alias
return alias
@@ -383,7 +410,11 @@ class SiteTree(object):
def current_app_is_admin(self):
"""Returns boolean whether current application is Admin contrib."""
- return self._global_context.current_app == 'admin'
+ current_app = (
+ getattr(self._global_context.get('request', None), 'current_app',
+ self._global_context.current_app))
+
+ return current_app == 'admin'
def get_sitetree(self, alias):
"""Gets site tree items from the given site tree.
@@ -391,33 +422,39 @@ class SiteTree(object):
Returns (tree alias, tree items) tuple.
"""
- self.cache_init()
+ # Cache aliases for speedup.
+ cache = self.cache
+ get_cache_entry = cache.get_entry
+ set_cache_entry = cache.set_entry
+
+ cache.init()
+
sitetree_needs_caching = False
if not self.current_app_is_admin():
# We do not need i18n for a tree rendered in Admin dropdown.
alias = self.resolve_tree_i18n_alias(alias)
- sitetree = self.get_cache_entry('sitetrees', alias)
+ sitetree = get_cache_entry('sitetrees', alias)
if not sitetree:
sitetree = MODEL_TREE_ITEM_CLASS.objects.select_related('parent', 'tree').\
filter(tree__alias__exact=alias).order_by('parent__sort_order', 'sort_order')
sitetree = self.attach_dynamic_tree_items(alias, sitetree)
- self.set_cache_entry('sitetrees', alias, sitetree)
+ set_cache_entry('sitetrees', alias, sitetree)
sitetree_needs_caching = True
- parents = self.get_cache_entry('parents', alias)
+ parents = get_cache_entry('parents', alias)
if not parents:
parents = defaultdict(list)
for item in sitetree:
parent = getattr(item, 'parent')
parents[parent].append(item)
- self.set_cache_entry('parents', alias, parents)
+ set_cache_entry('parents', alias, parents)
# Prepare items by ids cache if needed.
if sitetree_needs_caching:
# We need this extra pass to avoid future problems on items depth calculation.
for item in sitetree:
- self.update_cache_entry_value('items_by_ids', alias, {item.id: item})
+ cache.update_entry_value('items_by_ids', alias, {item.id: item})
for item in sitetree:
if sitetree_needs_caching:
@@ -429,8 +466,13 @@ class SiteTree(object):
# Resolve item permissions.
if item.access_restricted:
- item.perms = set([u'%s.%s' % (perm.content_type.app_label, perm.codename) for perm in
- item.access_permissions.select_related()])
+ permissions_src = (
+ item.permissions if getattr(item, 'is_dynamic', False)
+ else item.access_permissions.select_related())
+
+ item.perms = set(
+ ['%s.%s' % (perm.content_type.app_label, perm.codename) for perm in permissions_src])
+
# Contextual properties.
item.url_resolved = self.url(item)
if VARIABLE_TAG_START in item.title:
@@ -445,7 +487,7 @@ class SiteTree(object):
# Save sitetree data into cache if needed.
if sitetree_needs_caching:
- self.cache_save()
+ cache.save()
return alias, sitetree
... 545 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-sitetree.git
More information about the Python-modules-commits
mailing list