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

fix: Dropped django-select2 dependency #197

Merged
merged 38 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4245adc
Fix: Update locales and add floating options for images
fsbraun Nov 7, 2023
e66e618
Merge branch 'master' of github.com:fsbraun/djangocms-frontend
fsbraun Nov 7, 2023
cbaccdd
Merge branch 'master' of github.com:fsbraun/djangocms-frontend
fsbraun Nov 28, 2023
66e053e
fix: icons not showing in ckeditor
fsbraun Nov 28, 2023
fec0ece
Merge branch 'django-cms:master' into master
fsbraun Nov 28, 2023
49e4acc
Merge branch 'django-cms:master' into master
fsbraun Nov 28, 2023
a9ead97
Add image drag and drop
fsbraun Nov 28, 2023
9ac7126
Merge branch 'master' of github.com:fsbraun/djangocms-frontend
fsbraun Nov 28, 2023
f5f27b6
Update docs
fsbraun Nov 28, 2023
6d5fac4
Add tests
fsbraun Nov 28, 2023
18d60ab
Fix tests for v4
fsbraun Nov 28, 2023
44d5035
Bump version
fsbraun Nov 28, 2023
210cccd
Update changelog
fsbraun Nov 28, 2023
510494e
Merge branch 'django-cms:master' into master
fsbraun Nov 28, 2023
297d436
Merge branch 'django-cms:master' into master
fsbraun Dec 13, 2023
fc20a5a
Merge branch 'django-cms:master' into master
fsbraun Dec 15, 2023
606cc91
fix/remove-unused-css
fsbraun Dec 15, 2023
1af2ef9
Merge branch 'django-cms:master' into master
fsbraun Jan 4, 2024
60f810f
Merge branch 'django-cms:master' into master
fsbraun Jan 8, 2024
05a0939
Merge branch 'django-cms:master' into master
fsbraun Jan 8, 2024
a8e5f2d
Doc typos
fsbraun Jan 8, 2024
c7c8bcf
Merge branch 'django-cms:master' into master
fsbraun Jan 9, 2024
ad90c57
Fix: Missing space in auto column short description
fsbraun Jan 11, 2024
d2a2e78
Merge branch 'master' of github.com:fsbraun/djangocms-frontend
fsbraun Jan 11, 2024
41e58bc
Merge branch 'master' into master
fsbraun Jan 11, 2024
ef87c91
Unlist removed iconsets from the docs
fsbraun Jan 12, 2024
8d63c99
Merge branch 'django-cms:master' into master
fsbraun Jan 12, 2024
a165dcd
Merge branch 'master' into master
fsbraun Jan 13, 2024
c7e34a2
Merge branch 'django-cms:master' into master
fsbraun Feb 14, 2024
aa0aff9
Merge branch 'django-cms:master' into master
fsbraun Feb 16, 2024
1017581
Merge branch 'django-cms:master' into master
fsbraun Feb 28, 2024
4a6c6bf
Merge branch 'django-cms:master' into master
fsbraun Mar 21, 2024
25cbc79
Bump version
fsbraun Mar 21, 2024
a006821
Add translations
fsbraun Mar 21, 2024
47cb3d0
Update test environment
fsbraun Mar 21, 2024
17f3b71
Fix: Tree structure for pages
fsbraun Mar 21, 2024
1dd0e83
Restore Django 3.2 compatibility
fsbraun Mar 21, 2024
d405c51
Update changelog
fsbraun Mar 21, 2024
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
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Changelog
=========

1.3.0 (2024-03-21)
==================

* feat: Add abstract base model `AbstractFrontendUIItem` by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/195
* feat: Add icons for selected text-enabled plugins by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/195
* fix: Correct site used when using Link plugin within a static placholder in django CMS 3.x by @fsbraun
* fix: removed Nav Container plugin and fixed Navigation Link plugin by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/192
* fix: Remove `{% spaceless %}` around `{% block "content" %}` by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/188
* fix: Improved fieldset layout for Django 4.2+ by @fsbraun in https://github.com/django-cms/djangocms-frontend/pull/185
* fix: Dropped django-select2 dependency


1.2.2 (2024-01-13)
==================

