Exemplo n.º 1
0
class BlogAbout(Page):
    subpage_types = []
    max_count = 1
    address = models.CharField(max_length=250, blank=True, null=True)
    location = models.CharField(max_length=250, blank=True, null=True)

    content = StreamField([
        ("title_and_text", blocks.TitleAndTextBlock()),
        ("Full_richtext", blocks.RichtextBlock()),
        ("card_block", blocks.CardBlock()),
    ],
                          null=True,
                          blank=True)
    subtitle = models.CharField(max_length=250, blank=True, null=True)
    content_panels = Page.content_panels + [
        FieldPanel('subtitle'),
        StreamFieldPanel("content"),
        MultiFieldPanel([
            FieldPanel('address'),
            GeoPanel('location', address_field='address'),
        ], _('Geo details')),
    ]

    @cached_property
    def point(self):
        return geosgeometry_str_to_struct(self.location)

    @property
    def lat(self):
        return self.point['y']

    @property
    def lng(self):
        return self.point['x']
Exemplo n.º 2
0
class ClassicGeoPage(Page):
    address = models.CharField(max_length=250, blank=True, null=True)
    location = models.CharField(max_length=250, blank=True, null=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('address'),
            GeoPanel('location', address_field='address', hide_latlng=True),
        ], _('Geo details')),
    ]

    def get_context(self, request):
        data = super(ClassicGeoPage, self).get_context(request)
        return data

    @cached_property
    def point(self):
        from wagtailgeowidget.helpers import geosgeometry_str_to_struct
        return geosgeometry_str_to_struct(self.location)

    @property
    def lat(self):
        return self.point['y']

    @property
    def lng(self):
        return self.point['x']
Exemplo n.º 3
0
class Location(Page):
    """
    Geocoded location details.
    """

    region = models.ForeignKey(Region,
                               related_name="locations",
                               null=True,
                               on_delete=models.SET_NULL)
    formatted_address = models.CharField("Full Address",
                                         max_length=255,
                                         blank=True,
                                         null=True)
    lat_lng = models.CharField("Latitude/Longitude",
                               max_length=255,
                               blank=True,
                               null=True)

    @cached_property
    def point(self):
        return geosgeometry_str_to_struct(self.lat_lng)

    @property
    def lat(self):
        return self.point["y"]

    @property
    def lng(self):
        return self.point["x"]

    content_panels = Page.content_panels + [
        FieldPanel("region"),
        MultiFieldPanel(
            [
                FieldPanel("formatted_address"),
                GeoPanel("lat_lng", address_field="formatted_address"),
            ],
            "Geocoded Address",
        ),
    ]

    search_fields = Page.search_fields + [
        SearchField("region", partial_match=True),
        SearchField("formatted_address", partial_match=True),
    ]

    subpage_types = ["Meeting"]

    class Meta:
        indexes = [
            models.Index(fields=["region"]),
            models.Index(fields=["formatted_address"]),
        ]

    def __str__(self):
        return "{0}: {1}".format(self.region, self.title)
Exemplo n.º 4
0
class GeoLocation(models.Model):
    title = models.CharField(max_length=255)
    address = models.CharField(max_length=250, blank=True, null=True)
    location = models.PointField(srid=4326, null=True, blank=True)

    panels = [
        FieldPanel('title'),
        FieldPanel('address'),
        GeoPanel('location', address_field='address')
    ]
Exemplo n.º 5
0
class AboutPageOffice(Orderable):
    page = ParentalKey('about.AboutPage', related_name='offices')
    title = models.TextField(_('Title'))
    svg = models.TextField(_('SVG icon'), null=True)
    address = models.CharField(_('Address'),
                               help_text=_("Location's address"),
                               max_length=250)
    map = models.CharField(_('Map'), null=True, max_length=250)

    panels = [
        FieldPanel('title'),
        MultiFieldPanel([
            FieldPanel('address'),
            GeoPanel('map', address_field='address'),
        ], _('Location details')),
        FieldPanel('svg')
    ]
