-
Notifications
You must be signed in to change notification settings - Fork 6
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
Updated some bugs and enhancements #8
base: main
Are you sure you want to change the base?
Changes from all commits
c45a284
cb1a682
a148fff
16d3ac6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.utils.translation import gettext_lazy as _ | ||
from djangocms_frontend.helpers import insert_fields | ||
|
||
|
||
class AttributesMixin: | ||
block_attr = { | ||
"description": _( | ||
"Advanced settings lets you add html attributes to render this element. Use them wisely and rarely." | ||
), | ||
"classes": ( | ||
"collapse", | ||
"attributes", | ||
), | ||
} | ||
|
||
def get_fieldsets(self, request, obj=None): | ||
meta = self.form._meta | ||
fields = ( | ||
[] | ||
) | ||
fields.append("attributes") | ||
return insert_fields( | ||
super().get_fieldsets(request, obj), | ||
fields, | ||
blockname=_("Advanced settings"), | ||
blockattrs=self.block_attr, | ||
position=-1, # Always last | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,14 @@ | |
from .. import forms | ||
from .. import forms as forms_module | ||
from .. import models, settings | ||
from ..attributes import AttributesMixin | ||
from ..helpers import add_plugin, delete_plugin, insert_fields | ||
from .ajax_plugins import FormPlugin | ||
|
||
mixin_factory = settings.get_renderer(forms_module) | ||
|
||
|
||
class FormElementPlugin(CMSPluginBase): | ||
class FormElementPlugin(AttributesMixin, CMSPluginBase): | ||
top_element = FormPlugin.__name__ | ||
module = _("Forms") | ||
render_template = f"djangocms_form_builder/{settings.framework}/widgets/base.html" | ||
|
@@ -69,7 +70,6 @@ class CharFieldPlugin(mixin_factory("CharField"), FormElementPlugin): | |
name = _("Text") | ||
model = models.CharField | ||
form = forms.CharFieldForm | ||
settings_fields = (("min_length", "max_length"),) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you remove |
||
|
||
|
||
@plugin_pool.register_plugin | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,15 @@ | |
framework = getattr(django_settings, "DJANGOCMS_FRONTEND_FRAMEWORK", "bootstrap5") | ||
theme = getattr(django_settings, "DJANGOCMS_FRONTEND_THEME", "djangocms_frontend") | ||
|
||
DEFAULT_SPACER_SIZE_CHOICES = (("mb-3", "Default"),) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather ask you to set this in your settings. It will first try to take |
||
DEFAULT_SPACER_SIZE_CHOICES = ( | ||
('', 'no margin set'), | ||
('mb-1', 'mb-1'), | ||
('mb-2', 'mb-2'), | ||
('mb-3', 'mb-3 (default)'), | ||
('mb-4', 'mb-4'), | ||
('mb-5', 'mb-5'), | ||
) | ||
|
||
TAG_CHOICES = (("div", "div"),) | ||
FORM_TEMPLATE = getattr( | ||
django_settings, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not assume django CMS frontend is installed.