<commit_before>import autocomplete_light
from models import Monster, MonsterInstance


class MonsterAutocomplete(autocomplete_light.AutocompleteModelTemplate):
    model = Monster
    search_fields = ['name', 'awakens_from__name', 'awakens_to__name', '^element']
    split_words = True
    choice_template = 'autocomplete/monster_choice.html'
    limit_choices = 15
    attrs = {
        'placeholder': 'Start typing monster name',
        'data-autocomplete-minimum-characters': 2,
    }

    def choices_for_request(self):
        self.choices = self.choices.filter(obtainable=True).order_by('element', 'is_awakened')
        return super(MonsterAutocomplete, self).choices_for_request()

autocomplete_light.register(MonsterAutocomplete)


class MonsterInstanceAutocomplete(autocomplete_light.AutocompleteModelTemplate):
    model = MonsterInstance
    search_fields = ['monster__name', 'monster__awakens_from__name', 'monster__awakens_to__name', '^monster__element']
    split_words = True
    choice_template = 'autocomplete/monster_instance_choice.html'
    limit_choices = 15
    attrs = {
        'placeholder': 'Start typing monster name',
        'data-autocomplete-minimum-characters': 2,
    }

    def choices_for_request(self):

        self.choices = self.choices.filter(owner=self.request.user.summoner)
        monster_filter = self.request.GET.get('monster', None)

        # set .data of input autocomplete to {monster: <<id>>} in javascript to add query parameter

        if monster_filter:
            self.choices = self.choices.filter(monster__pk=monster_filter)

        return super(MonsterInstanceAutocomplete, self).choices_for_request()

autocomplete_light.register(MonsterInstanceAutocomplete)<commit_msg>Added food/storage display<commit_after>import autocomplete_light
from models import Monster, MonsterInstance


class MonsterAutocomplete(autocomplete_light.AutocompleteModelTemplate):
    model = Monster
    search_fields = ['name', 'awakens_from__name', 'awakens_to__name', '^element']
    split_words = True
    choice_template = 'autocomplete/monster_choice.html'
    limit_choices = 15
    attrs = {
        'placeholder': 'Start typing monster name',
        'data-autocomplete-minimum-characters': 2,
    }

    def choices_for_request(self):
        self.choices = self.choices.filter(obtainable=True).order_by('element', 'is_awakened')
        return super(MonsterAutocomplete, self).choices_for_request()

autocomplete_light.register(MonsterAutocomplete)


class MonsterInstanceAutocomplete(autocomplete_light.AutocompleteModelTemplate):
    model = MonsterInstance
    search_fields = ['monster__name', 'monster__awakens_from__name', 'monster__awakens_to__name', '^monster__element']
    split_words = True
    choice_template = 'autocomplete/monster_instance_choice.html'
    limit_choices = 15
    attrs = {
        'placeholder': 'Start typing monster name',
        'data-autocomplete-minimum-characters': 2,
    }

    def choices_for_request(self):
        self.choices = self.choices.filter(owner=self.request.user.summoner)
        monster_filter = self.request.GET.get('monster', None)

        # set .data of input autocomplete to {monster: <<id>>} in javascript to add query parameter
        # See line 265 autocomplete.js

        if monster_filter:
            self.choices = self.choices.filter(monster__pk=monster_filter)

        return super(MonsterInstanceAutocomplete, self).choices_for_request()

autocomplete_light.register(MonsterInstanceAutocomplete)
{'fraction_non_alphanumeric': 0.09462915601023018, 'fraction_numerical': 0.004262574595055414, 'mean_word_length': 4.357686453576864, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2962913', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1013, 'n_words': 187}