Skip to main content

Small CMS built around a tree navigation open to any django models

Project description

coop_cms is a Content Management System (CMS) for Django

Yet another CMS ?

  1. Coop-cms is built around Articles. It defines a basic abstract model so you can define your own model.

  2. It has a website tree in a nice admin widget, to let you order Articles and any other standard django model you’ve defined in your project.

  3. Based on the tree, you get templatetags for menu navigation, siblings links, breadcrumb, etc

Coop-cms has some sister apps to make it more usable:

  • coop_bar, an extensible toolbar (same concept : any app you create can add links in the toolbar).

  • coop_html_editor, integration of in-site html editors._

  • colorbox, make easy integration of jquery colorbox library.

Quick start

Python 3, Django >=2.0, < 3.0 required

Install it with pip install apidev_coop_cms

urls.py

At the very end of your urls.py file, add:

urlpatterns += [
    url(r'^html-editor/', include('coop_html_editor.urls')),
    url(r'^', include('coop_cms.urls')),
    url(r'^coop_bar/', include('coop_bar.urls')),
]

Please note that coop-cms will handle any page slug, except the ones you will have defined before.

settings.py

In settings.py:

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'coop_cms.middleware.PermissionsMiddleware',  # Optional: redirect to login when PermissionDenied is raised
    'coop_cms.utils.RequestMiddleware',
    ...
)

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.template.context_processors.debug",
    "django.template.context_processors.i18n",
    'django.template.context_processors.request',
    "django.template.context_processors.media",
    "django.template.context_processors.static",
    "django.contrib.messages.context_processors.messages",
    ...
)

AUTHENTICATION_BACKENDS = (
    'coop_cms.perms_backends.ArticlePermissionBackend',
    'coop_cms.apps.email_auth.auth_backends.EmailAuthBackend',  # Optional -> login with email rather than username
    'django.contrib.auth.backends.ModelBackend', # Django's default auth backend
)

INSTALLED_APPS = (
    # Contribs
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',

    # 3rd parties
    'django_extensions',
    'sorl.thumbnail',
    'floppyforms',
    'registration', # Optional

    # apps
    'coop_bar',
    'coop_html_editor',
    'colorbox',
    'coop_cms',
    'coop_cms.apps.coop_bootstrap', # Optional -> utilities for Bootstrap CSS framework
    'coop_cms.apps.email_auth', # Optional -> login with email rather than username

    # The coop_cms Article is an abstract model, you must define an Article in one of your app
    # We provide 2 apps that can be used if needed. Choose one or the other
    # 'coop_cms.apps.basic_cms', # Nothing else than a concrete Article model.
    'coop_cms.apps.demo_cms', # A ready-to-use example app.

    # The app below make possible to create articles from a RSS feed. Add it if needed
    'coop_cms.apps.rss_sync',
)

# These are settings to customize the CMS behavior. The values are just examples and correspond to the demo_cms app.

# Define the Concrete Article to use. Not required if basic_cms is used
COOP_CMS_ARTICLE_CLASS = 'coop_cms.apps.demo_cms.models.Article'

# Define a custom form for Article editing. Not required if basic_cms is used
COOP_CMS_ARTICLE_FORM = 'coop_cms.apps.demo_cms.forms.ArticleForm'

# Make possible to customize the menus in the admin bar. Optional.
# If not defined, the tuple is build with the coop_bar_cfg modules of all INSTALLED_APPS
COOPBAR_MODULES = (
    'coop_cms.apps.demo_cms.my_coop_bar',
)

# Populate the urls when editing <a> tag in HTML editor
COOP_HTML_EDITOR_LINK_MODELS = (
    'demo_cms.Article',
)

# Optional: you can overload the aloha plugins used by coop_cms --> see coop_html_editor docs for details
ALOHA_PLUGINS = (
    "common/format",
    "common/highlighteditables",
)

# Optional: you can change the jquery version used by aloha --> see coop_html_editor docs for details
ALOHA_JQUERY = 'js/jquery.1.7.2.js'

# Optional : you can customize the whole behavior of aloha by proving the url of config file.
# It will overload the config provided by coop_html_editor --> see coop_html_editor for details
ALOHA_INIT_URL = '/static/js/my_aloha_config.js'

# Default size of the article logo. Can be changed in template
COOP_CMS_ARTICLE_LOGO_SIZE = "128x128"

