Skip to content

Commit

Permalink
Slight improvement to the move form generation
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Feb 26, 2024
1 parent bec2c63 commit 33938a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Next version
``feincms3.plugins`` to also accept a (for now optional) context parameter.
Previously those functions were not directly usable with
``RegionRenderer.register``.
- Move form: Use a potentially restricted ``ModelAdmin.get_queryset`` method
instead of the default model manager to generate potential targets.
- Improved the test coverage a bit.

4.5 (2023-11-01)
~~~~~~~~~~~~~~~~
Expand Down
8 changes: 7 additions & 1 deletion feincms3/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ def __init__(self, *args, **kwargs):

super().__init__(*args, **kwargs)

choices = self._generate_choices(self.model._default_manager.with_tree_fields())
choices = self._generate_choices(
self.modeladmin.get_queryset(self.request).with_tree_fields()
)
self.fields["new_location"] = forms.ChoiceField(
label=_("New location"),
widget=forms.RadioSelect,
Expand Down Expand Up @@ -339,6 +341,10 @@ def clean(self):
else:
self.instance.parent = data["relative"].parent

# FIXME feincms3-sites would also require site_id,
# feincms3-language-sites would also require language_code to be set
# for the cleaning step to work correctly in all cases.

# All fields of model are not in this form
self.instance.full_clean(
exclude=[f.name for f in self.model._meta.get_fields()]
Expand Down

0 comments on commit 33938a9

Please sign in to comment.