def ready(self): from products.models import PricedProduct, ProductVariationValue import autocomplete_light autocomplete_light.register(PricedProduct, search_fields=['product__name']) autocomplete_light.register(ProductVariationValue, search_fields=['name', 'variation__name'])
def register_concept_autocomplete(concept_class, *args, **kwargs): """ Registers the given ``concept`` with ``autocomplete_light`` based on the in-built ``aristotle_mdr.autocomplete_light_registry.PermissionsAutocomplete``. This ensures the autocomplete for the registered conforms to Aristotle permissions. :param concept concept_class: The model that is to be registered """ x = reg.autocompleteTemplate.copy() x['name'] = 'Autocomplete' + concept_class.__name__ autocomplete_light.register(concept_class, reg.PermissionsAutocomplete, **x)
from mariners_profile.models import ReferrersPool import autocomplete_light class ReferrerAutocomplete(autocomplete_light.AutocompleteModelTemplate): search_fields = ['^name', ] model = ReferrersPool # Template that removes the "Results not Found" autocomplete_template = 'autocomplete_template.html' autocomplete_light.register(ReferrerAutocomplete)
import autocomplete_light from accounts.models import UserContact autocomplete_light.register( UserContact, search_fields=('search_names', ), autocomplete_js_attributes={'placeholder': 'city name ..'})
import autocomplete_light import appomatic_arbetsformedling.models autocomplete_light.register( appomatic_arbetsformedling.models.Skill, search_fields=['name'], add_another_url_name='appomatic_arbetsformedling.views.skill_create')
import autocomplete_light from models import Document autocomplete_light.register( Document, search_fields=['^title'], autocomplete_js_attributes={ 'placeholder': 'Document name..', }, )
import autocomplete_light from people.models import Person class PersonAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['given_names', 'surname'] model = Person attrs = { 'placeholder': 'Leave blank if anonymous', } autocomplete_light.register(PersonAutocomplete)
import autocomplete_light from taggit.models import Tag autocomplete_light.register(Tag)
# -*- coding: utf-8 -*- ######################################################################### # # Copyright (C) 2016 OSGeo # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### import autocomplete_light from models import Layer autocomplete_light.register( Layer, search_fields=['^title', '^typename'], autocomplete_js_attributes={ 'placeholder': 'Layer name..', }, )
import autocomplete_light from organization.functions import job_render_reference from organization.models import Job class JobAutocomplete(autocomplete_light.AutocompleteModelBase): choices = Job.objects.filter().order_by('-ordering') search_fields = ['title'] display_edit_link = True field_name = 'jobs' def choice_label(self, choice): return job_render_reference(choice, self.display_edit_link, self.field_name) def choice_html(self, choice): return self.choice_html_format % ( self.choice_value(choice), self.choice_label(choice)) autocomplete_light.register(Job, JobAutocomplete)
from django.contrib import admin from django.db.models import ManyToManyField import autocomplete_light from utils import get_form_models, get_search_fields for form_name, form_model in get_form_models(): try: class FormAdmin(admin.ModelAdmin): list_display = [field.name for field in form_model._meta.fields if field.name in form_model.label_fields and not isinstance(field, ManyToManyField)] search_fields = get_search_fields(form_model) admin.site.register(form_model, FormAdmin) except AttributeError: admin.site.register(form_model) autocomplete_light.register(form_model, search_fields=get_search_fields(form_model))
# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### import autocomplete_light from .models import Profile class ProfileAutocomplete(autocomplete_light.AutocompleteModelTemplate): choice_template = 'autocomplete_response.html' def choices_for_request(self): self.choices = self.choices.exclude(username='******') return super(ProfileAutocomplete, self).choices_for_request() autocomplete_light.register( Profile, ProfileAutocomplete, search_fields=['first_name', 'last_name', 'email', 'username'], )
) except: return choice_format % (self.choice_value(choice), self.choice_label(choice)) class OrganizerAutocomplete(AutocompleteCustom): search_fields = ['name'] model = Organizer attrs = { # This will set the input placeholder attribute: 'placeholder': "Veuillez saisir l'organisateur", # This will set the yourlabs.Autocomplete.minimumCharacters # options, the naming conversion is handled by jQuery 'data-autocomplete-minimum-characters': 1, } autocomplete_light.register(OrganizerAutocomplete, add_another_url_name='add_another_organizer_create') class LabelAutocomplete(AutocompleteCustom): search_fields = ['name'] model = Label attrs = { # This will set the input placeholder attribute: 'placeholder': "ex. Ironman, ...", # This will set the yourlabs.Autocomplete.minimumCharacters # options, the naming conversion is handled by jQuery 'data-autocomplete-minimum-characters': 1, } autocomplete_light.register(LabelAutocomplete, add_another_url_name='add_another_label_create')
Q(etablissement__etablissement__nom__icontains=q) | Q(discipline__display_name__icontains=q) | Q(niveau__display_name__icontains=q)).distinct()[:10] return results def autocomplete_html(self): html = [] choice_html_format = """ <span class="div" style="text-align: left;"> <a class="blue" href="/recherche/%s/"> %s </a> </span>""" choice = self.choices_for_request() for item in choice['offre']: html.append( choice_html_format % (item.etablissement.etablissement.id, unicode(item).split(':')[0])) if not html: html = self.empty_html_format % _(u'aucun résultat').capitalize() return self.autocomplete_html_format % ''.join(html) autocomplete_light.register(SearchAutocomplete)
import autocomplete_light from models import WFPDocument class WFPDocumentWfpDocsAutocomplete( autocomplete_light.AutocompleteModelTemplate): choice_template = 'autocomplete_response.html' autocomplete_light.register( WFPDocument, WFPDocumentWfpDocsAutocomplete, search_fields=['title'], order_by=['title'], limit_choices=30, autocomplete_js_attributes={ 'placeholder': 'Staticmap name..', }, )
import autocomplete_light from dormbase.personal.models import Guest autocomplete_light.register(Guest, autocomplete_light.AutocompleteModelTemplate, choice_template='desk/guest_choice.html', search_fields=('athena', 'fullname'), name="GuestSigninAutocomplete")
import autocomplete_light from models import Media autocomplete_light.register(Media, search_fields=('name',))
import autocomplete_light from models import Artist class ArtistAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['name',] autocomplete_light.register(Artist, ArtistAutocomplete)
import autocomplete_light from taggit.models import Tag from models import ResourceBase, Region class ResourceBaseAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields=['title', 'group__title', 'owner__username', 'keywords__name'] def choices_for_request(self): self.choices = self.choices.distinct() 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 # search_fields=['title', 'group__title', 'owner__username', 'keywords__name'], # autocomplete_js_attributes={'placeholder': 'Resource name..', }, ) autocomplete_light.register(Tag, search_fields=['name', 'slug'], autocomplete_js_attributes={'placeholder': 'A space or comma-separated list of keywords', },)
import autocomplete_light from .models import * models = [OtoModel, FkModel, MtmModel, GfkModel] try: import genericm2m except ImportError: pass else: models.append(GmtmModel) for model in models: autocomplete_light.register(model) class A(autocomplete_light.AutocompleteGenericBase): choices=[m.objects.all() for m in models] search_fields=[['name']] * len(models) autocomplete_light.register(A) # The autocomplete for class B is used to set up the test case for # autocomplete_light.tests.widgets.TextWidgetTestCase.test_widget_attrs_copy. # This bug is triggered only when the autocomplete is registered with a # widget_attrs dictionary. class B(autocomplete_light.AutocompleteGenericBase): choices=[m.objects.all() for m in models]
#-*- coding:utf-8 -*- from projectsapp.apps.members.models import Member from projectsapp.apps.projects.models import Project import autocomplete_light autocomplete_light.register( Project, search_fields=('name', ), autocomplete_js_attributes={'placeholder': 'Project...'}) autocomplete_light.register( Member, autocomplete_light.AutocompleteModelTemplate, autocomplete_template='autocomplete_template/member_autocomplete.html', search_fields=( 'name', 'trademark', ), autocomplete_js_attributes={'placeholder': 'Member...'})
import autocomplete_light from cities_light.models import Country, City from django.contrib.auth.models import User, Group class AutocompleteTaggableItems(autocomplete_light.AutocompleteGenericBase): choices = ( User.objects.all(), Group.objects.all(), City.objects.all(), Country.objects.all(), ) search_fields = ( ('username', 'email'), ('name',), ('search_names',), ('name_ascii',), ) autocomplete_light.register(AutocompleteTaggableItems)
import autocomplete_light from models import OutsideAdmin autocomplete_light.register(OutsideAdmin, search_fields=('name',))
from django.contrib.auth.models import User import autocomplete_light from mozillians.users.models import UserProfile class VouchedUserProfileAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['full_name', 'user__email'] choices = UserProfile.objects.vouched() autocomplete_light.register(UserProfile, VouchedUserProfileAutocomplete, name='VouchedUserProfiles') class VouchedUserAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['userprofile__full_name', 'email'] choices = (User.objects.exclude(userprofile__full_name='').filter( userprofile__is_vouched=True)) autocomplete_light.register(User, VouchedUserAutocomplete, name='VouchedUsers')
class EstudioPacienteForm(autocomplete_light.ModelForm): hidden_redirect = forms.CharField(widget=forms.HiddenInput(),initial="/estudios-radiologicos/") class Meta: model = EstudioPaciente dateTimeOptions = { #'pickerPosition' : 'bottom-left', 'todayHighlight' : True, } widgets = {'hora_fecha_inicio': DateTimeWidget(attrs={'id':"yourdatetimeid"}, usel10n = True, bootstrap_version=3,options=dateTimeOptions), 'hora_fecha_fin': DateTimeWidget(attrs={'id':"yourdatetimeid2"}, usel10n = True, bootstrap_version=3,options=dateTimeOptions) } class FechaForm(forms.Form): dateTimeOptions = { 'todayHighlight' : True, } fecha = forms.DateField(widget=DateWidget(usel10n=True, bootstrap_version=3, options=dateTimeOptions)) #AUTOCOMPLETE LIGHT - AUTOCOMPLETE LIGHT - AUTOCOMPLETE LIGHT - AUTOCOMPLETE LIGHT class ExpedienteAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['^paciente__carnet', ] model = Expediente autocomplete_light.register(ExpedienteAutocomplete) class SolicitudAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['^id', ] model = Solicitud autocomplete_light.register(SolicitudAutocomplete)
choices = super(JurisdictionAutocomplete, self).choices_for_request() self.choices = [] for choice in choices: self.choices.append(choice) if choice.children: self.choices.append((choice, choice.children)) return self.choices def choice_value(self, choice): if isinstance(choice, Jurisdiction): return choice.pk return choice[0].pk def choice_label(self, choice): if isinstance(choice, Jurisdiction): return choice.get_jurisdiction_display() return 'All jurisdictions within ' + choice[ 0].get_jurisdiction_display() def choice_html(self, choice): # I hope the label never needs to be escaped if isinstance(choice, (list, tuple)): return self.choice_html_format_multiple % (escape( self.choice_value(choice)), escape( choice[1]), self.choice_label(choice)) return self.choice_html_format % (escape( self.choice_value(choice)), self.choice_label(choice)) autocomplete_light.register(Jurisdiction, JurisdictionAutocomplete)
from django.contrib.auth.models import User import autocomplete_light class UserAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ("username", "email", "first_name", "last_name") autocomplete_js_attributes = {"placeholder": "type a user name ..."} autocomplete_light.register(User, UserAutocomplete)
from cinema.models import Film, Person, Genre, Keyword from django.db.models import Q from itertools import chain # Autocompletion pour un film class FilmAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['original_title', 'english_title'] autocomplete_js_attributes = {'placeholder': 'Title ?'} def choice_value(self, film): return film.imdb_id autocomplete_light.register(Film, FilmAutocomplete) # Autocompletion pour une personne class PersonAutocomplete(autocomplete_light.AutocompleteModelTemplate): search_fields = ['name'] choice_template = 'autocomplete/person_autocomplete.html' autocomplete_light.register(Person, PersonAutocomplete, name='Actor', choices=(Person.objects.filter( Q(actorweight__rank__isnull=False) | Q(actorweight__star=True)).distinct()), autocomplete_js_attributes={
# # Copyright (C) 2016 OSGeo # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### import autocomplete_light from .models import GroupProfile class GroupProfileAutocomplete(autocomplete_light.AutocompleteModelTemplate): choice_template = 'autocomplete_response.html' autocomplete_light.register( GroupProfile, GroupProfileAutocomplete, search_fields=['title'], )
# coding=utf-8 from __future__ import unicode_literals import autocomplete_light from tagging.models import Tag autocomplete_light.register(Tag, search_fields=['^name'])
import autocomplete_light from models import School class SchoolAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = [ 'name', 'address', 'post', # TODO add the functionality below #'^former_profile_set__user__first_name', #'^former_profile_set__user__last_name', #'^former_profile_set__user__email_name', #'^former_profile_set__user__username', ] model = School attrs={ 'placeholder': '', 'data-autocomplete-minimum-characters': 1, } autocomplete_light.register(SchoolAutocomplete)
import autocomplete_light from models import TemplatedChoice autocomplete_light.register(TemplatedChoice, autocomplete_light.AutocompleteModelTemplate)
# # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### import autocomplete_light from taggit.models import Tag from models import ResourceBase, Region class ResourceBaseAutocomplete(autocomplete_light.AutocompleteModelTemplate): choice_template = 'autocomplete_response.html' autocomplete_light.register(Region, search_fields=['name'], autocomplete_js_attributes={'placeholder': 'Region/Country ..', },) autocomplete_light.register(ResourceBase, ResourceBaseAutocomplete, search_fields=['title'], order_by=['title'], limit_choices=100, autocomplete_js_attributes={'placeholder': 'Resource name..', },) autocomplete_light.register(Tag, search_fields=['name', 'slug'], autocomplete_js_attributes={'placeholder': 'A space or comma-separated list of keywords', },)
from django.contrib.auth.models import User, Group class UserAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields=['username','first_name','last_name'] def choice_label(self, choice): label = "" if choice.first_name: label += choice.first_name if choice.last_name: if choice.first_name: label += " " label += choice.last_name if choice.userprofile.organization: if choice.first_name or choice.last_name: label += ", " label += choice.userprofile.organization if choice.username: label += "".join([" (", choice.username, ")"]) return label autocomplete_light.register(User, UserAutocomplete) autocomplete_light.register(Group, search_fields=['name'])
from django.contrib.auth.models import User import autocomplete_light from mozillians.users.models import UserProfile class VouchedUserProfileAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['full_name', 'user__email', 'user__username'] choices = UserProfile.objects.vouched() autocomplete_light.register(UserProfile, VouchedUserProfileAutocomplete, name='VouchedUserProfiles') class VouchedUserAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['userprofile__full_name', 'email'] choices = (User.objects.exclude(userprofile__full_name='') .filter(userprofile__is_vouched=True)) autocomplete_light.register(User, VouchedUserAutocomplete, name='VouchedUsers')
import autocomplete_light from models import TemplatedChoice autocomplete_light.register( TemplatedChoice, autocomplete_light.AutocompleteModelTemplate, choice_template='template_autocomplete/templated_choice.html')
from autocomplete_light.contrib.hvad import AutocompleteModelBase import autocomplete_light from .models import Category autocomplete_light.registry.autocomplete_model_base = AutocompleteModelBase autocomplete_light.register(Category, search_fields=('name',))
from django.contrib import admin from django import forms from django.contrib.contenttypes.models import ContentType from django.utils.translation import ugettext_lazy as _ from apps.tags.models import TaggedCategory from .models import SpecificQuestion, SpecificQuestionType from apps.project_sheet.models import I4pProjectTranslation from apps.workgroup.models import WorkGroup import autocomplete_light from askbot.models.question import Thread autocomplete_light.register(Thread, search_fields=['title']) class AutocompleteSpecificQuestionContext( autocomplete_light.AutocompleteGenericBase): choices = ( I4pProjectTranslation.objects.all(), WorkGroup.objects.all(), ) def choice_label(self, choice): if isinstance(choice, I4pProjectTranslation): print choice.__dict__ return u"%s #%s: %s (%s)" % (_('project'), choice.id, choice.title, choice.language_code) elif isinstance(choice, WorkGroup): return u"%s #%s: %s (%s)" % (_('workgroup'), choice.id,
def __init__(self, *args, **kwargs): super(GrassAdmin, self).__init__(*args, **kwargs) for inline in self.inlines: if issubclass(inline, GrassInlineModelAdmin): autocomplete_light.register(inline.get_autocomplete_class())
import autocomplete_light from tagging.models import Tag autocomplete_light.register(Tag)
class DcCreatorAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['^first_name', 'last_name_prefix', 'last_name'] model = DcCreator add_another_url_name = 'dariah_core:dccreator_create' attrs = { # This will set the input placeholder attribute: 'placeholder': 'Start typing...', # This will set the yourlabs.Autocomplete.minimumCharacters # options, the naming conversion is handled by jQuery 'data-autocomplete-minimum-characters': 1, } widget_attrs = {} @property def empty_html_format(self): data = {'model': self.model.lowercase_underscore_name(), 'url': self.add_another_url_name} return render_to_string('dariah_core/_creator-contrib_autocomplete_empty_html_format.html', data) class DcContributorAutocomplete(DcCreatorAutocomplete): model = DcContributor add_another_url_name = 'dariah_core:dccontributor_create' autocomplete_light.register(Tag) autocomplete_light.register(DcCreator, DcCreatorAutocomplete) autocomplete_light.register(DcContributor, DcContributorAutocomplete)
# (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### import autocomplete_light from models import Map class MapAutocomplete(autocomplete_light.AutocompleteModelTemplate): choice_template = 'autocomplete_response.html' autocomplete_light.register( Map, MapAutocomplete, search_fields=['title'], order_by=['title'], limit_choices=100, autocomplete_js_attributes={ 'placeholder': 'Map name..', }, )
# # Copyright (C) 2012 Open Source Geospatial Foundation # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### import autocomplete_light from models import Layer autocomplete_light.register( Layer, search_fields=[ '^title', '^typename'], autocomplete_js_attributes={ 'placeholder': 'Layer name..', }, )
import autocomplete_light from .models import Profile autocomplete_light.register( Profile, search_fields=['^first_name', '^email', '^username'], autocomplete_js_attributes={ 'placeholder': 'name or email..', }, )
# Copyright 2014 Vypo # # message f=autocomplete_light_registry.py&n=ea8f0b6c7e14e411 # sha256 f0745c597c4f0668a3a7d95dbdafbef08856bc7f614b7d7e53676e47c4b034db # # This file is part of BuilderDB. # # BuilderDB is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # BuilderDB is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with BuilderDB. If not, see <http://www.gnu.org/licenses/>. import autocomplete_light from django.contrib.auth.models import User autocomplete_light.register(User, search_fields=['username'], attrs={'data-autocomplete-minimum-characters': 3}, widget_attrs={ 'data-widget-maximum-values': 10, 'class': 'modern-style' } )
from .models import * import autocomplete_light class IssueReportAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['id', 'name'] attrs = {'placeholder': 'Report...'} model = Report widget_attrs = { 'class': 'modern-style', } autocomplete_light.register(IssueReportAutocomplete)
from tracking.models import Organization, Physician import autocomplete_light autocomplete_light.register( Organization, search_fields=["org_name"], attrs={"data-autcomplete-minimum-characters": 3, "placeholder": "Select Group", "style": "width:173px;"}, ) autocomplete_light.register( Physician, search_fields=["physician_name"], attrs={"data-autcomplete-minimum-characters": 3, "placeholder": "Select Practitioner", "style": "width:173px;"}, )
import autocomplete_light from .models import Articulo class ArticuloAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['descripcion', 'codigo_barra', 'id'] autocomplete_light.register(Articulo, ArticuloAutocomplete, name='ArticuloAutocomplete', choices=Articulo.objects.all())
# it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### import autocomplete_light from .models import Profile class ProfileAutocomplete(autocomplete_light.AutocompleteModelTemplate): choice_template = 'autocomplete_response.html' def choices_for_request(self): self.choices = self.choices.exclude(username='******') return super(ProfileAutocomplete, self).choices_for_request() autocomplete_light.register( Profile, ProfileAutocomplete, search_fields=['first_name', 'last_name', 'email', 'username'], )
add_another_url_name = 'dariah_core:dccreator_create' attrs = { # This will set the input placeholder attribute: 'placeholder': 'Start typing...', # This will set the yourlabs.Autocomplete.minimumCharacters # options, the naming conversion is handled by jQuery 'data-autocomplete-minimum-characters': 1, } widget_attrs = {} @property def empty_html_format(self): data = { 'model': self.model.lowercase_underscore_name(), 'url': self.add_another_url_name } return render_to_string( 'dariah_core/_creator-contrib_autocomplete_empty_html_format.html', data) class DcContributorAutocomplete(DcCreatorAutocomplete): model = DcContributor add_another_url_name = 'dariah_core:dccontributor_create' autocomplete_light.register(Tag) autocomplete_light.register(DcCreator, DcCreatorAutocomplete) autocomplete_light.register(DcContributor, DcContributorAutocomplete)
import autocomplete_light from example.models import Person # This will generate a PersonAutocomplete class autocomplete_light.register(Person, # Just like in ModelAdmin.search_fields search_fields=['FirstName', 'LastName'], attrs={ # This will set the input placeholder attribute: #'placeholder': 'Other model name ?', # This will set the yourlabs.Autocomplete.minimumCharacters # options, the naming conversion is handled by jQuery 'data-autocomplete-minimum-characters': 1, }, # This will set the data-widget-maximum-values attribute on the # widget container element, and will be set to # yourlabs.Widget.maximumValues (jQuery handles the naming # conversion). widget_attrs={ 'data-widget-maximum-values': 4, # Enable modern-style widget ! 'class': 'modern-style', }, )
import autocomplete_light from recipe.models import Recipe autocomplete_light.register(Recipe, search_fields=('name',), autocomplete_js_attributes={'placeholder': 'recipe name ..'})
import autocomplete_light from .models import Profile class ProfileAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = [ '^first_name', '^email', '^username'] def choices_for_request(self): self.choices = self.choices.exclude(username='******') return super(ProfileAutocomplete, self).choices_for_request() autocomplete_light.register( Profile, ProfileAutocomplete )
import autocomplete_light from .models import Area autocomplete_light.register(Area, search_fields=('search_names',), autocomplete_js_attributes={'placeholder': 'area name ..'})
# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### import autocomplete_light from models import Document class DocumentAutocomplete(autocomplete_light.AutocompleteModelTemplate): choice_template = 'autocomplete_response.html' autocomplete_light.register( Document, DocumentAutocomplete, search_fields=['title'], order_by=['title'], limit_choices=100, autocomplete_js_attributes={ 'placeholder': 'Document name..', }, )
search_fields = ['^username'] choices = User.objects.filter( Q(user_level=User.ADMIN) | Q(user_level=User.JUDGE) | Q(user_level=User.SUB_JUDGE)) model = User attrs = {'placeholder': '', 'data-autocomplete-minimum-characters': 1} class TagAutocomplete(autocomplete_light.AutocompleteModelBase): search_fields = ['^tag_name'] choices = Tag.objects.all() model = Tag attrs = {'placeholder': '', 'data-autocomplete-minimum-characters': 1} autocomplete_light.register(UserAutocomplete) autocomplete_light.register(TagAutocomplete) class ProblemForm(forms.ModelForm): other_judge_id = forms.IntegerField(required=False, min_value=0) partial_judge_code = forms.FileField(required=False) partial_judge_header = forms.FileField(required=False) special_judge_code = forms.FileField(required=False) class Meta: model = Problem fields = [ 'pname', 'description', 'input',
# coding=utf-8 from __future__ import unicode_literals import autocomplete_light from tagging.models import Tag autocomplete_light.register( Tag, search_fields=['^name'] )
import autocomplete_light from models import Record class AutocompleteRecord(autocomplete_light.AutocompleteModelBase): search_fields = ['..'] widget_template = 'formapp/autocomplete_record_widget.html' add_another_url_name = 'create_gateway' def choices_for_request(self): q = self.request.GET.get('q', '') exclude = self.request.GET.getlist('exclude', []) self.feature = self.request.GET['feature'] if q: choices = Record.objects.filter(text_data__icontains=q) else: choices = Record.objects.all() choices = choices.filter( form__appform__app__provides_id=self.feature, environment=self.request.session['appstore_environment']) return self.order_choices(choices).exclude(pk__in=exclude )[0:self.limit_choices] autocomplete_light.register(Record, AutocompleteRecord, name='AutocompleteRecord')
import autocomplete_light from .models import CodeModel class AutocompleteCode(autocomplete_light.AutocompleteModelBase): '''Autocomplete for non-id foreign key ''' autocomplete_js_attributes = {'placeholder': u'Start type name...'} search_fields = ('name',) def choice_value(self, choice): return choice.code autocomplete_light.register(CodeModel, AutocompleteCode)
class FacultyAutocomplete(UserAutocomplete): attrs = { 'placeholder': 'Lookup Faculty', } class ActiveStudentAutocomplete(UserAutocomplete): choices = Student.objects.filter(is_active=True) class LookupStudentAutocomplete(UserAutocomplete, autocomplete_light.AutocompleteModelTemplate): autocomplete_template = 'sis/lookup_student.html' class ContactAutocomplete(autocomplete_light.AutocompleteModelTemplate): split_words = True search_fields = ['fname', 'lname'] attrs = { 'placeholder': 'Lookup Contact(s)', } choice_template = 'sis/autocomplete_contact.html' autocomplete_light.register(EmergencyContact, ContactAutocomplete) autocomplete_light.register(Student, UserAutocomplete) autocomplete_light.register(Student, ActiveStudentAutocomplete) autocomplete_light.register(Faculty, FacultyAutocomplete) autocomplete_light.register(Student, LookupStudentAutocomplete)