# Templates that can be used for an article
# It can be a tuple or a function returning a tuple
COOP_CMS_ARTICLE_TEMPLATES = 'coop_cms.apps.demo_cms.get_article_templates'
# COOP_CMS_ARTICLE_TEMPLATES = (
#     ('standard.html', 'Standard'),
#     ('homepage.html', 'Homepage'),
#     ('blog.html', 'Blog'),
# )

# Prefix for making absolute links
COOP_CMS_SITE_PREFIX = 'http://127.0.0.1:8000'

# from email : the domain of this address should allow the IP of your SMTP server : See SPF
COOP_CMS_FROM_EMAIL = '"Your name" <your@email.com>'

# TODO : REPLY-TO
COOP_CMS_REPLY_TO = '"Your name" <your@email.com>'

# Email address to send a newsletter test
COOP_CMS_TEST_EMAILS = (
    '"Your name" <your@email.com>',
)

# tuples of templates that can be used for a newsletter.
COOP_CMS_NEWSLETTER_TEMPLATES = (
    ('basic_newsletter.html', 'Basic'),
    ('special_newsletter.html', 'With sections'),
    ('sortable_newsletter.html', 'Sortable sections'),
)
# optional : A custom form for editing the newsletter
COOP_CMS_NEWSLETTER_FORM = 'coop_cms.apps.demo_cms.forms.SortableNewsletterForm'

Base template

You need to create a base template base.html in one of your template folders. The article.html will inherit from this base template.

You need the following templatetags libs:

{% load coop_navigation coop_bar_tags %}

In the <head> of the document:

{% coop_bar_headers %}
{% block jquery_declaration %}{% endblock %}
{% block extra_head %}{% endblock %}

In the <body> of the document:

{% block document %}...{% endblock %}
{% coop_bar %}

Just before </body> at the end of the document:

{% coop_bar_footer %}

You can also put some navigations in the <body>:

{% navigation_as_nested_ul %}
The navigation_as_nested_ul templatetag accepts several args
  • tree=”english” –> The name of the navigation_tree to use. “default” if missing

  • li_template=”dropdown_li.html” –> a template for every <li> tags

  • ul_template=”dropdown_ul.html” –> a template for every <ul> tags

  • li_args=”dropdown_li_class.html” –> args to be used for any <li> tags

There are others templatetags for navigation : navigation_breadcrumb, navigation_children, navigation_siblings with similar behavior

Going further

You can look at the demo_app in apps folder to see how to customize the behavior of coop_cms:
  • Editable “pieces of HTML” in your page : A editable block that can be shared by several pages.

  • Custom templates for articles and newsletters

  • Custom fields in article

  • Custom admin bar

  • Configuration values

Internationalization

If you want to make an international site, coop_cms works well with django-modeltranslation.

We recommend to remove django-modeltranslation from the apps when making the model migrations

if not (len(sys.argv) > 1 and sys.argv[1] in (‘makemigrations’, )):

INSTALLED_APPS = (‘modeltranslation’, ) + INSTALLED_APPS

The model migrations wil not take the translation fields into account and it will be easier to add or remove languages with the following commands

python manage.py sync_translation_fields –noinput python manage.py update_translation_fields

License

apidev-coop-cms is a fork of credis/coop_cms and uses BSD license see license.txt.

coop-cms development was funded by CREDIS, FSE (European Social Fund) and Conseil Regional d’Auvergne.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apidev_coop_cms-1.6.17.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apidev_coop_cms-1.6.17-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file apidev_coop_cms-1.6.17.tar.gz.

File metadata

  • Download URL: apidev_coop_cms-1.6.17.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for apidev_coop_cms-1.6.17.tar.gz
Algorithm Hash digest
SHA256 152857a1f5e8e253b4fe70757c3177686a6303a604afb142f2d63d94c31529c3
MD5 3926445386eba05835d84dd798e3c4de
BLAKE2b-256 788634c42e06a1c08a1ad03c014e697ea3574b9087700e777b54e278c11c163b

See more details on using hashes here.

File details

Details for the file apidev_coop_cms-1.6.17-py3-none-any.whl.

File metadata

File hashes

Hashes for apidev_coop_cms-1.6.17-py3-none-any.whl
Algorithm Hash digest
SHA256 e3144425877a9fdc3b586122f1b0dfa3aeec3d685a92a276fe564fb738f5fc74
MD5 a977378c60d0f87345fbf36ac19cc61b
BLAKE2b-256 d004c7f220662afe74e29400dd69dae00c64ea35b5bb400812cc72864e3f3478

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page