-
Notifications
You must be signed in to change notification settings - Fork 112
/
cms_plugins.py
54 lines (42 loc) · 1.73 KB
/
cms_plugins.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import gettext_lazy as _
from .models import FobiFormWidget
from .settings import WIDGET_FORM_SENT_GET_PARAM
from fobi.integration.processors import IntegrationProcessor
__title__ = "fobi.contrib.apps.djangocms_integration.cms_plugins"
__author__ = "Artur Barseghyan <[email protected]>"
__copyright__ = "2014-2019 Artur Barseghyan"
__license__ = "GPL 2.0/LGPL 2.1"
__all__ = ("FobiFormWidgetPlugin",)
class FobiFormWidgetPlugin(CMSPluginBase, IntegrationProcessor):
"""Fobi form widget plugin."""
model = FobiFormWidget
name = _("Fobi form")
render_template = "djangocms_integration/widget.html"
text_enabled = True
cache = False
# Fobi integration processor configuration
form_sent_get_param = WIDGET_FORM_SENT_GET_PARAM
can_redirect = False
login_required_template_name = "djangocms_integration/login_required.html"
def process(self, request, instance, **kwargs):
"""This is where most of the form handling happens.
:param django.http.HttpRequest request:
:return django.http.HttpResponse | str:
"""
return self._process(request, instance, **kwargs)
def render(self, context, instance, placeholder):
"""Render."""
self.process(context["request"], instance)
rendered_context = getattr(self, "rendered_output", "")
context.update(
{
"object": instance,
"instance": instance,
"placeholder": placeholder,
"rendered_context": rendered_context,
}
)
return context
plugin_pool.register_plugin(FobiFormWidgetPlugin)