Skip to content

Commit

Permalink
Remove more legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Oct 28, 2024
1 parent 9ef96d6 commit 5c8e79f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 2 additions & 4 deletions djangocms_link/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class LinkFormField(Field):
file_link_validators = []
anchor_validators = [AnchorValidator()]

empty_values = [{}] + [{link_type: ""} for link_type in link_types]
empty_values = [None, {}]

def __init__(self, *args, **kwargs):
kwargs.setdefault("help_text", _("Select a link type and provide a link."))
Expand All @@ -280,8 +280,6 @@ def __init__(self, *args, **kwargs):
def prepare_value(self, value):
if isinstance(value, list):
return value

Check warning on line 282 in djangocms_link/fields.py

View check run for this annotation

Codecov / codecov/patch

djangocms_link/fields.py#L282

Added line #L282 was not covered by tests
if value is None:
value = {}
multi_value = len(self.widget.widgets) * [None]
if "external_link" in value:
pos = self._get_pos("external_link")
Expand Down Expand Up @@ -310,7 +308,7 @@ def to_python(self, value):
return {}
pos_anchor = self._get_pos("anchor")

python = {link_type: value[pos]}
python = {link_type: value[pos]} if value[pos] else {}
if link_type == "internal_link" and pos_anchor and value[pos_anchor]:
python["anchor"] = value[pos_anchor]
return python
Expand Down
6 changes: 0 additions & 6 deletions djangocms_link/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
from django.db import models


def get_queryset_manager(base: models.QuerySet | models.Manager) -> models.QuerySet:
if hasattr(base, "drafts"):
return base.drafts()
return base


def get_manager(model: models.Model, current_content: bool = False) -> models.Manager:
if hasattr(model, "admin_manager"):
return model.admin_manager.current_content() if current_content else model.admin_manager
Expand Down

0 comments on commit 5c8e79f

Please sign in to comment.