Пример #1
0
    def signages(self):
        if self.target_type == ContentType.objects.get_for_model(Signage):
            return [self.target]
        return []

    @property
    def infrastructures(self):
        if self.target_type == ContentType.objects.get_for_model(Infrastructure):
            return [self.target]
        return []


Path.add_property('interventions', lambda self: Intervention.path_interventions(self), _("Interventions"))
Topology.add_property('interventions', lambda self: Intervention.topology_interventions(self), _("Interventions"))
if 'geotrek.signage' in settings.INSTALLED_APPS:
    Blade.add_property('interventions', lambda self: Intervention.blade_interventions(self), _("Interventions"))


class InterventionStatus(StructureOrNoneRelated):

    status = models.CharField(verbose_name=_("Status"), max_length=128)
    order = models.PositiveSmallIntegerField(default=None, null=True, blank=True, verbose_name=_("Display order"))

    class Meta:
        verbose_name = _("Intervention's status")
        verbose_name_plural = _("Intervention's statuses")
        ordering = ['order', 'status']

    def __str__(self):
        if self.structure:
            return "{} ({})".format(self.status, self.structure.name)
Пример #2
0
        return cls.overlapping(topology).select_related('physical_type')


Path.add_property('physical_edges', PhysicalEdge.path_physicals,
                  _("Physical edges"))
Topology.add_property('physical_edges', PhysicalEdge.topology_physicals,
                      _("Physical edges"))
Intervention.add_property(
    'physical_edges', lambda self: self.target.physical_edges
    if self.target else [], _("Physical edges"))
Project.add_property('physical_edges',
                     lambda self: self.edges_by_attr('physical_edges'),
                     _("Physical edges"))
if 'geotrek.signage' in settings.INSTALLED_APPS:
    Blade.add_property('physical_edges',
                       lambda self: self.signage.physical_edges,
                       _("Physical edges"))


class LandType(StructureOrNoneRelated):
    name = models.CharField(max_length=128, verbose_name=_("Name"))
    right_of_way = models.BooleanField(default=False,
                                       verbose_name=_("Right of way"))

    class Meta:
        verbose_name = _("Land type")
        verbose_name_plural = _("Land types")
        ordering = ['name']

    def __str__(self):
        if self.structure:
Пример #3
0
    'areas', lambda self: intersecting(RestrictedArea, self, distance=0),
    _("Restricted areas"))
TouristicEvent.add_property(
    'areas', lambda self: intersecting(RestrictedArea, self, distance=0),
    _("Restricted areas"))
if 'geotrek.diving' in settings.INSTALLED_APPS:
    Dive.add_property(
        'areas',
        lambda self: uniquify(intersecting(RestrictedArea, self, distance=0)),
        _("Restricted areas"))
    Dive.add_property(
        'published_areas',
        lambda self: [area for area in self.areas if area.published],
        _("Published areas"))
if 'geotrek.signage' in settings.INSTALLED_APPS:
    Blade.add_property('areas', lambda self: self.signage.areas,
                       _("Restricted areas"))
    Blade.add_property(
        'published_areas',
        lambda self: [area for area in self.areas if area.published],
        _("Published areas"))

Topology.add_property(
    'published_areas',
    lambda self: [area for area in self.areas if area.published],
    _("Published areas"))
Project.add_property(
    'published_areas',
    lambda self: [area for area in self.areas if area.published],
    _("Published areas"))
Intervention.add_property(
    'published_areas',
Пример #4
0

Path.add_property('treks', Trek.path_treks, _("Treks"))
Topology.add_property('treks', Trek.topology_treks, _("Treks"))
if settings.HIDE_PUBLISHED_TREKS_IN_TOPOLOGIES:
    Topology.add_property('published_treks', lambda self: [], _("Published treks"))
else:
    Topology.add_property('published_treks', lambda self: intersecting(Trek, self).filter(published=True), _("Published treks"))
Intervention.add_property('treks', lambda self: self.target.treks if self.target else [], _("Treks"))
Project.add_property('treks', lambda self: self.edges_by_attr('treks'), _("Treks"))
tourism_models.TouristicContent.add_property('treks', lambda self: intersecting(Trek, self), _("Treks"))
tourism_models.TouristicContent.add_property('published_treks', lambda self: intersecting(Trek, self).filter(published=True), _("Published treks"))
tourism_models.TouristicEvent.add_property('treks', lambda self: intersecting(Trek, self), _("Treks"))
tourism_models.TouristicEvent.add_property('published_treks', lambda self: intersecting(Trek, self).filter(published=True), _("Published treks"))
if 'geotrek.signage' in settings.INSTALLED_APPS:
    Blade.add_property('treks', lambda self: self.signage.treks, _("Treks"))
    Blade.add_property('published_treks', lambda self: self.signage.published_treks, _("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)


class TrekRelationship(models.Model):
    """