当前位置: 首页>>代码示例>>Python>>正文


Python Path.add_property方法代码示例

本文整理汇总了Python中geotrek.core.models.Path.add_property方法的典型用法代码示例。如果您正苦于以下问题:Python Path.add_property方法的具体用法?Python Path.add_property怎么用?Python Path.add_property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在geotrek.core.models.Path的用法示例。


在下文中一共展示了Path.add_property方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
            settings.LEAFLET_CONFIG['TILES'][0][0],
        ]
        if settings.SHOW_SENSITIVE_AREAS_ON_MAP_SCREENSHOT:
            maplayers.append(ugettext(u"Sensitive area"))
        if settings.SHOW_POIS_ON_MAP_SCREENSHOT:
            maplayers.append(ugettext(u"POIs"))
        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
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:33,代码来源:models.py

示例2: physical_type_csv_display

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
            self.physical_type
        )

    @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']
开发者ID:camillemonchicourt,项目名称:Geotrek,代码行数:32,代码来源:models.py

示例3: physical_type_csv_display

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
    def physical_type_csv_display(self):
        return unicode(self.physical_type)

    @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']
开发者ID:makinabot,项目名称:Geotrek,代码行数:32,代码来源:models.py

示例4: _

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
    class Meta:
        proxy = True
        verbose_name = _(u"Infrastructure")
        verbose_name_plural = _(u"Infrastructures")

    @classmethod
    def path_infrastructures(cls, path):
        return cls.objects.existing().filter(aggregations__path=path).distinct("pk")

    @classmethod
    def topology_infrastructures(cls, topology):
        return cls.overlapping(topology)


Path.add_property("infrastructures", lambda self: Infrastructure.path_infrastructures(self), _(u"Infrastructures"))
Topology.add_property(
    "infrastructures", lambda self: Infrastructure.topology_infrastructures(self), _(u"Infrastructures")
)


class SignageGISManager(gismodels.GeoManager):
    """ Overide default typology mixin manager, and filter by type. """

    def get_queryset(self):
        return super(SignageGISManager, self).get_queryset().filter(type__type=INFRASTRUCTURE_TYPES.SIGNAGE)


class SignageStructureManager(StructureRelatedManager):
    """ Overide default structure related manager, and filter by type. """
开发者ID:Kristof-DM,项目名称:Geotrek,代码行数:31,代码来源:models.py

示例5: geomtransform

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
    @property
    def geomtransform(self):
        geom = self.topo_object.geom
        return geom.transform(settings.API_SRID, clone=True)

    @property
    def lat_value(self):
        return self.geomtransform.x

    @property
    def lng_value(self):
        return self.geomtransform.y


Path.add_property('signages', lambda self: Signage.path_signages(self), _(u"Signages"))
Topology.add_property('signages', lambda self: Signage.topology_signages(self), _(u"Signages"))
Topology.add_property('published_signages', lambda self: Signage.published_topology_signages(self),
                      _(u"Published Signages"))


class Direction(models.Model):
    label = models.CharField(db_column="etiquette", max_length=128)

    class Meta:
        db_table = 's_b_direction'
        verbose_name = _(u"Direction")
        verbose_name_plural = _(u"Directions")

    def __unicode__(self):
        return self.label
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:32,代码来源:models.py

示例6: path_area_edges

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
    @classmethod
    def path_area_edges(cls, path):
        return cls.objects.existing()\
                          .select_related('restricted_area')\
                          .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):
开发者ID:Pitchs,项目名称:Geotrek,代码行数:33,代码来源:models.py

示例7: path_treks

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
    def path_treks(cls, path):
        treks = cls.objects.existing().filter(aggregations__path=path)
        # 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)

开发者ID:camillemonchicourt,项目名称:Geotrek,代码行数:31,代码来源:models.py

示例8: physical_type_csv_display

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
            self.physical_type
        )

    @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']
开发者ID:amandine-sahl,项目名称:Geotrek,代码行数:32,代码来源:models.py

示例9: duration_pretty

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
    def duration_pretty(self):
        return trekking_tags.duration(self.duration)

    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)

开发者ID:Web5design,项目名称:Geotrek,代码行数:31,代码来源:models.py

