Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1392] Add product finder plugin to products app #589

Merged
merged 2 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/open_inwoner/cms/products/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool

from open_inwoner.pdc.models import Category
from open_inwoner.pdc.forms import ProductFinderForm
from open_inwoner.pdc.models import Category, ProductCondition


@plugin_pool.register_plugin
Expand All @@ -20,3 +21,15 @@ def render(self, context, instance, placeholder):
0 : self.limit
]
return context


@plugin_pool.register_plugin
class ProductFinderPlugin(CMSPluginBase):
module = _("PDC")
name = _("Product Finder Plugin")
render_template = "cms/products/product_finder_plugin.html"

def render(self, context, instance, placeholder):
context["condition"] = ProductCondition.objects.first()
context["condition_form"] = ProductFinderForm()
return context
1 change: 1 addition & 0 deletions src/open_inwoner/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@
"PicturePlugin",
"CategoriesPlugin",
"ActivePlansPlugin",
"ProductFinderPlugin",
],
"text_only_plugins": ["LinkPlugin"],
"name": _("Content"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% load i18n product_tags %}

{% if condition %}
{% product_finder condition=condition form=condition_form form_action="products:product_finder" primary_text=_("Start") %}
{% endif %}