本文整理汇总了Python中selectable.registry.registry.register函数的典型用法代码示例。如果您正苦于以下问题:Python register函数的具体用法?Python register怎么用?Python register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了register函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get
def get(self, request):
# pylint: disable=E1101
# Instance of <class> has no <member>
# pylint: disable=W0142
# Used * or ** magic
# import from selectable locally so it's not a hard dependency
from selectable.forms import AutoCompleteWidget
from selectable.registry import registry
data = request.GET
model_class = get_model(data['app_label'], data['model_name'])
if not model_class:
raise Http404('"{0}" model not found'.format(data['model_name']))
lookup_name = data.get('lookup', None)
if lookup_name:
lookup_class = registry.get(lookup_name)
else:
lookup_class_name = u'Flyedit{app_label}{model_name}Lookup'.format(
app_label=data['app_label'].title(),
model_name=model_class._meta.object_name)
lookup_name = ('flyedit-{0}'.format(lookup_class_name.lower()))
lookup_class = registry.get(lookup_name)
if not lookup_class:
# create a default lookup class on the fly
from selectable.base import ModelLookup
first_charfield = (f for f in model_class._meta.fields
if isinstance(f, CharField)).next()
search_field = '{0}__icontains'.format(first_charfield.name)
lookup_class = type(
lookup_class_name.encode('ascii'),
(ModelLookup,),
{'model': model_class,
'search_fields': [search_field]})
registry.register(lookup_class)
print lookup_class.model
print lookup_class.search_fields
# Use a dummy form class to render just the auto-complete field
class Form(forms.Form):
autocomplete = forms.CharField(
label=u'',
widget=AutoCompleteWidget(lookup_class))
return HttpResponse(Form()._html_output(
normal_row='<li class="new item">%(field)s</li>',
error_row='',
row_ender='',
help_text_html='',
errors_on_separate_row=False))
开发者ID:2general,项目名称:django-flyedit,代码行数:53,代码来源:views.py
示例2: get_cliente_lookup_widget
def get_cliente_lookup_widget(ruc_empresa):
""" Construye un widget lookup para autobus """
print 'get_cliente_lookup_widget - Para empresa', ruc_empresa
class ClienteLookup(ModelLookup):
model = impd_models.ImpdCliente
search_fields = ('identificacion__icontains', 'razon_social__icontains')
filters = {'estado': estado_activo, 'ruc_empresa':ruc_empresa}
def get_item_label(self, item):
return u'%s, %s' % (item.identificacion, item.razon_social)
try:
registry.register(ClienteLookup)
except:
pass
return ClientSearchWidget(lookup_class=ClienteLookup, attrs={'placeholder': __.PH_CLIENTE, 'class':'search_input', 'size':'30'})
开发者ID:rraidel89,项目名称:portal,代码行数:17,代码来源:lookups.py
示例3: get_factura_config_lookup_widget
def get_factura_config_lookup_widget(ruc_empresa):
""" Construye un widget lookup para autobus """
print 'get_factura_config_lookup_widget - Para empresa', ruc_empresa
class FacturaConfigLookup(ModelLookup):
model = impd_models.ImpdFacturaConfiguracion
search_fields = ('descripcion__icontains', 'establecimiento__icontains')
filters = {'estado': estado_activo, 'ruc_empresa':ruc_empresa}
def get_item_label(self, item):
return u'%s, %s' % (item.establecimiento, item.descripcion)
try:
registry.register(FacturaConfigLookup)
except:
pass
return ConfigSearchWidget(lookup_class=FacturaConfigLookup, attrs={'placeholder': __.PH_CONFIG, 'class':'search_input', 'size':'30'})
开发者ID:rraidel89,项目名称:portal,代码行数:17,代码来源:lookups.py
示例4: get_productos_lookup_widget
def get_productos_lookup_widget(ruc_empresa):
""" Construye un widget lookup para autobus """
print 'get_productos_lookup_widget - Para empresa', ruc_empresa
class ProductoLookup(ModelLookup):
model = core_models.Producto
search_fields = ('nombre__icontains', 'titulo__icontains', 'codigo_sku__icontains')
filters = {'estado': estado_activo, 'ruc_empresa':ruc_empresa}
def get_item_label(self, item):
return u'%s, %s' % (item.codigo_sku, item.nombre)
try:
registry.register(ProductoLookup)
except Exception as e:
print 'SELECTABLE ERROR', e
return selectable.AutoCompleteSelectWidget(lookup_class=ProductoLookup, attrs={'placeholder': __.PH_PRODUCTO, 'class':'form-control'})
开发者ID:rraidel89,项目名称:portal,代码行数:17,代码来源:lookups.py
示例5: get_destinatario_lookup_widget
def get_destinatario_lookup_widget(ruc_empresa):
""" Construye un widget lookup para autobus """
print 'get_destinatario_lookup_widget - Para empresa', ruc_empresa
class DestinarioLookup(ModelLookup):
model = impd_models.ImpdGRDestinatario
search_fields = ('identificacion_destinatario__icontains', 'razon_social_destinatario__icontains')
filters = {'estado': estado_activo, 'ruc_empresa':ruc_empresa}
def get_item_label(self, item):
return u'%s' % item.get_descripcion()
try:
registry.unregister(DestinarioLookup)
except:
pass
registry.register(DestinarioLookup)
return DestinatarioSearchWidget(lookup_class=DestinarioLookup,
attrs={'placeholder': __.PH_DESTINATARIO, 'class':'big-field', 'size':'30'})
开发者ID:rraidel89,项目名称:portal,代码行数:19,代码来源:lookups.py
示例6: formfield_for_dbfield
def formfield_for_dbfield(self, db_field, **kwargs):
if isinstance(db_field, models.ForeignKey):
request = kwargs.get("request")
related_modeladmin = self.admin_site._registry.get(db_field.rel.to)
can_change_related = bool(related_modeladmin and
related_modeladmin.has_add_permission(request))
if (isinstance(db_field, models.ForeignKey) and
db_field.name in self.related_search_fields):
class_name = self.__class__.__name__.lower()
model_name = db_field.name
name = u'%s-%s' % (class_name, model_name)
class Lookup(ModelLookup):
model = db_field.rel.to
search_fields = ['%s__icontains' % f for f in self.related_search_fields[db_field.name]]
def _name(cls):
return name
name = classmethod(_name)
def get_query(self, request, term):
qs = self.get_queryset()
if term:
for bit in term.split():
or_queries = [models.Q(**{field_name: smart_str(bit)})
for field_name in self.search_fields]
qs = qs.filter(reduce(operator.or_, or_queries))
return qs
try:
registry.register(Lookup)
except LookupAlreadyRegistered:
pass
if db_field.name in self.related_combobox:
kwargs['widget'] = AutoComboboxSelectEditWidget(db_field.rel,
self.admin_site, Lookup, can_change_related=can_change_related)
else:
kwargs['widget'] = AutoCompleteSelectEditWidget(db_field.rel,
self.admin_site, Lookup, can_change_related=can_change_related)
#elif isinstance(db_field, models.ForeignKey):
#kwargs['widget'] = SelectEditWidget(db_field.rel, self.admin_site,
#can_change_related=can_change_related)
return super(SelectableAdminMixin, self).formfield_for_dbfield(db_field, **kwargs)
开发者ID:makinacorpus,项目名称:django-coop,代码行数:39,代码来源:autocomplete_admin.py
示例7: get_producto_factura_lookup_widget
def get_producto_factura_lookup_widget(ruc_empresa):
""" Construye un widget lookup para autobus """
print 'get_productos_lookup_widget - Para empresa', ruc_empresa
class ProductoFacturaLookup(ModelLookup):
model = impd_models.ImpdProducto
search_fields = ('descripcion__icontains', 'codigo_principal__icontains', 'codigo_secundario__icontains')
filters = {'estado': estado_activo, 'ruc_empresa':ruc_empresa}
def get_item_label(self, item):
return u'%s, %s' % (item.codigo_principal, item.descripcion)
try:
registry.unregister(ProductoFacturaLookup)
except:
pass
try:
registry.register(ProductoFacturaLookup)
except:
pass
return ProductSearchWidget(lookup_class=ProductoFacturaLookup,
attrs={'placeholder': __.PH_PRODUCTO, 'class':'big-field', 'size':'30'})
开发者ID:rraidel89,项目名称:portal,代码行数:23,代码来源:lookups.py
示例8: ScientificNameLookup
from selectable.base import ModelLookup
from selectable.registry import registry
from demo.prpv.models import TOrganismeTaxo, Fruit
class ScientificNameLookup(ModelLookup):
model = TOrganismeTaxo
search_field = 'nom_scientifique__icontains'
class FruitLookup(ModelLookup):
model = Fruit
search_field = 'name__icontains'
registry.register(FruitLookup)
#registry.register(ScientificNameLookup)
开发者ID:mathilde-cirad,项目名称:demo-django,代码行数:16,代码来源:lookups.py
示例9: T3DonorCodeLookup
search_fields = ('code__icontains', )
filters = {'donor_code_type': DonorCode.T1, }
class T3DonorCodeLookup(ModelLookup):
model = DonorCode
search_fields = ('code__icontains', )
filters = {'donor_code_type': DonorCode.T3, }
class ItemCategoryLookup(ModelLookup):
model = ItemCategory
search_fields = ('name__icontains', )
class CatalogItemLookup(ModelLookup):
model = CatalogItem
search_fields = ('item_code__icontains', 'description__icontains')
def get_item_label(self, item):
if item.donor_id:
return '{} ({})'.format(item.description, item.donor)
else:
return item.description
registry.register(T1DonorCodeLookup)
registry.register(T3DonorCodeLookup)
registry.register(ItemCategoryLookup)
registry.register(CatalogItemLookup)
开发者ID:aqueiroz,项目名称:CTS,代码行数:30,代码来源:lookups.py
示例10: FruitLookup
from selectable.base import ModelLookup
from selectable.registry import registry
from sabr.models import Master
class FruitLookup(ModelLookup):
model = Fruit
search_field = 'name__icontains'
class PlayerLookup(ModelLookup)
model = Master
search_field = 'playerid__icontains'
registry.register(PlayerLookup)
开发者ID:iamdangeruss,项目名称:SABRtooth_production,代码行数:15,代码来源:lookup.py
示例11: suggestions
return suggestions(idiom=IDIOM_GRISCHUN,
direction=SEARCH_DIRECTION_RUM_DEU,
term=term,
limit=10)
class LookupBidirGri(LookupBase):
def get_query(self, request, term):
suggRum = suggestions(idiom=IDIOM_GRISCHUN,
direction=SEARCH_DIRECTION_RUM_DEU,
term=term,
limit=7)
suggDeu = suggestions(idiom=IDIOM_GRISCHUN,
direction=SEARCH_DIRECTION_DEU_RUM,
term=term,
limit=7)
sugg = suggRum + suggDeu
sugg.sort()
return sugg
registry.register(LookupDeuVal)
registry.register(LookupValDeu)
registry.register(LookupBidirVal)
registry.register(LookupDeuPut)
registry.register(LookupPutDeu)
registry.register(LookupBidirPut)
registry.register(LookupDeuGri)
registry.register(LookupGriDeu)
registry.register(LookupBidirGri)
开发者ID:cls-nebadje,项目名称:dicziunari-web,代码行数:30,代码来源:lookups.py
示例12: ElementLookup
from __future__ import unicode_literals
from selectable.base import ModelLookup
from selectable.registry import registry
from .models import Element
class ElementLookup(ModelLookup):
model = Element
search_fields = ('text__icontains', )
registry.register(ElementLookup)
开发者ID:douradofefs,项目名称:meu_portal,代码行数:13,代码来源:lookups.py
示例13: MediumLookup
search_fields = ('label__icontains', 'reference__icontains')
class MediumLookup(ModelLookup):
model = ContactMedium
search_fields = ('label__icontains', )
class ActivityLookup(ModelLookup):
model = ActivityNomenclature
search_fields = ('path__icontains', )
filters = {'level': settings.ACTIVITY_NOMENCLATURE_LOOKUP_LEVEL}
try:
registry.register(LocationLookup)
except LookupAlreadyRegistered:
pass
try:
registry.register(AreaLookup)
except LookupAlreadyRegistered:
pass
try:
registry.register(MediumLookup)
except LookupAlreadyRegistered:
pass
try:
registry.register(ActivityLookup)
except LookupAlreadyRegistered:
pass
开发者ID:Web5design,项目名称:coop-mes,代码行数:30,代码来源:admin.py
示例14: RegionLookup
from selectable.base import ModelLookup
from selectable.registry import registry
from cities.models import Region
class RegionLookup(ModelLookup):
model = Region
search_fields = ('name__icontains', )
filters = {'country__code': "CA", }
def get_item_value(self, item):
return item.name
def get_item_id(self, item):
return item.id
if not 'event-regionlookup' in registry._registry:
registry.register(RegionLookup)
开发者ID:dany431,项目名称:cityfusion,代码行数:18,代码来源:lookups.py
示例15: NeighbourhoodLookup
from selectable.base import LookupBase
from selectable.registry import registry
from .models import Neighbourhood, City
class NeighbourhoodLookup(LookupBase):
def get_query(self, request, term):
neighbourhoods = Neighbourhood.objects.all()
cities = City.objects.all()
if term.strip() != '':
neighbourhoods = neighbourhoods.filter(name__icontains=term)
cities = cities.filter(name__icontains=term)
cities = [city for city in cities]
neighbourhoods = [neighbourhood for neighbourhood in neighbourhoods]
locations = cities + neighbourhoods
return locations
registry.register(NeighbourhoodLookup)
开发者ID:Murithi,项目名称:wachuna,代码行数:20,代码来源:lookups.py
示例16: get_item_label
print u'No results'
return results
def get_item_label(self, item):
return unicode(item)
# name_flat = ' '.join(item.givenName)
# surname_flat = ' '.join(item.surname)
# return u'%s %s' % (name_flat, surname_flat)
def get_item_id(self, item):
return item.id
class ValidationReportLookup(LookupBase):
pass
registry.register(PersonLookup)
registry.register(ValidationReportLookup)
from django import forms
class MetadataForm(forms.ModelForm):
class Meta:
model = metadataInfoType_model
widgets = {'metadataCreator' : AutoCompleteSelectMultipleWidget(lookup_class=PersonLookup)}
class MetadataInline(ReverseInlineModelAdmin):
form = MetadataForm
class ResourceForm(forms.ModelForm):
class Meta:
model = resourceInfoType_model
开发者ID:ljo,项目名称:META-SHARE,代码行数:31,代码来源:resource_editor.py
示例17: CityLookup
from selectable.base import ModelLookup
from selectable.registry import registry
from catalog.models import City, County
class CityLookup(ModelLookup):
model = City
search_fields = ('name__icontains', )
class CountyLookup(ModelLookup):
model = County
search_fields = ('name__icontains', )
registry.register(CityLookup)
registry.register(CountyLookup)
开发者ID:cmhayes,项目名称:open-data-nc,代码行数:17,代码来源:lookups.py
示例18: super
term = functools.reduce(
lambda x, y: re.sub(y[0], y[1], x),
self.sub_patterns,
term,
)
term = self.join_pattern.join(term)
return super(FlexModelLookup, self).get_query(request, term)
class DepartmentLookup(ModelLookup):
model = Department
search_fields = ('name__icontains',)
class InstitutionLookup(FlexModelLookup):
model = Institution
search_fields = ('name__iregex',)
sub_patterns = [
['[\s\-,]', ''],
]
join_pattern = '[\s\-,]*'
for lookup in [DepartmentLookup, InstitutionLookup]:
try:
registry.register(lookup)
except LookupAlreadyRegistered:
pass
开发者ID:jmcarp,项目名称:gradpay,代码行数:30,代码来源:lookups.py
示例19: FruitLookup
from django.contrib.auth.models import User
from selectable.base import ModelLookup
from selectable.registry import registry
from example.core.models import Fruit, City
class FruitLookup(ModelLookup):
model = Fruit
search_fields = ('name__icontains', )
registry.register(FruitLookup)
class OwnerLookup(ModelLookup):
model = User
search_fields = ('username__icontains', )
registry.register(OwnerLookup)
class CityLookup(ModelLookup):
model = City
search_fields = ('name__icontains', )
def get_query(self, request, term):
results = super(CityLookup, self).get_query(request, term)
state = request.GET.get('state', '')
if state:
开发者ID:Automatique,项目名称:betafarm,代码行数:31,代码来源:lookups.py
示例20: super
return self.model.objects.none()
return super(EndpointByAssessmentLookup, self).get_query(request, term)
def get_item_label(self, obj):
return u"{} | {} | {} | {}".format(
obj.animal_group.experiment.study,
obj.animal_group.experiment,
obj.animal_group,
obj
)
def get_item_value(self, obj):
return '<a href="{}" target="_blank">{}</a>'.format(
obj.get_absolute_url(),
self.get_item_label(obj)
)
registry.register(SpeciesLookup)
registry.register(StrainLookup)
registry.register(ExperimentCASLookup)
registry.register(AnimalGroupLifestageExposedLookup)
registry.register(AnimalGroupLifestageAssessedLookup)
registry.register(DoseUnitsLookup)
registry.register(EndpointSystemLookup)
registry.register(EndpointOrganLookup)
registry.register(EndpointEffectLookup)
registry.register(EndpointStatisticalTestLookup)
registry.register(EndpointByStudyLookup)
registry.register(EndpointByAssessmentLookup)
开发者ID:ashyhanov,项目名称:hawc,代码行数:30,代码来源:lookups.py
注:本文中的selectable.registry.registry.register函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论