示例10: unicode

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
        return unicode(self.name)

    def __unicode__(self):
        return u"%s (%s)" % (self.name, self.date)

    @classmethod
    def path_interventions(cls, path):
        return cls.objects.existing().filter(topology__aggregations__path=path)

    @classmethod
    def topology_interventions(cls, topology):
        topos = Topology.overlapping(topology).values_list('pk', flat=True)
        return cls.objects.existing().filter(topology__in=topos).distinct('pk')


Path.add_property('interventions', lambda self: Intervention.path_interventions(self), _(u"Interventions"))
Topology.add_property('interventions', lambda self: Intervention.topology_interventions(self), _(u"Interventions"))


class InterventionStatus(StructureOrNoneRelated):

    status = models.CharField(verbose_name=_(u"Status"), max_length=128, db_column='status')

    class Meta:
        db_table = 'm_b_suivi'
        verbose_name = _(u"Intervention's status")
        verbose_name_plural = _(u"Intervention's statuses")
        ordering = ['id']

    def __unicode__(self):
        if self.structure:
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:33,代码来源:models.py

示例11: InfrastructureStructureManager

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
    in_structure = InfrastructureStructureManager()

    class Meta:
        proxy = True
        verbose_name = _(u"Infrastructure")
        verbose_name_plural = _(u"Infrastructures")

    @classmethod
    def path_infrastructures(cls, path):
        return cls.objects.filter(aggregations__path=path).distinct('pk')

    @classmethod
    def topology_infrastructures(cls, topology):
        return cls.objects.filter(aggregations__path__in=topology.paths.all()).distinct('pk')

Path.add_property('infrastructures', lambda self: Infrastructure.path_infrastructures(self))
Topology.add_property('infrastructures', lambda self: Infrastructure.topology_infrastructures(self))


class SignageGISManager(gismodels.GeoManager):
    """ Overide default typology mixin manager, and filter by type. """
    def get_query_set(self):
        return super(SignageGISManager, self).get_query_set().filter(type__type=INFRASTRUCTURE_TYPES.SIGNAGE)


class SignageStructureManager(StructureRelatedManager):
    """ Overide default structure related manager, and filter by type. """
    def get_query_set(self):
        return super(SignageStructureManager, self).get_query_set().filter(type__type=INFRASTRUCTURE_TYPES.SIGNAGE)

开发者ID:makinabot,项目名称:Geotrek,代码行数:31,代码来源:models.py

示例12: is_publishable

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
    def is_publishable(self):
        return self.is_complete() and self.has_geom_valid()

    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.objects.existing().filter(aggregations__path__in=topology.paths.all()).distinct('pk')

Path.add_property('treks', lambda self: Trek.path_treks(self))
Topology.add_property('treks', lambda self: Trek.topology_treks(self))
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)

开发者ID:makinabot,项目名称:Geotrek,代码行数:30,代码来源:models.py

示例13: Infrastructure

# 需要导入模块: from geotrek.core.models import Path [as 别名]
# 或者: from geotrek.core.models.Path import add_property [as 别名]
        return all_years


class Infrastructure(MapEntityMixin, BaseInfrastructure):
    """ An infrastructure in the park, which is not of type SIGNAGE """
    type = models.ForeignKey(InfrastructureType, db_column='type', verbose_name=_("Type"))
    objects = BaseInfrastructure.get_manager_cls(InfrastructureGISManager)()

    class Meta:
        db_table = 'a_t_infrastructure'
        verbose_name = _(u"Infrastructure")
        verbose_name_plural = _(u"Infrastructures")

    @classmethod
    def path_infrastructures(cls, path):
        return cls.objects.existing().filter(aggregations__path=path).distinct('pk')

    @classmethod
    def topology_infrastructures(cls, topology):
        return cls.overlapping(topology)

    @classmethod
    def published_topology_infrastructure(cls, topology):
        return cls.topology_infrastructures(topology).filter(published=True)


Path.add_property('infrastructures', lambda self: Infrastructure.path_infrastructures(self), _(u"Infrastructures"))
Topology.add_property('infrastructures', lambda self: Infrastructure.topology_infrastructures(self), _(u"Infrastructures"))
Topology.add_property('published_infrastructures', Infrastructure.published_topology_infrastructure,
                      _(u"Published Infrastructures"))
开发者ID:makinacorpus,项目名称:Geotrek,代码行数:32,代码来源:models.py


注:本文中的geotrek.core.models.Path.add_property方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。