{ "info": { "author": "Vladimir Savin", "author_email": "zero13cool@yandex.ru", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4" ], "description": "django-vest\n===========\n\n.. image:: https://img.shields.io/pypi/v/django-vest.svg\n :target: https://pypi.python.org/pypi/django-vest\n :alt: Latest PyPI version\n\n.. image:: https://travis-ci.org/zerc/django-vest.svg?branch=master\n :target: https://travis-ci.org/zerc/django-vest\n :alt: Build status\n\nExtension for default template system for making inheritance more flexible. Adding some kind of themes.\n\nUsage\n-----\nImagine you have several sites on different hosts. They differ by visually and small functional. ``django-vest`` this is a way to use one code base for this situation.\n\nHe allowing to split templates on ``themes`` - one per site. We also have extended inheritance between themes - we have `DEFAULT_THEME` and we can override each template in `CURRENT_THEME`. Exmaple:\n\n.. code:: html\n\n {% extends 'DEFAULT_THEME/index.html' %}\n {% block page_title %}Dark theme{% endblock %}\n\n``django-vest`` have some tools for logic splitting according by ``CURRENT_THEME`` in views. Assume we have some ``form`` class who is different in each theme. Then our code may looks like:\n\n\n.. code:: python\n\n # forms.py\n from django_vest.decorators import themeble\n\n @themeble(name='Form', themes=('dark_theme',))\n class DarkThemeForm(object):\n ''' Some kind of logic/fields for dark_theme form\n '''\n name = 'DarkThemeForm'\n\n\n @themeble(name='Form')\n class DefaultForm(object):\n ''' Default logic/fields for all themes\n '''\n name = 'Default form'\n\n\n # views.py\n from .forms import Form\n\n\nIn example bellow ``Form`` class will be alias for DarkThemeForm if ``settings.CURRENT_THEME == 'dark_theme'`` otherwise it is ``DefaultForm``.\n\nIf you want restricting access to views according by ``CURRENT_THEME`` just use ``only_for`` decorator:\n\n.. code:: python\n\n # views.py\n from django.http import Http404\n from django.views.generic.base import TemplateView\n\n from django_vest import only_for\n\n @only_for('black_theme')\n def my_view(request):\n ...\n\n # Redirect for special page\n dark_theme_page = only_for('dark_theme', redirect_to='restict_access')(\n TemplateView.as_view(template_name='dark_theme_page.html'))\n\n # Raise Http404 when user trying to open page with invalid theme\n dark_theme_page_not_found = \\\n only_for('dark_theme', raise_error=Http404)(\n TemplateView.as_view(template_name='dark_theme_page.html'))\n\n\n**Extends for default templates**\n\nVersion 0.1.3 has a new template loader ``django_vest.templates_loaders.AppsLoader`` and new keyword ``DJANGO_ORIGIN``.\n\nNow we can override default django admin template without copy past of full origin file.\n\nExample:\n\nFile: ``templates/main_theme/admin/change_list.html``\n\n.. code:: html\n\n {% extends \"DJANGO_ORIGIN/admin/change_list.html\" %}\n {% load i18n admin_urls admin_static admin_list %}\n\n {% block breadcrumbs %}\n