本文整理匯總了Python中geotrek.maintenance.models.Intervention.add_property方法的典型用法代碼示例。如果您正苦於以下問題:Python Intervention.add_property方法的具體用法?Python Intervention.add_property怎麽用?Python Intervention.add_property使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類geotrek.maintenance.models.Intervention
的用法示例。
在下文中一共展示了Intervention.add_property方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: physical_type_csv_display
# 需要導入模塊: from geotrek.maintenance.models import Intervention [as 別名]
# 或者: from geotrek.maintenance.models.Intervention import add_property [as 別名]
@property
def physical_type_csv_display(self):
return unicode(self.physical_type)
@classmethod
def path_physicals(cls, path):
return cls.objects.select_related('physical_type').filter(aggregations__path=path).distinct('pk')
@classmethod
def topology_physicals(cls, topology):
return cls.overlapping(topology).select_related('physical_type')
Path.add_property('physical_edges', PhysicalEdge.path_physicals)
Topology.add_property('physical_edges', PhysicalEdge.topology_physicals)
Intervention.add_property('physical_edges', lambda self: self.topology.physical_edges if self.topology else [])
Project.add_property('physical_edges', lambda self: self.edges_by_attr('physical_edges'))
class LandType(StructureRelated):
name = models.CharField(max_length=128, db_column='foncier', verbose_name=_(u"Name"))
right_of_way = models.BooleanField(db_column='droit_de_passage', verbose_name=_(u"Right of way"))
class Meta:
db_table = 'f_b_foncier'
verbose_name = _(u"Land type")
verbose_name_plural = _(u"Land types")
ordering = ['name']
def __unicode__(self):
return self.name
示例2: display
# 需要導入模塊: from geotrek.maintenance.models import Intervention [as 別名]
# 或者: from geotrek.maintenance.models.Intervention import add_property [as 別名]
@property
def display(self):
return u'<a data-pk="%s" href="%s" >%s</a>' % (self.pk, self.get_detail_url(), self.physical_type)
@classmethod
def path_physicals(cls, path):
return cls.objects.select_related('physical_type').filter(aggregations__path=path).distinct('pk')
@classmethod
def topology_physicals(cls, topology):
return cls.objects.select_related('physical_type').filter(aggregations__path__in=topology.paths.all()).distinct('pk')
Path.add_property('physical_edges', PhysicalEdge.path_physicals)
Topology.add_property('physical_edges', PhysicalEdge.topology_physicals)
Intervention.add_property('physical_edges', lambda self: self.topology.physical_edges if self.topology else [])
Project.add_property('physical_edges', lambda self: self.edges_by_attr('physical_edges'))
class LandType(StructureRelated):
name = models.CharField(max_length=128, db_column='foncier', verbose_name=_(u"Name"))
right_of_way = models.BooleanField(db_column='droit_de_passage', verbose_name=_(u"Right of way"))
class Meta:
db_table = 'f_b_foncier'
verbose_name = _(u"Land type")
verbose_name_plural = _(u"Land types")
ordering = ['name']
def __unicode__(self):
return self.name
示例3: _
# 需要導入模塊: from geotrek.maintenance.models import Intervention [as 別名]
# 或者: from geotrek.maintenance.models.Intervention import add_property [as 別名]
if settings.SHOW_SERVICES_ON_MAP_SCREENSHOT:
maplayers.append(ugettext(u"Services"))
if settings.SHOW_SIGNAGES_ON_MAP_SCREENSHOT:
maplayers.append(ugettext(u"Signages"))
if settings.SHOW_INFRASTRUCTURES_ON_MAP_SCREENSHOT:
maplayers.append(ugettext(u"Infrastructures"))
return {"maplayers": maplayers}
Path.add_property('treks', Trek.path_treks, _(u"Treks"))
Topology.add_property('treks', Trek.topology_treks, _(u"Treks"))
if settings.HIDE_PUBLISHED_TREKS_IN_TOPOLOGIES:
Topology.add_property('published_treks', lambda self: [], _(u"Published treks"))
else:
Topology.add_property('published_treks', lambda self: intersecting(Trek, self).filter(published=True), _(u"Published treks"))
Intervention.add_property('treks', lambda self: self.topology.treks if self.topology else [], _(u"Treks"))
Project.add_property('treks', lambda self: self.edges_by_attr('treks'), _(u"Treks"))
tourism_models.TouristicContent.add_property('treks', lambda self: intersecting(Trek, self), _(u"Treks"))
tourism_models.TouristicContent.add_property('published_treks', lambda self: intersecting(Trek, self).filter(published=True), _(u"Published treks"))
tourism_models.TouristicEvent.add_property('treks', lambda self: intersecting(Trek, self), _(u"Treks"))
tourism_models.TouristicEvent.add_property('published_treks', lambda self: intersecting(Trek, self).filter(published=True), _(u"Published treks"))
class TrekRelationshipManager(models.Manager):
use_for_related_fields = True
def get_queryset(self):
# Select treks foreign keys by default
qs = super(TrekRelationshipManager, self).get_queryset().select_related('trek_a', 'trek_b')
# Exclude deleted treks
return qs.exclude(trek_a__deleted=True).exclude(trek_b__deleted=True)
示例4: topology_area_edges
# 需要導入模塊: from geotrek.maintenance.models import Intervention [as 別名]
# 或者: from geotrek.maintenance.models.Intervention import add_property [as 別名]
.select_related('restricted_area__area_type')\
.filter(aggregations__path=path).distinct('pk')
@classmethod
def topology_area_edges(cls, topology):
return cls.overlapping(topology)\
.select_related('restricted_area')\
.select_related('restricted_area__area_type')
if settings.TREKKING_TOPOLOGY_ENABLED:
Path.add_property('area_edges', RestrictedAreaEdge.path_area_edges)
Path.add_property('areas', lambda self: uniquify(map(attrgetter('restricted_area'), self.area_edges)))
Topology.add_property('area_edges', RestrictedAreaEdge.topology_area_edges)
Topology.add_property('areas', lambda self: uniquify(map(attrgetter('restricted_area'), self.area_edges)))
Intervention.add_property('area_edges', lambda self: self.topology.area_edges if self.topology else [])
Intervention.add_property('areas', lambda self: self.topology.areas if self.topology else [])
Project.add_property('area_edges', lambda self: self.edges_by_attr('area_edges'))
Project.add_property('areas', lambda self: uniquify(map(attrgetter('restricted_area'), self.area_edges)))
else:
Topology.add_property('areas', lambda self: intersecting(RestrictedArea, self))
TouristicContent.add_property('areas', lambda self: intersecting(RestrictedArea, self))
TouristicEvent.add_property('areas', lambda self: intersecting(RestrictedArea, self))
class City(models.Model):
code = models.CharField(primary_key=True, max_length=6, db_column='insee')
name = models.CharField(max_length=128, db_column='commune', verbose_name=_(u"Name"))
geom = models.MultiPolygonField(srid=settings.SRID, spatial_index=False)
示例5: physical_type_csv_display
# 需要導入模塊: from geotrek.maintenance.models import Intervention [as 別名]
# 或者: from geotrek.maintenance.models.Intervention import add_property [as 別名]
@property
def physical_type_csv_display(self):
return unicode(self.physical_type)
@classmethod
def path_physicals(cls, path):
return cls.objects.existing().select_related('physical_type').filter(aggregations__path=path).distinct('pk')
@classmethod
def topology_physicals(cls, topology):
return cls.overlapping(topology).select_related('physical_type')
Path.add_property('physical_edges', PhysicalEdge.path_physicals, _(u"Physical edges"))
Topology.add_property('physical_edges', PhysicalEdge.topology_physicals, _(u"Physical edges"))
Intervention.add_property('physical_edges', lambda self: self.topology.physical_edges if self.topology else [], _(u"Physical edges"))
Project.add_property('physical_edges', lambda self: self.edges_by_attr('physical_edges'), _(u"Physical edges"))
class LandType(StructureRelated):
name = models.CharField(max_length=128, db_column='foncier', verbose_name=_(u"Name"))
right_of_way = models.BooleanField(db_column='droit_de_passage', verbose_name=_(u"Right of way"))
class Meta:
db_table = 'f_b_foncier'
verbose_name = _(u"Land type")
verbose_name_plural = _(u"Land types")
ordering = ['name']
def __unicode__(self):
return self.name
示例6: topology_treks
# 需要導入模塊: from geotrek.maintenance.models import Intervention [as 別名]
# 或者: from geotrek.maintenance.models.Intervention import add_property [as 別名]
# The following part prevents conflict with default trek ordering
# ProgrammingError: SELECT DISTINCT ON expressions must match initial ORDER BY expressions
return treks.order_by('topo_object').distinct('topo_object')
@classmethod
def topology_treks(cls, topology):
if settings.TREKKING_TOPOLOGY_ENABLED:
qs = cls.overlapping(topology)
else:
area = topology.geom.buffer(settings.TREK_POI_INTERSECTION_MARGIN)
qs = cls.objects.filter(geom__intersects=area)
return qs
Path.add_property('treks', Trek.path_treks)
Topology.add_property('treks', Trek.topology_treks)
Intervention.add_property('treks', lambda self: self.topology.treks if self.topology else [])
Project.add_property('treks', lambda self: self.edges_by_attr('treks'))
class TrekRelationshipManager(models.Manager):
use_for_related_fields = True
def get_queryset(self):
# Select treks foreign keys by default
qs = super(TrekRelationshipManager, self).get_queryset().select_related('trek_a', 'trek_b')
# Exclude deleted treks
return qs.exclude(trek_a__deleted=True).exclude(trek_b__deleted=True)
class TrekRelationship(models.Model):
"""
示例7: __unicode__
# 需要導入模塊: from geotrek.maintenance.models import Intervention [as 別名]
# 或者: from geotrek.maintenance.models.Intervention import add_property [as 別名]
def __unicode__(self):
return u"%s (%s - %s)" % (self.name, self.departure, self.arrival)
@classmethod
def path_treks(cls, path):
return cls.objects.existing().filter(aggregations__path=path).distinct("pk")
@classmethod
def topology_treks(cls, topology):
return cls.overlapping(topology)
Path.add_property("treks", Trek.path_treks)
Topology.add_property("treks", Trek.topology_treks)
Intervention.add_property("treks", lambda self: self.topology.treks if self.topology else [])
Project.add_property("treks", lambda self: self.edges_by_attr("treks"))
class TrekRelationshipManager(models.Manager):
use_for_related_fields = True
def get_query_set(self):
# Select treks foreign keys by default
qs = super(TrekRelationshipManager, self).get_query_set().select_related("trek_a", "trek_b")
# Exclude deleted treks
return qs.exclude(trek_a__deleted=True).exclude(trek_b__deleted=True)
class TrekRelationship(models.Model):
"""
示例8: topology_area_edges
# 需要導入模塊: from geotrek.maintenance.models import Intervention [as 別名]
# 或者: from geotrek.maintenance.models.Intervention import add_property [as 別名]
@classmethod
def topology_area_edges(cls, topology):
return cls.overlapping(topology)\
.select_related('restricted_area')\
.select_related('restricted_area__area_type')
if settings.TREKKING_TOPOLOGY_ENABLED:
Path.add_property('area_edges', RestrictedAreaEdge.path_area_edges, _(u"Restricted area edges"))
Path.add_property('areas', lambda self: uniquify(map(attrgetter('restricted_area'), self.area_edges)),
_(u"Restricted areas"))
Topology.add_property('area_edges', RestrictedAreaEdge.topology_area_edges, _(u"Restricted area edges"))
Topology.add_property('areas', lambda self: uniquify(
intersecting(RestrictedArea, self)) if self.ispoint() else uniquify(
map(attrgetter('restricted_area'), self.area_edges)), _(u"Restricted areas"))
Intervention.add_property('area_edges', lambda self: self.topology.area_edges if self.topology else [],
_(u"Restricted area edges"))
Intervention.add_property('areas', lambda self: self.topology.areas if self.topology else [],
_(u"Restricted areas"))
Project.add_property('area_edges', lambda self: self.edges_by_attr('area_edges'), _(u"Restricted area edges"))
Project.add_property('areas', lambda self: uniquify(map(attrgetter('restricted_area'), self.area_edges)),
_(u"Restricted areas"))
else:
Topology.add_property('areas', lambda self: uniquify(intersecting(RestrictedArea, self, distance=0)),
_(u"Restricted areas"))
TouristicContent.add_property('areas', lambda self: intersecting(RestrictedArea, self, distance=0),
_(u"Restricted areas"))
TouristicEvent.add_property('areas', lambda self: intersecting(RestrictedArea, self, distance=0),
_(u"Restricted areas"))