Skip to content

Commit

Permalink
Issue samluescher#25: Only folders for the current site.
Browse files Browse the repository at this point in the history
Also filter folders that has been registerred in the current site.
  • Loading branch information
erlenddalen committed May 27, 2013
1 parent a21d6ff commit 14daa62
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions media_tree/admin/filenode_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'parent' and issubclass(db_field.rel.to, FileNode):
# overriding formfield_for_dbfield, thus bypassign both Django's and mptt's
# formfield_for_foreignkey method, and also preventing Django from wrapping
# field with RelatedFieldWidgetWrapper ("add" button resulting in a file add form)
valid_targets = FileNode.tree.filter(**db_field.rel.limit_choices_to)
# field with RelatedFieldWidgetWrapper ("add" button resulting in a file add form)

# Issue 25 - Only allow folders registerred in the current site.
valid_targets = FileNode.tree.filter(**db_field.rel.limit_choices_to).filter(
site=Site.objects.get_current())
request = kwargs['request']
node = get_request_attr(request, 'save_node', None)
if node:
Expand Down

0 comments on commit 14daa62

Please sign in to comment.