{ "info": { "author": "Greg Brown", "author_email": "greg@gregbrown.co.nz", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "django-pubtools is a helper library for creating publishable django models.\n\n[![Circle CI](https://circleci.com/gh/gregplaysguitar/django-pubtools.svg?style=svg)](https://circleci.com/gh/gregplaysguitar/django-pubtools)\n[![codecov](https://codecov.io/gh/gregplaysguitar/django-pubtools/branch/master/graph/badge.svg)](https://codecov.io/gh/gregplaysguitar/django-pubtools)\n[![Latest Version](https://img.shields.io/pypi/v/django-pubtools.svg?style=flat)](https://pypi.python.org/pypi/django-pubtools/)\n\n## Overview\n\nExtend the `AbstractPublishableModel` class to create a publishable model class.\n\n- Publishable content can be in either draft, preview, or published status.\n- Draft content may be previewed on the site by a logged-in staff member\n- Preview content may be previewed publicly, via a special url\n\n\n## Installation\n\n pip install django-pubtools\n\n\n## Example implementation\n\nmodels.py:\n\n```python\nfrom django.db import models\nimport pubtools.models\n\nclass Article(pubtools.models.AbstractPublishableModel):\n title = models.CharField(max_length=100)\n```\n\nviews.py:\n\n```python\nfrom django.http import HttpResponse\nfrom .models import Article\n\ndef article(request, id):\n # pass the request to enable staff preview\n articles = Article.objects.published(request)\n article = articles.get(id=id)\n return HttpResponse(article.title)\n```\n\nadmin.py:\n\n```python\nfrom django.contrib import admin\nfrom baseclasses.admin import PublishableModelAdminMixin\n\nfrom .models import Article\n\n@admin.register(Article)\nclass ArticleAdmin(PublishableModelAdminMixin, admin.ModelAdmin):\n list_display = ['title']\n```\n\n## Reference\n\n### `pubtools.models.AbstractPublishableModel`\n\n##### Model fields\n\n- `created` (datetime, set on creation)\n- `last_updated` (datetime, updated on save)\n- `pub_date` (date)\n- `pub_status` (one of draft, review or published)\n\n##### Model methods\n\n- `published` (property) return True if the instance is published\n- `get_prev_published(qs=None, loop=False)` get previous published instance\n- `get_next_published(qs=None, loop=False)` get next published instance\n\n### `pubtools.models.PublishableModelQuerySet`\n\n##### Manager/queryset methods\n\n- `published(self, request=None)` If request is passed, and a preview status\n flag is in request.GET, then check if the user is a staff member, and\n return objects with the requested status if so. Otherwise, return only\n published objects.\n\n### `pubtools.admin.PublishableModelAdminMixin`\n\n- Overrides `view_on_site` to add a flag to urls for draft/preview content.\n- Adds a \"Publish selected\" action to the admin", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gregplaysguitar/django-pubtools", "keywords": "django,publishing", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-pubtools", "package_url": "https://pypi.org/project/django-pubtools/", "platform": "any", "project_url": "https://pypi.org/project/django-pubtools/", "project_urls": { "Homepage": "https://github.com/gregplaysguitar/django-pubtools" }, "release_url": "https://pypi.org/project/django-pubtools/2.0.4/", "requires_dist": null, "requires_python": "", "summary": "A set of reusable base classes and helpers for django", "version": "2.0.4" }, "last_serial": 3391958, "releases": { "2.0.0": [ { "comment_text": "", "digests": { "md5": "eed6b3bb912e1aca875758b8702ecb74", "sha256": "3e16277d6b8af97826d5b6aab14c5e8a3975c79ca852b3f6fe43697312dcc8f2" }, "downloads": -1, "filename": "django-pubtools-2.0.0.tar.gz", "has_sig": false, "md5_digest": "eed6b3bb912e1aca875758b8702ecb74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6170, "upload_time": "2017-11-28T03:21:18", "url": "https://files.pythonhosted.org/packages/b5/4c/e98bf2c19a539f4ab10556ff096a0c87c7009db6cf1751028740844acbfd/django-pubtools-2.0.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "63f4e1ada218622bfd8274c2358458c6", "sha256": "9bf6abd5f12c0cc01ed26a13a5c1816403e9cdea589658f0c52cde4d77f43ff1" }, "downloads": -1, "filename": "django-pubtools-2.0.1.tar.gz", "has_sig": false, "md5_digest": "63f4e1ada218622bfd8274c2358458c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6450, "upload_time": "2017-11-28T20:52:49", "url": "https://files.pythonhosted.org/packages/cf/4f/d49ec929496e2a178e9be11f01db481b3cedc8250ed940f7da0ef09e68b5/django-pubtools-2.0.1.tar.gz" } ], "2.0.2": [ { "comment_text": "", "digests": { "md5": "de0432b479b768a10582414250d9d36c", "sha256": "ae4c4dff98b0879f720f069c297213320868795cfdfc94e8c9ce50b32505c12e" }, "downloads": -1, "filename": "django-pubtools-2.0.2.tar.gz", "has_sig": false, "md5_digest": "de0432b479b768a10582414250d9d36c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6457, "upload_time": "2017-11-29T02:31:07", "url": "https://files.pythonhosted.org/packages/d8/1e/151f68dbb134027146b9de3241fc128be4f3498ea7b240b3be9b36dadfd1/django-pubtools-2.0.2.tar.gz" } ], "2.0.3": [ { "comment_text": "", "digests": { "md5": "783d9944da8b502b1794bf06c73bd2ee", "sha256": "a642c50d39852d9e2f16741191e40be75e09395520a299526cb807c259df90fc" }, "downloads": -1, "filename": "django-pubtools-2.0.3.tar.gz", "has_sig": false, "md5_digest": "783d9944da8b502b1794bf06c73bd2ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6456, "upload_time": "2017-11-29T02:33:19", "url": "https://files.pythonhosted.org/packages/9d/db/802a3a2f1e2160f7d02ce37c77e3ce614b02eb10fdff14b23a58ba95ed63/django-pubtools-2.0.3.tar.gz" } ], "2.0.4": [ { "comment_text": "", "digests": { "md5": "feb9eec2c5dacebb8c3b5d2cbb159b1a", "sha256": "c7dacdbc91c73275287ee7d0de8833928c4cc3f54cf2ffc67e52240be5cb6517" }, "downloads": -1, "filename": "django-pubtools-2.0.4.tar.gz", "has_sig": false, "md5_digest": "feb9eec2c5dacebb8c3b5d2cbb159b1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6439, "upload_time": "2017-12-05T22:02:45", "url": "https://files.pythonhosted.org/packages/1e/e1/1f7c87d9016c75ec2555e26483949bb7b6ed450f3d3076133369a614e449/django-pubtools-2.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "feb9eec2c5dacebb8c3b5d2cbb159b1a", "sha256": "c7dacdbc91c73275287ee7d0de8833928c4cc3f54cf2ffc67e52240be5cb6517" }, "downloads": -1, "filename": "django-pubtools-2.0.4.tar.gz", "has_sig": false, "md5_digest": "feb9eec2c5dacebb8c3b5d2cbb159b1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6439, "upload_time": "2017-12-05T22:02:45", "url": "https://files.pythonhosted.org/packages/1e/e1/1f7c87d9016c75ec2555e26483949bb7b6ed450f3d3076133369a614e449/django-pubtools-2.0.4.tar.gz" } ] }