Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
simod committed Dec 1, 2016
2 parents c7b97d6 + f7d41c6 commit 064b1e3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions geonode/base/autocomplete_light_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,27 @@
import autocomplete_light

from models import ResourceBase, Region, HierarchicalKeyword
from guardian.shortcuts import get_objects_for_user


class ResourceBaseAutocomplete(autocomplete_light.AutocompleteModelTemplate):
choice_template = 'autocomplete_response.html'
model = ResourceBase

def choices_for_request(self):
permitted = get_objects_for_user(
self.request.user,
'base.view_resourcebase')
self.choices = self.choices.filter(id__in=permitted)

return super(ResourceBaseAutocomplete, self).choices_for_request()


autocomplete_light.register(Region,
search_fields=['name'],
autocomplete_js_attributes={'placeholder': 'Region/Country ..', },)

autocomplete_light.register(ResourceBase,
ResourceBaseAutocomplete,
autocomplete_light.register(ResourceBaseAutocomplete,
search_fields=['title'],
order_by=['title'],
limit_choices=100,
Expand Down

0 comments on commit 064b1e3

Please sign in to comment.