當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Intervention類代碼示例

本文整理匯總了Python中geotrek.maintenance.models.Intervention的典型用法代碼示例。如果您正苦於以下問題:Python Intervention類的具體用法?Python Intervention怎麽用?Python Intervention使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Intervention類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_creation_form_on_infrastructure

    def test_creation_form_on_infrastructure(self):
        self.login()

        infra = InfrastructureFactory.create()
        infrastr = u"%s" % infra

        response = self.client.get(Intervention.get_add_url() + '?infrastructure=%s' % infra.pk)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, infrastr)
        form = response.context['form']
        self.assertEqual(form.initial['infrastructure'], infra)
        # Should be able to save form successfully
        data = self.get_good_data()
        data['infrastructure'] = infra.pk
        response = self.client.post(Intervention.get_add_url() + '?infrastructure=%s' % infra.pk, data)
        self.assertEqual(response.status_code, 302)
開發者ID:leplatrem,項目名稱:Geotrek,代碼行數:16,代碼來源:tests.py

示例2: test_creation_form_on_signage

    def test_creation_form_on_signage(self):
        self.login()

        signa = SignageFactory.create()
        signage = u"%s" % signa

        response = self.client.get(Intervention.get_add_url() + '?signage=%s' % signa.pk)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, signage)
        form = response.context['form']
        self.assertEqual(form.initial['signage'], signa)
        # Should be able to save form successfully
        data = self.get_good_data()
        data['signage'] = signa.pk
        response = self.client.post(Intervention.get_add_url() + '?signage=%s' % signa.pk, data)
        self.assertEqual(response.status_code, 302)
開發者ID:makinacorpus,項目名稱:Geotrek,代碼行數:16,代碼來源:test_views.py

示例3: test_structurerelated_not_loggedin

    def test_structurerelated_not_loggedin(self):
        # Test that it does not fail on update if not logged in
        self.client.logout()
        response = self.client.get(Intervention.get_add_url())
        self.assertEqual(response.status_code, 302)

        i = InterventionFactory.create()
        response = self.client.get(i.get_update_url())
        self.assertEqual(response.status_code, 302)
開發者ID:leplatrem,項目名稱:Geotrek,代碼行數:9,代碼來源:tests.py

示例4: test_creation_form_on_signage_with_errors

    def test_creation_form_on_signage_with_errors(self):
        self.login()

        signa = SignageFactory.create()
        signage = u"%s" % signa

        response = self.client.get(Intervention.get_add_url() + '?signage=%s' % signa.pk)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, signage)
        form = response.context['form']
        self.assertEqual(form.initial['signage'], signa)
        data = self.get_good_data()
        data['signage'] = signa.pk

        # If form invalid, it should not fail
        data.pop('status')
        response = self.client.post(Intervention.get_add_url() + '?signage=%s' % signa.pk, data)
        self.assertEqual(response.status_code, 200)
開發者ID:makinacorpus,項目名稱:Geotrek,代碼行數:18,代碼來源:test_views.py

示例5: test_creation_form_on_infrastructure_with_errors

    def test_creation_form_on_infrastructure_with_errors(self):
        self.login()

        infra = InfrastructureFactory.create()
        infrastr = u"%s" % infra

        response = self.client.get(Intervention.get_add_url() + '?infrastructure=%s' % infra.pk)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, infrastr)
        form = response.context['form']
        self.assertEqual(form.initial['infrastructure'], infra)
        data = self.get_good_data()
        data['infrastructure'] = infra.pk

        # If form invalid, it should not fail
        data.pop('status')
        response = self.client.post(Intervention.get_add_url() + '?infrastructure=%s' % infra.pk, data)
        self.assertEqual(response.status_code, 200)
開發者ID:makinacorpus,項目名稱:Geotrek,代碼行數:18,代碼來源:test_views.py

示例6: test_form_default_stake

 def test_form_default_stake(self):
     self.login()
     good_data = self.get_good_data()
     good_data['stake'] = ''
     good_data['topology'] = """
     {"offset":0,"positions":{"0":[0.8298653170816073,1],"2":[0,0.04593024777973237]},"paths":[%s,%s,%s]}
     """ % (PathFactory.create().pk, PathFactory.create().pk, PathFactory.create().pk)
     response = self.client.post(Intervention.get_add_url(), good_data)
     self.assertEqual(response.status_code, 302)
     response = self.client.get(response._headers['location'][1])
     self.assertTrue('object' in response.context)
     intervention = response.context['object']
     self.assertFalse(intervention.stake is None)
開發者ID:leplatrem,項目名稱:Geotrek,代碼行數:13,代碼來源:tests.py

示例7: test_form_on_infrastructure

    def test_form_on_infrastructure(self):
        self.login()

        infra = InfrastructureFactory.create()
        infrastr = u"%s" % infra
        # For creation
        response = self.client.get(Intervention.get_add_url() + '?infrastructure=%s' % infra.pk)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, infrastr)
        # For edition
        intervention = InterventionFactory.create()
        intervention.set_infrastructure(infra)
        response = self.client.get(infra.get_update_url())
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, infrastr)
開發者ID:makinabot,項目名稱:Geotrek,代碼行數:15,代碼來源:tests.py

示例8: physical_type_csv_display

    @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
開發者ID:camillemonchicourt,項目名稱:Geotrek,代碼行數:30,代碼來源:models.py

示例9: _

        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)
開發者ID:makinacorpus,項目名稱:Geotrek,代碼行數:31,代碼來源:models.py

示例10: display

    @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
開發者ID:makinabot,項目名稱:Geotrek,代碼行數:30,代碼來源:models.py

示例11: topology_area_edges

                          .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)
開發者ID:Pitchs,項目名稱:Geotrek,代碼行數:30,代碼來源:models.py

示例12: test_disorders_not_mandatory

 def test_disorders_not_mandatory(self):
     self.login()
     data = self.get_good_data()
     data.pop('disorders')
     response = self.client.post(Intervention.get_add_url(), data)
     self.assertEqual(response.status_code, 302)
開發者ID:makinacorpus,項目名稱:Geotrek,代碼行數:6,代碼來源:test_views.py

示例13: physical_type_csv_display

    @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
開發者ID:amandine-sahl,項目名稱:Geotrek,代碼行數:30,代碼來源:models.py

示例14: topology_treks

        # 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):
    """
開發者ID:camillemonchicourt,項目名稱:Geotrek,代碼行數:31,代碼來源:models.py

示例15: __unicode__

    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):
    """
開發者ID:Web5design,項目名稱:Geotrek,代碼行數:30,代碼來源:models.py


注:本文中的geotrek.maintenance.models.Intervention類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。