The Minipub model

from minipub.models import MinipubModel

class Article(MinipubModel):
    ...

MinipubModel is an abstract model that provides the following 3 fields:

  • status: a list of choices; default is ‘draft’ or ‘published’.
  • start: a start date; defaults to date of publication.
  • end: an end date; optional.

Timestamps

MinipubModel also adds the following fields that get auto-updated and should not be manually modified: created, modified and status_changed.

The concept of ‘Live’ objects

Objects are usually considered ‘live’ if they are ‘published’ and between the start and end dates - this is usually sufficient for them being available to display in the public website.

live() methods are available both as a chainable filter on a queryset, and as an instance method. For example, if you have an Article model that uses MinipubModel:

my_articles = Article.objects.live()

or

can_be_viewed = article1.live()

Extra statuses

Models can have more statuses than draft, published - see here for more details.

Sitemaps

If you have defined a sitemap.xml, refer also to the sitemaps page.

‘staff_preview’ property

MinipubModel.staff_preview()

Helper property - says if this object is being previewed by a member of staff.

Can be used when displaying objects in the website - members of staff will see all objects, using this property in the template can help for attaching a message/custom CSS saying that this object is being previewed.

For example, in the example_project we have this snippet:

{% if article.staff_preview %}
    <div class="label label-warning">This is a preview</div>
{% endif %}