Created
December 10, 2015 04:05
-
-
Save mkoistinen/11f94908b2eb8fe4d2e5 to your computer and use it in GitHub Desktop.
Wizard starting point
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.utils.translation import ugettext as _ | |
from cms.wizards.wizard_pool import wizard_pool | |
from cms.wizards.wizard_base import Wizard | |
from .forms import CreateNewsArticleForm | |
class NewsBlogArticleWizard(Wizard): | |
def get_title(self, **kwargs): | |
""" | |
Programmatically define the title of the wizard. | |
:return: str | |
""" | |
return super(NewsBlogArticleWizard, self).get_title(**kwargs) | |
def get_weight(self, **kwargs): | |
""" | |
Programmatically determine the 'weight' of this wizard. The weight | |
determines the sort order of the various wizards. | |
:return: int | |
""" | |
return super(NewsBlogArticleWizard, self).get_weight(**kwargs) | |
def get_description(self, **kwargs): | |
""" | |
Programmatically define the description of the wizard. | |
:return: str | |
""" | |
return super(NewsBlogArticleWizard, self).get_description(**kwargs) | |
def get_success_url(self, obj, **kwargs): | |
""" | |
Programmatically define URL to redirect to, when this wizard | |
successfully creates a new object (News Item in this case). | |
:return: str | |
""" | |
return super(NewsBlogArticleWizard, self).get_success_url(obj, **kwargs) | |
def user_has_add_permission(self, user, **kwargs): | |
""" | |
Programmatically determine whether the current «user» has permission to | |
use this wizard. By defaut, this method simply checks the normal | |
permissions system to see if «user» can add this model type. | |
:param user: | |
:param kwargs: | |
:return: Boolean | |
""" | |
return super(NewsBlogArticleWizard, self).user_has_add_permission( | |
user, **kwargs) | |
news_article_wizard = NewsBlogArticleWizard( | |
title=_('New news article'), | |
weight=300, | |
form=CreateNewsArticleForm, | |
# model | |
# template_name | |
# description = _('Create new news item') | |
# edit_mode_on_success | |
) | |
wizard_pool.register(news_article_wizard) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment