Пример #1
0
    def test_register_unregister_isregistered(self):
        wizard_pool._clear()
        self.assertEqual(len(wizard_pool._entries), 0)
        wizard_pool.register(self.page_wizard)
        # Now, try to register the same thing
        with self.assertRaises(AlreadyRegisteredException):
            wizard_pool.register(self.page_wizard)

        self.assertEqual(len(wizard_pool._entries), 1)
        self.assertTrue(wizard_pool.is_registered(self.page_wizard))
        self.assertTrue(wizard_pool.unregister(self.page_wizard))
        self.assertEqual(len(wizard_pool._entries), 0)

        # Now, try to unregister something that is not registered
        self.assertFalse(wizard_pool.unregister(self.user_settings_wizard))
Пример #2
0
    def test_register_unregister_isregistered(self):
        wizard_pool._clear()
        self.assertEqual(len(wizard_pool._entries), 0)
        wizard_pool.register(self.page_wizard)
        # Now, try to register the same thing
        with self.assertRaises(AlreadyRegisteredException):
            wizard_pool.register(self.page_wizard)

        self.assertEqual(len(wizard_pool._entries), 1)
        self.assertTrue(wizard_pool.is_registered(self.page_wizard))
        self.assertTrue(wizard_pool.unregister(self.page_wizard))
        self.assertEqual(len(wizard_pool._entries), 0)

        # Now, try to unregister something that is not registered
        self.assertFalse(wizard_pool.unregister(self.user_settings_wizard))
Пример #3
0
    def test_get_entries(self):
        """
        Test that the registered entries are returned in weight-order, no matter
        which order they were added.
        """
        wizard_pool._clear()
        wizard_pool.register(self.page_wizard)
        wizard_pool.register(self.user_settings_wizard)
        wizards = [self.page_wizard, self.user_settings_wizard]
        wizards = sorted(wizards, key=lambda e: getattr(e, 'weight'))
        entries = wizard_pool.get_entries()
        self.assertSequencesEqual(entries, wizards)

        wizard_pool._clear()
        wizard_pool.register(self.user_settings_wizard)
        wizard_pool.register(self.page_wizard)
        wizards = [self.page_wizard, self.user_settings_wizard]
        wizards = sorted(wizards, key=lambda e: getattr(e, 'weight'))
        entries = wizard_pool.get_entries()
        self.assertSequencesEqual(entries, wizards)
Пример #4
0
    def test_get_entries(self):
        """
        Test that the registered entries are returned in weight-order, no matter
        which order they were added.
        """
        wizard_pool._clear()
        wizard_pool.register(self.page_wizard)
        wizard_pool.register(self.user_settings_wizard)
        wizards = [self.page_wizard, self.user_settings_wizard]
        wizards = sorted(wizards, key=lambda e: getattr(e, 'weight'))
        entries = wizard_pool.get_entries()
        self.assertSequencesEqual(entries, wizards)

        wizard_pool._clear()
        wizard_pool.register(self.user_settings_wizard)
        wizard_pool.register(self.page_wizard)
        wizards = [self.page_wizard, self.user_settings_wizard]
        wizards = sorted(wizards, key=lambda e: getattr(e, 'weight'))
        entries = wizard_pool.get_entries()
        self.assertSequencesEqual(entries, wizards)
from django.utils.translation import ugettext_lazy as _

from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool

from .forms import CampaignForm


class CampaignWizard(Wizard):
    pass


campaign_wizard = CampaignWizard(
    title=_('New Campaign'),
    weight=200,
    form=CampaignForm,
    description=_('Create a new Campaign'),
)

wizard_pool.register(campaign_wizard)
Пример #6
0
        return super().user_has_add_permission(user, page)


class RichieCMSPageWizard(ExcludeRootReverseIDMixin, CMSPageWizard):
    """A page wizard that can not be created below our Richie extended pages."""


class RichieCMSSubPageWizard(ExcludeRootReverseIDMixin, CMSSubPageWizard):
    """A subpage wizard that can not be created below our Richie extended pages."""


wizard_pool.unregister(cms_page_wizard)
wizard_pool.register(
    RichieCMSPageWizard(
        title=_("New page"),
        weight=100,
        form=CreateCMSPageForm,
        model=Page,
        description=_("Create a new page next to the current page."),
    ))

wizard_pool.unregister(cms_subpage_wizard)
wizard_pool.register(
    RichieCMSSubPageWizard(
        title=_("New sub page"),
        weight=110,
        form=CreateCMSSubPageForm,
        model=Page,
        description=_("Create a page below the current page."),
    ))

Пример #7
0
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool

from polls_cms_integration.forms import PollWizardForm
from polls.models import Poll


class PollWizard(Wizard):
    pass


poll_wizard = PollWizard(
    title="Poll",
    weight=200,  # determines the ordering of wizards in the Create dialog
    form=PollWizardForm,
    description="Create a new Poll",
)

wizard_pool.register(poll_wizard)
Пример #8
0
        if len(app_configs) < 2:
            self.fields['sections'].widget = forms.HiddenInput()
            self.fields['sections'].initial = app_configs[0].pk

    def save(self, commit=True):
        service = super(CreateServicesServiceForm, self).save(commit=False)
        #service.owner = self.user
        service.save()

        # If 'content' field has value, create a TextPlugin with same and add it to the PlaceholderField
        content = clean_html(self.cleaned_data.get('content', ''), False)
        if content and permissions.has_plugin_permission(self.user, 'TextPlugin', 'add'):
            add_plugin(
                placeholder=service.content,
                plugin_type='TextPlugin',
                language=self.language_code,
                body=content,
            )

        return service


services_service_wizard = ServicesServiceWizard(
    title=_(u"New service"),
    weight=200,
    form=CreateServicesServiceForm,
    description=_(u"Create a service.")
)

wizard_pool.register(services_service_wizard)
Пример #9
0
            if question and question.answer:
                plugin_kwarg = {
                    'placeholder': question.answer,
                    'plugin_type': content_plugin,
                    'language': self.language_code,
                    content_field: answer_content,
                }
                add_plugin(**plugin_kwarg)

        # Ensure we make an initial revision
        question.save()

        return question


faq_category_wizard = FaqCategoryWizard(
    title=_(u"New FAQ category"),
    weight=400,
    form=CreateFaqCategoryForm,
    description=_(u"Create a new FAQ category."))

wizard_pool.register(faq_category_wizard)

faq_category_wizard = FaqQuestionWizard(
    title=_(u"New FAQ question"),
    weight=450,
    form=CreateFaqQuestionForm,
    description=_(u"Create a new FAQ question."))

wizard_pool.register(faq_category_wizard)
Пример #10
0
from .forms import PostCreationForm
from .models import Post


class BlogWizard(Wizard):
    model = Post

    def user_has_add_permission(self, user, **kwargs):
        if not user:
            return False
        if user.is_superuser:
            return True

        opts = self.model._meta
        if user.has_perm('%s.%s' % (opts.app_label, get_permission_codename('add', opts))):
            return True

        # By default, no permission.
        return False

blog_wizard = BlogWizard(
    title=_('New post'),
    weight=200,
    model=Post,
    form=PostCreationForm,
    description=_('Create a new blog post.'),
)

wizard_pool.register(blog_wizard)
Пример #11
0
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool

from .forms import PostCreationForm
from .models import Post


class BlogWizard(Wizard):
    model = Post

    def user_has_add_permission(self, user, **kwargs):
        if not user:
            return False
        if user.is_superuser:
            return True

        opts = self.model._meta
        if user.has_perm("%s.%s" % (opts.app_label, get_permission_codename("add", opts))):
            return True

        # By default, no permission.
        return False


blog_wizard = BlogWizard(
    title=_("New post"), weight=200, model=Post, form=PostCreationForm, description=_("Create a new blog post.")
)

wizard_pool.register(blog_wizard)
Пример #12
0
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool

from .forms import BubbleWizardForm
from .models import TextModel


class TextBubbleWizard(Wizard):
    def get_success_url(self, obj, **kwargs):
        return None


text_bubble_wizard = TextBubbleWizard(
    title="Text Bubble Wizard",
    weight=200,
    form=BubbleWizardForm,
    model=TextModel,
    description="Create a new Text Bubble",
)

wizard_pool.register(text_bubble_wizard)
Пример #13
0
from .models import Category


class CategoryWizard(Wizard):

    def get_success_url(self, *args, **kwargs):
        # Since categories do not have their own urls, return None so that
        # cms knows that it should just close the wizard window (reload
        # current page)
        return None


class CreateCategoryForm(BaseFormMixin, TranslatableModelForm, MoveNodeForm):
    """
    The model form for Category wizad.
    """

    class Meta:
        model = Category
        fields = ['name', 'slug', ]


aldryn_category_wizard = CategoryWizard(
    title=_(u"New category"),
    weight=290,
    form=movenodeform_factory(Category, form=CreateCategoryForm),
    description=_(u"Create a new category.")
)

wizard_pool.register(aldryn_category_wizard)
Пример #14
0
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool

from .forms import ArticleCreationForm
from spe_blog.models import Article


class ArticleCreationWizard(Wizard):
    pass


article_wizard = ArticleCreationWizard(
    title="New Article",
    weight=200,
    form=ArticleCreationForm,
    description="Create an article",
)

wizard_pool.register(article_wizard)
Пример #15
0
            f'<h1>Курс: {course_product.name}</h1><p>{course_product.long_description}</p>'
        )
        add_plugin(
            plugin_type='CourseProgramCMSPlugin',
            placeholder=content_placeholder,
            language=self.language_code,
            course=course_product.course,
        )
        add_plugin(
            plugin_type='CourseProductSignupCMSPlugin',
            placeholder=content_placeholder,
            language=self.language_code,
            course_product=course_product,
        )

        return page


class NewCourseWizard(CMSPageWizard):
    pass


new_course_wizard = NewCourseWizard(
    title=_("Landing for Course Product"),
    description=_("Create landing page for existing course product"),
    weight=90,
    form=NewCourseForm,
    model=Page,
)
wizard_pool.register(new_course_wizard)
Пример #16
0
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool
from activities.forms import ActivityWizardForm

# http://docs.django-cms.org/en/latest/reference/wizards.html

class ActivityWizard(Wizard):
    pass


activity_wizard = ActivityWizard(
    title='New Activity',
    weight=200,
    form=ActivityWizardForm,
    description='Create a new activity',
)

wizard_pool.register(activity_wizard)
Пример #17
0
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool

from offers_cms_integration.forms import EstateWizardForm


class EstateWizard(Wizard):
    pass


estate_wizard = EstateWizard(
    title="Estate",
    weight=200,  # determines the ordering of wizards in the Create dialog
    form=EstateWizardForm,
    description="Create a new Offer",
)

wizard_pool.register(estate_wizard)
Пример #18
0
            placeholder=placeholder,
            plugin_type="OrganizationPlugin",
            **{"page": self.cleaned_data["organization"].extended_object},
        )

        return page


class CourseWizard(Wizard):
    """Inherit from Wizard because each wizard must have its own Python class."""


wizard_pool.register(
    CourseWizard(
        title=_("New course page"),
        description=_("Create a new course page"),
        model=Course,
        form=CourseWizardForm,
        weight=200,
    ))


class CourseRunWizardForm(BaseWizardForm):
    """
    This form is used by the wizard that creates a new course run page.
    A related CourseRun model is created for each course run page.
    """

    course = forms.ModelChoiceField(
        required=True,
        queryset=Course.objects.filter(
            extended_object__publisher_is_draft=True,
Пример #19
0

class PostWizard(Wizard):
    pass


for config in BlogConfig.objects.all().order_by("namespace"):
    seed = slugify("{}.{}".format(config.app_title, config.namespace))
    new_wizard = type(str(seed), (PostWizard, ), {})
    new_form = type("{}Form".format(seed), (PostWizardForm, ),
                    {"default_appconfig": config.pk})
    post_wizard = new_wizard(
        title=_("New {0}").format(config.object_name),
        weight=200,
        form=new_form,
        model=Post,
        description=_("Create a new {0} in {1}").format(
            config.object_name, config.app_title),
    )
    try:
        wizard_pool.register(post_wizard)
    except AlreadyRegisteredException:  # pragma: no cover
        if settings.DEBUG:
            raise
        else:
            warnings.warn(
                "Wizard {} cannot be registered. Please make sure that "
                "BlogConfig.namespace {} and BlogConfig.app_title {} are"
                "unique together".format(seed, config.namespace,
                                         config.app_title))
Пример #20
0
                add_plugin(**plugin_kwargs)

        with transaction.atomic():
            with revision_context_manager.create_revision():
                job_opening.save()
                if self.user:
                    revision_context_manager.set_user(self.user)
                revision_context_manager.set_comment(
                    ugettext("Initial version."))

        return job_opening


job_category_wizard = JobCategoryWizard(
    title=_(u"New job category"),
    weight=500,
    form=CreateJobCategoryForm,
    description=_(u"Create a new job category.")
)

wizard_pool.register(job_category_wizard)

job_opening_wizard = JobOpeningWizard(
    title=_(u"New job opening"),
    weight=550,
    form=CreateJobOpeningForm,
    description=_(u"Create a new job opening.")
)

wizard_pool.register(job_opening_wizard)
Пример #21
0
    def save(self):
        """
        The parent form created the page.
        This method creates the associated person page extension.
        """
        page = super().save()
        Person.objects.create(
            extended_object=page,
            person_title=self.cleaned_data["person_title"],
            first_name=self.cleaned_data["first_name"],
            last_name=self.cleaned_data["last_name"],
        )
        return page


class PersonWizard(Wizard):
    """Inherit from Wizard because each wizard must have its own Python class."""

    pass


wizard_pool.register(
    PersonWizard(
        title=_("New person page"),
        description=_("Create a new person page"),
        model=Person,
        form=PersonWizardForm,
        weight=200,
    )
)
Пример #22
0
        ]


class CreateDoctorsSectionForm(BaseFormMixin, TranslatableModelForm):
    class Meta:
        model = Section
        fields = ['title', 'page']


doctors_doctor_wizard = DoctorsDoctorWizard(
    title=_('New doctor'),
    weight=300,
    form=CreateDoctorsDoctorForm,
    description=_("Create a new doctor."))

wizard_pool.register(doctors_doctor_wizard)

doctors_section_wizard = DoctorsSectionWizard(
    title=_('New section'),
    weight=300,
    form=CreateDoctorsSectionForm,
    description=_("Create a new section."))

# Disabling the section wizard by default. To enable, create a file
# cms_wizards.py in your project and add the following lines:

# from cms.wizards.wizard_pool import wizard_pool
# from nnuh_doctors.cms_wizards import doctors_section_wizard
#
#  wizard_pool.register(doctors_section_wizard)
Пример #23
0
                    content_field: content,
                }
                add_plugin(**plugin_kwargs)

        with transaction.atomic():
            with revision_context_manager.create_revision():
                job_opening.save()
                if self.user:
                    revision_context_manager.set_user(self.user)
                revision_context_manager.set_comment(
                    ugettext("Initial version."))

        return job_opening


job_category_wizard = JobCategoryWizard(
    title=_(u"New job category"),
    weight=500,
    form=CreateJobCategoryForm,
    description=_(u"Create a new job category."))

wizard_pool.register(job_category_wizard)

job_opening_wizard = JobOpeningWizard(
    title=_(u"New job opening"),
    weight=550,
    form=CreateJobOpeningForm,
    description=_(u"Create a new job opening."))

wizard_pool.register(job_opening_wizard)
Пример #24
0
from .models import Category


class CategoryWizard(Wizard):
    def get_success_url(self, *args, **kwargs):
        # Since categories do not have their own urls, return None so that
        # cms knows that it should just close the wizard window (reload
        # current page)
        return None


class CreateCategoryForm(BaseFormMixin, TranslatableModelForm, MoveNodeForm):
    """
    The model form for Category wizad.
    """
    class Meta:
        model = Category
        fields = [
            'name',
            'slug',
        ]


aldryn_category_wizard = CategoryWizard(
    title=_(u"New category"),
    weight=290,
    form=movenodeform_factory(Category, form=CreateCategoryForm),
    description=_(u"Create a new category."))

wizard_pool.register(aldryn_category_wizard)
Пример #25
0
                translation_info = get_translation_info_message(group)
                revision_context_manager.set_comment(
                    ugettext("Initial version of {object_repr}. {trans_info}".
                             format(object_repr=object_repr,
                                    trans_info=translation_info)))

        return group


people_person_wizard = PeoplePersonWizard(
    title=_('New person'),
    weight=300,
    form=CreatePeoplePersonForm,
    description=_("Create a new person."))

wizard_pool.register(people_person_wizard)

people_group_wizard = PeopleGroupWizard(
    title=_('New affiliation'),
    weight=300,
    form=CreatePeopleGroupForm,
    description=_("Create a new affiliation."))

# Disabling the group wizard by default. To enable, create a file
# cms_wizards.py in your project and add the following lines:

# from cms.wizards.wizard_pool import wizard_pool
# from ssrd_people.cms_wizards import people_group_wizard
#
#  wizard_pool.register(people_group_wizard)
Пример #26
0
from .models import Alias as AliasModel, Category


class CreateAliasWizard(Wizard):
    def user_has_add_permission(self, user, **kwargs):
        return Alias.can_create_alias(user)


class CreateAliasCategoryWizard(Wizard):
    def user_has_add_permission(self, user, **kwargs):
        return user.has_perm(get_model_permission_codename(Category, 'add'), )


create_alias_wizard = CreateAliasWizard(
    title=_('New alias'),
    weight=200,
    form=CreateAliasWizardForm,
    model=AliasModel,
    description=_('Create a new alias.'),
)
create_alias_category_wizard = CreateAliasCategoryWizard(
    title=_('New alias category'),
    weight=200,
    form=CreateCategoryWizardForm,
    model=Category,
    description=_('Create a new alias category.'),
)

wizard_pool.register(create_alias_wizard)
wizard_pool.register(create_alias_category_wizard)
Пример #27
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool


if settings.SHOP_TUTORIAL in ('commodity', 'i18n_commodity'):
    from shop.models.defaults.commodity import Commodity
    from shop.forms.wizards import CommodityWizardForm


    commodity_wizard = Wizard(
        title=_("New Commodity"),
        weight=200,
        form=CommodityWizardForm,
        description=_("Create a new Commodity instance"),
        model=Commodity,
        template_name='shop/wizards/create_product.html'
    )
    wizard_pool.register(commodity_wizard)
Пример #28
0
class ProjectWizard(Wizard):
    pass


class BlogWizard(Wizard):
    pass

portfolio_wizard = PortfolioWizard(
    title="Create Portfolio",
    weight=200,  # determines the ordering of wizards in the Create dialog
    form=PortfolioWizardForm,
    description="Create a new Portfolio",
)

project_wizard = ProjectWizard(
    title="Create Project",
    weight=200,  # determines the ordering of wizards in the Create dialog
    form=ProjectoWizardForm,
    description="Create a new Project",
)

blog_wizard = BlogWizard(
    title="Create Blog",
    weight=200,  # determines the ordering of wizards in the Create dialog
    form=BlogWizardForm,
    description="Create a new Blog",
)

wizard_pool.register(portfolio_wizard)
wizard_pool.register(project_wizard)
wizard_pool.register(blog_wizard)
Пример #29
0
            # first.
            if not article.pk:
                article.save()

            if article and article.content:
                add_plugin(
                    placeholder=article.content,
                    plugin_type='TextPlugin',
                    language=self.language_code,
                    body=content,
                )

        with transaction.atomic():
            with create_revision():
                article.save()
                if self.user:
                    set_user(self.user)
                set_comment(ugettext("Initial version."))

        return article


newsblog_article_wizard = NewsBlogArticleWizard(
    title=_(u"New news/blog article"),
    weight=200,
    form=CreateNewsBlogArticleForm,
    description=_(u"Create a new news/blog article.")
)

wizard_pool.register(newsblog_article_wizard)
Пример #30
0
    def save(self, commit=True):
        dashboard = super(CreateDashboards_appDashboardForm, self).save(commit=False)
        dashboard.owner = self.user
        dashboard.save()

        # If 'content' field has value, create a TextPlugin with same and add it to the PlaceholderField
        content = clean_html(self.cleaned_data.get('content', ''), False)
        if content and permissions.has_plugin_permission(self.user, 'TextPlugin', 'add'):
            add_plugin(
                placeholder=dashboard.content,
                plugin_type='TextPlugin',
                language=self.language_code,
                body=content,
            )




        return dashboard


dashboards_app_dashboard_wizard = Dashboards_appDashboardWizard(
    title=_(u"New Dashboard "),
    weight=200,
    form=CreateDashboards_appDashboardForm,
    description=_(u"Create a new Dashboard.")
)

wizard_pool.register(dashboards_app_dashboard_wizard)
Пример #31
0
class CreatePeopleGroupForm(BaseFormMixin, TranslatableModelForm):
    class Meta:
        model = Group
        fields = ['name', 'description', 'address', 'postal_code', 'city',
                  'phone', 'email', 'website']


people_person_wizard = PeoplePersonWizard(
    title=_('New person'),
    weight=300,
    form=CreatePeoplePersonForm,
    description=_("Create a new person.")
)

wizard_pool.register(people_person_wizard)


people_group_wizard = PeopleGroupWizard(
    title=_('New group'),
    weight=300,
    form=CreatePeopleGroupForm,
    description=_("Create a new group.")
)

# Disabling the group wizard by default. To enable, create a file
# cms_wizards.py in your project and add the following lines:

# from cms.wizards.wizard_pool import wizard_pool
# from aldryn_people.cms_wizards import people_group_wizard
#
Пример #32
0
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool

from .forms import ArticleCreationForm
from spe_blog.models import Article

class ArticleCreationWizard(Wizard):
    pass

article_wizard = ArticleCreationWizard(
    title="New Article",
    weight=200,
    form=ArticleCreationForm,
    description="Create an article",
)

wizard_pool.register(article_wizard)
Пример #33
0
            # first.
            if not article.pk:
                article.save()

            if article and article.content:
                add_plugin(
                    placeholder=article.content,
                    plugin_type='TextPlugin',
                    language=self.language_code,
                    body=article_content,
                )

        with transaction.atomic():
            with revision_context_manager.create_revision():
                article.save()
                if self.user:
                    revision_context_manager.set_user(self.user)
                revision_context_manager.set_comment(
                    ugettext("Initial version."))

        return article


newsblog_article_wizard = NewsBlogArticleWizard(
    title=_(u"New news/blog article"),
    weight=200,
    form=CreateNewsBlogArticleForm,
    description=_(u"Create a new news/blog article."))

wizard_pool.register(newsblog_article_wizard)
Пример #34
0
 def test_get_entry(self):
     wizard_pool._clear()
     wizard_pool.register(self.page_wizard)
     entry = wizard_pool.get_entry(self.page_wizard)
     self.assertEqual(entry, self.page_wizard)
    from django.conf import settings

    from newscenter.models import Article

    class ArticleWizardForm(forms.ModelForm):
        if 'djangocms_text_ckeditor' in settings.INSTALLED_APPS:
            from djangocms_text_ckeditor.widgets import TextEditorWidget
            body = forms.CharField(widget=TextEditorWidget())

        class Meta:
            model = Article
            fields = ['title', 'release_date', 'newsroom', 'body', 'feeds']

    class ArticleWizard(Wizard):
        pass

    newscenter_wizard = ArticleWizard(
        title="New Article",
        weight=200,
        form=ArticleWizardForm,
        model=Article,
        edit_mode_on_success=False,
        description="Create a new article in Newscenter",
    )

    wizard_pool.register(newscenter_wizard)

except ImportError:
    # For django CMS version not supporting wizards just ignore this file
    pass
Пример #36
0
                plugin_kwarg = {
                    'placeholder': question.answer,
                    'plugin_type': content_plugin,
                    'language': self.language_code,
                    get_cms_setting('WIZARD_CONTENT_PLUGIN_BODY'): answer,
                }
                add_plugin(**plugin_kwarg)

        if commit:
            question.save()

        return question

faq_category_wizard = FaqCategoryWizard(
    title=_(u"New FAQ category"),
    weight=400,
    form=CreateFaqCategoryForm,
    description=_(u"Create a new FAQ category.")
)

wizard_pool.register(faq_category_wizard)

faq_category_wizard = FaqQuestionWizard(
    title=_(u"New FAQ question"),
    weight=450,
    form=CreateFaqQuestionForm,
    description=_(u"Create a new FAQ question.")
)

wizard_pool.register(faq_category_wizard)
Пример #37
0
            # If the event has not been saved, then there will be no
            # Placeholder set-up for this event yet, so, ensure we have saved
            # first.
            if not event.pk:
                event.save()

            if event and event.description:
                # we have to use kwargs because we don't know in advance what
                # is the 'body' field for configured plugin
                plugin_kwargs = {
                    'placeholder': event.description,
                    'plugin_type': content_plugin,
                    'language': self.language_code,
                    content_field: event_content,
                }
                add_plugin(**plugin_kwargs)

        event.save()

        return event


event_wizard = EventWizard(
    title=_(u"New Event"),
    weight=500,
    form=CreateEventForm,
    description=_(u"Create a new Event.")
)

wizard_pool.register(event_wizard)
Пример #38
0
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool

from .forms import HealthApplicationForm
from .models import EmployeeModel


class HealthAppWizard(Wizard):
    def get_success_url(self, obj, **kwargs):
        """
        This should return the URL of the created object, «obj».
        """
        # if 'language' in kwargs:
        #     url = obj.get_absolute_url()
        # else:
        url = obj.get_absolute_url()

        return url


health_app_wizard = HealthAppWizard(
    title="Health Questionnaire",
    weight=200,
    form=HealthApplicationForm,
    model=EmployeeModel,
    description="Create a new Health Questions instance",
)

wizard_pool.register(health_app_wizard)
Пример #39
0
        class Media:
            js = ('admin/js/jquery.js', 'admin/js/jquery.init.js',)

        def save(self, commit=True):
            self.instance._set_default_author(get_current_user())
            return super(PostWizardForm, self).save(commit)

    class PostWizard(Wizard):
        pass

    for config in BlogConfig.objects.all().order_by('namespace'):
        new_wizard = type(str(slugify(config.app_title)), (PostWizard,), {})
        new_form = type(str('{0}Form').format(slugify(config.app_title)), (PostWizardForm,), {
            'default_appconfig': config.pk
        })
        post_wizard = new_wizard(
            title=_('New {0}').format(config.object_name),
            weight=200,
            form=new_form,
            model=Post,
            description=_('Create a new {0} in {1}').format(config.object_name, config.app_title),
        )
        try:
            wizard_pool.register(post_wizard)
        except AlreadyRegisteredException:  # pragma: no cover
            if settings.DEBUG:
                raise
except ImportError:
    # For django CMS version not supporting wizards just ignore this file
    pass
Пример #40
0
        Course.objects.create(
            extended_object=page,
            organization_main=self.cleaned_data["organization"])
        return page


class CourseWizard(Wizard):
    """Inherit from Wizard because each wizard must have its own Python class."""

    pass


wizard_pool.register(
    CourseWizard(
        title=_("New course page"),
        description=_("Create a new course page"),
        model=Course,
        form=CourseWizardForm,
        weight=200,
    ))


class OrganizationWizardForm(BaseWizardForm):
    """
    This form is used by the wizard that creates a new organization page
    A related organization model is created for each organization page
    """

    model = Organization

    def save(self):
        """
Пример #41
0
 def test_get_entry(self):
     wizard_pool._clear()
     wizard_pool.register(self.page_wizard)
     entry = wizard_pool.get_entry(self.page_wizard)
     self.assertEqual(entry, self.page_wizard)
Пример #42
0
        app_configs = get_published_app_configs()
        if len(app_configs) < 2:
            self.fields['app_config'].widget = forms.HiddenInput()
            self.fields['app_config'].initial = app_configs[0].pk

    def save(self, commit=True):
        event = super(CreateEventsEventForm, self).save(commit=False)
        #event.owner = self.user
        event.save()

        # If 'content' field has value, create a TextPlugin with same and add it to the PlaceholderField
        content = clean_html(self.cleaned_data.get('content', ''), False)
        if content and permissions.has_plugin_permission(
                self.user, 'TextPlugin', 'add'):
            add_plugin(
                placeholder=event.content,
                plugin_type='TextPlugin',
                language=self.language_code,
                body=content,
            )

        return event


events_event_wizard = EventsEventWizard(title=_(u"New event"),
                                        weight=200,
                                        form=CreateEventsEventForm,
                                        description=_(u"Create a event."))

wizard_pool.register(events_event_wizard)
Пример #43
0
""" Docs. """

from django.utils.translation import ugettext_lazy as _
from cms.wizards.wizard_base import Wizard
from cms.wizards.wizard_pool import wizard_pool

from shop2.models.defaults.commodity import Commodity
from shop2.forms.wizards import CommodityWizardForm

commodity_wizard = Wizard(title=_("New Commodity"),
                          weight=200,
                          form=CommodityWizardForm,
                          description=_("Create a new Commodity instance"),
                          model=Commodity,
                          template_name='shop2/wizards/create_product.html')
wizard_pool.register(commodity_wizard)
Пример #44
0
        model = Group
        fields = [
            'name', 'description', 'address', 'postal_code', 'city', 'phone',
            'email', 'website'
        ]


people_person_wizard = PeoplePersonWizard(
    title=_('New person'),
    weight=300,
    form=CreatePeoplePersonForm,
    description=_("Create a new person."))

#wizard_pool.register(people_person_wizard)

people_group_wizard = PeopleGroupWizard(title=_('New group'),
                                        weight=300,
                                        form=CreatePeopleGroupForm,
                                        description=_("Create a new group."))

if ALDRYN_PEOPLE_HIDE_GROUPS == 0:
    wizard_pool.register(people_group_wizard)

# Disabling the group wizard by default. To enable, create a file
# cms_wizards.py in your project and add the following lines:

# from cms.wizards.wizard_pool import wizard_pool
# from aldryn_people.cms_wizards import people_group_wizard
#
#  wizard_pool.register(people_group_wizard)