armstrong.core.arm_sections

Provides the basic section objects
Download

armstrong.core.arm_sections Ranking & Summary

Advertisement

  • Rating:
  • License:
  • The Apache License 2.0
  • Publisher Name:
  • Bay Citizen & Texas Tribune
  • Publisher web site:
  • http://armstrongcms.org

armstrong.core.arm_sections Tags


armstrong.core.arm_sections Description

Provides the basic section objects armstrong.core.arm_sections is a Python module that provides the basic concept of sections within an Armstrong site (http://armstrongcms.org).WarningThis is development level software. Please do not unless you are familiar with what that means and are comfortable using that type of software.Sections give you a way to organize your content into logical groups. Sections can have a parent section to allow you to create a hierarchy. For example, the Texas Tribune has an Immigration section which in turns has Sanctuary Cities and Dream Act as children sections.Of course, you can create a flat infrastructure too if you would like. Simply ignore the parent/child features present. The parent/child relationship is managed through a django-mptt using a technique called modified preordered tree traversal.UsageYou need to add a section field to any model that you would like to show up in a given section. For example:# your models.pyfrom django.db import modelsfrom armstrong.core.arm_sections.models import Sectionclass MyArticle(models.Model): title = models.CharField(max_length=100) body = models.TextField() section = models.ForeignKey(Section)You can also relate to multiple sections as well through a ManyToManyField.Getting Items in a SectionSections provide a property called items which allow you to access all of the items associated with them. items is powered by backends so it can look at the most efficient place to figure out how to get what is associated with it.The easiest to set up is the standard database-powered QuerySet. The default one is configurable by the following settings:# Default model to useARMSTRONG_SECTIONS_QUERYSET_BACKEND = "mysite.models.MyContent"You can also set a per-slug QuerySet to swap out what QuerySet you use for each type of Section.#ARMSTRONG_SECTIONS_QUERYSET_BACKEND = { "immigration": "other.models.SomeOtherModel", "immigration/dream-act": "other.models.YetAnotherModel", "immigration/sanctuary-cities": "other.utils.some_callable",}The keys are the full slug of a given Section. Slugs are determined by joining the slug with all of the slugs of its parents. For example, sanctuary-cities is the slug for the Section that is a child of the Section with a slug of immigration.If the provided us callable, it will be executed and passed Section object that is trying to find its items. If it's not executable, it will attempt to an objects property on the class (normally a model) and attempt to call by_section() to determine which models are available for the given section.Note: Additional backends are planned.Installationpip install -e git://github.com/armstrongcms/armstrong.core.arm_sections Requirements: · Python


armstrong.core.arm_sections Related Software