Exemplo n.º 6
0
class Step(Page):
    short_description = models.CharField(
        max_length=75, help_text="A short preview of what the page is about")
    page_body = RichTextField(blank=True)
    checklist_instructions = RichTextField(
        blank=True,
        help_text=
        "Specific instructions provided when a user prints the page. Keep it short!"
    )

    address = models.CharField(max_length=250, blank=True, null=True)
    location = models.CharField(max_length=250, blank=True, null=True)

    contact = models.ForeignKey('roadmap.Contact',
                                null=True,
                                blank=True,
                                on_delete=models.SET_NULL,
                                related_name='+')

    content_panels = Page.content_panels + [
        FieldPanel('short_description', classname='full'),
        FieldPanel('page_body', classname='full'),
        FieldPanel('checklist_instructions', classname='full'),
        SnippetChooserPanel('contact'),
        MultiFieldPanel([
            FieldPanel('address'),
            GeoPanel('location', address_field='address'),
        ], _('Location of the step')),
    ]

    template = 'roadmap/step/base.html'

    @cached_property
    def point(self):
        return geosgeometry_str_to_struct(self.location)

    @property
    def lat(self):
        return self.point['y']

    @property
    def lng(self):
        return self.point['x']
Exemplo n.º 7
0
class GeoPage(Page):
    address = models.CharField(max_length=250, blank=True, null=True)
    location = models.PointField(srid=4326, null=True, blank=True)

    content_panels = Page.content_panels + [
        InlinePanel('related_locations', label="Related locations"),
    ]

    location_panels = [
        MultiFieldPanel([
            FieldPanel('address'),
            GeoPanel('location', address_field='address'),
        ],
                        heading='Location')
    ]

    edit_handler = TabbedInterface([
        ObjectList(content_panels, heading='Content'),
        ObjectList(location_panels, heading='Location'),
        ObjectList(Page.settings_panels,
                   heading='Settings',
                   classname="settings"),
    ])
Exemplo n.º 8
0
class ClassicGeoPage(Page):
    address = models.CharField(max_length=250, blank=True, null=True)
    location = models.CharField(max_length=250, blank=True, null=True)

    content_panels = Page.content_panels + [
        GeoPanel('location', address_field='address'),
    ]

    def get_context(self, request):
        data = super(ClassicGeoPage, self).get_context(request)
        return data

    @property
    def point(self):
        return GEOSGeometry(self.location)

    @property
    def lat(self):
        return self.point.y

    @property
    def lng(self):
        return self.point.x
Exemplo n.º 9
0
class Location(Page):
    """
    Geocoded location details.
    """

    region = models.ForeignKey(
        Region,
        related_name="locations",
        on_delete=models.PROTECT,
        limit_choices_to={"parent__isnull": False},
    )
    formatted_address = models.CharField("Full Address",
                                         max_length=255,
                                         blank=True,
                                         null=True)
    lat_lng = models.CharField("Latitude/Longitude",
                               max_length=255,
                               blank=True,
                               null=True)
    postal_code = models.CharField("Postal Code", max_length=12, blank=True)
    details = models.TextField(
        null=True,
        blank=True,
        help_text=
        "Details specific to the location, not the meeting. For example, "
        "'Located in shopping center behind the bank.'",
    )

    @cached_property
    def point(self):
        return geosgeometry_str_to_struct(self.lat_lng)

    @property
    def lat(self):
        return self.point["y"]

    @property
    def lng(self):
        return self.point["x"]

    content_panels = Page.content_panels + [
        FieldPanel("region"),
        FieldPanel("postal_code"),
        FieldPanel("details"),
        MultiFieldPanel(
            [
                FieldPanel("formatted_address"),
                GeoPanel("lat_lng", address_field="formatted_address"),
            ],
            "Geocoded Address",
        ),
    ]

    search_fields = Page.search_fields + [
        SearchField("region", partial_match=True),
        SearchField("formatted_address", partial_match=True),
    ]

    subpage_types = ["Meeting"]

    class Meta:
        indexes = [
            models.Index(fields=["region"]),
            models.Index(fields=["formatted_address"]),
        ]

    def __str__(self):
        return "{0}: {1}".format(self.region, self.title)
Exemplo n.º 10
0
        summary_dict['archaeology'] = archaeology_count

        return summary_dict

    @property
    def project_index(self):
        """
        Return the containing Projects Index Page
        :return: ProjectsIndexPage
        """
        # Find closest ancestor which is a project index
        return self.get_ancestors().type(ProjectsIndexPage).last()


ProjectPage.content_panels = [
    FieldPanel('title', classname="full title"),
    FieldPanel('date'),
    FieldPanel('intro', classname="full"),
    StreamFieldPanel('body'),
    InlinePanel('carousel_items', label="Carousel items"),
    InlinePanel('related_links', label="Related links"),
    GeoPanel('location')
]

ProjectPage.promote_panels = Page.promote_panels + [
    FieldPanel('app_label'),
    FieldPanel('is_public'),
    ImageChooserPanel('feed_image'),
    FieldPanel('tags'),
]