Expand Down
2 changes: 1 addition & 1 deletion djangocms_frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
13. Github actions will publish the new package to pypi
"""

__version__ = "1.2.2"
__version__ = "1.3.0"
75 changes: 50 additions & 25 deletions djangocms_frontend/contrib/link/forms.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import json
from types import SimpleNamespace

from django import apps, forms
from django.conf import settings as django_settings
from django.contrib.admin.widgets import SELECT2_TRANSLATIONS
from django.contrib.admin.widgets import SELECT2_TRANSLATIONS, AutocompleteMixin
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db import models
from django.db.models.fields.related import ManyToOneRel
from django.urls import reverse
from django.utils.encoding import force_str
from django.utils.translation import get_language
from django.utils.translation import gettext as _
from django_select2.forms import HeavySelect2Widget, Select2Widget

# from djangocms_link.validators import IntranetURLValidator
from entangled.forms import EntangledModelForm
Expand Down Expand Up @@ -56,30 +59,9 @@ def __init__(self, *args, **kwargs):
)


class Select2jqWidget(HeavySelect2Widget if MINIMUM_INPUT_LENGTH else Select2Widget):
"""Make jQuery available to Select2 widget"""

class Select2jqWidget(AutocompleteMixin, forms.Select):
empty_label = _("Select a destination")

@property
def media(self):
extra = ".min"
i18n_name = SELECT2_TRANSLATIONS.get(get_language())
i18n_file = (
("admin/js/vendor/select2/i18n/%s.js" % i18n_name,) if i18n_name else ()
)
return forms.Media(
js=("admin/js/vendor/select2/select2.full%s.js" % extra,)
+ i18n_file
+ ("djangocms_frontend/js/django_select2.js",),
css={
"screen": (
"admin/css/vendor/select2/select2%s.css" % extra,
"djangocms_frontend/css/select2.css",
),
},
)

def __init__(self, *args, **kwargs):
if MINIMUM_INPUT_LENGTH:
if "attrs" in kwargs:
Expand All @@ -88,9 +70,52 @@ def __init__(self, *args, **kwargs):
)
else:
kwargs["attrs"] = {"data-minimum-input-length": MINIMUM_INPUT_LENGTH}
kwargs.setdefault("data_view", "dcf_autocomplete:ac_view")
kwargs.setdefault("admin_site", None)
kwargs.setdefault(
"field",
SimpleNamespace(name="", model=SimpleNamespace(
_meta=SimpleNamespace(app="djangocms_frontend", label="link")
))
) # Fake field properties for autocomplete field (unused by link)
super().__init__(*args, **kwargs)

def get_url(self):
return reverse("dcf_autocomplete:ac_view")

def build_attrs(self, base_attrs, extra_attrs=None):
"""
Set select2's AJAX attributes.

Attributes can be set using the html5 data attribute.
Nested attributes require a double dash as per
https://select2.org/configuration/data-attributes#nested-subkey-options
"""
attrs = super(forms.Select, self).build_attrs(base_attrs, extra_attrs=extra_attrs)
attrs.setdefault("class", "")
i18n_name = getattr(self, "i18n_name", SELECT2_TRANSLATIONS.get(get_language())) # Django 3.2 compat
attrs.update(
{
"data-ajax--cache": "true",
"data-ajax--delay": 250,
"data-ajax--type": "GET",
"data-ajax--url": self.get_url(),
"data-theme": "admin-autocomplete",
"data-app-label": "app",
"data-model-name": "model",
"data-field-name": "field",
"data-allow-clear": json.dumps(not self.is_required),
"data-placeholder": "", # Allows clearing of the input.
"lang": i18n_name,
"class": attrs["class"]
+ (" " if attrs["class"] else "")
+ "admin-autocomplete",
}
)
return attrs

def optgroups(self, name, value, attr=None):
return super(forms.Select, self).optgroups(name, value)


class SmartLinkField(forms.ChoiceField):
widget = Select2jqWidget
Expand Down
4 changes: 3 additions & 1 deletion djangocms_frontend/contrib/link/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@
return None


def get_link_choices(request, term="", lang=None, nbsp=""):
def get_link_choices(request, term="", lang=None, nbsp=None):
global _querysets

if nbsp is None:
nbsp = "" if term else "\u2000"

Check warning on line 68 in djangocms_frontend/contrib/link/helpers.py

View check run for this annotation

Codecov / codecov/patch

djangocms_frontend/contrib/link/helpers.py#L68

Added line #L68 was not covered by tests
available_objects = []
# Now create our list of cms pages
type_id = ContentType.objects.get_for_model(Page).id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

{% block extrahead %}
{{ block.super }}
<style> {# Bugfix for Django admin styling #}
@media screen {
.change-form .select2-dropdown {
background: var(--body-bg);
border: 1px solid var(--border-color);
}
}
</style>
<script src="{% static 'djangocms_frontend/js/bundle.link.js' %}"></script>
{% endblock %}

Expand Down
2 changes: 1 addition & 1 deletion djangocms_frontend/contrib/link/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# TODO Check permissions
# ======================
self.term = kwargs.get("term", request.GET.get("term", ""))
self.term = kwargs.get("term", request.GET.get("term", "")).strip()

Check warning on line 25 in djangocms_frontend/contrib/link/views.py

View check run for this annotation

Codecov / codecov/patch

djangocms_frontend/contrib/link/views.py#L25

Added line #L25 was not covered by tests
results = get_link_choices(request, self.term)
return JsonResponse(
{
Expand Down
Binary file modified djangocms_frontend/locale/ar/LC_MESSAGES/django.mo
Binary file not shown.
Loading