Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Feature/refactor location models #304

Merged
merged 9 commits into from
Oct 5, 2017
Merged

Conversation

jmurty
Copy link
Contributor

@jmurty jmurty commented Oct 5, 2017

No description provided.

Split large `icekit.plugins.location.models.Location`
model into more focussed and re-usable component
abstract and mixin models:

- `GoogleMapMixin` for capturing map-able location
  data and rendering a Google Map of the location
- `AbstractLocation` for basic location data,
  no support for Google Map presentation
- `AbstractLocationWithGoogleMap` to combine
  basic location data with a Google Map
  presentation

This leaves the original `Location` model largely
unchanged, it is just an implementation of
`AbstractLocationWithGoogleMap` that has Fluent
content and other GLAMkit features (publishable,
workflows, etc)

Admin classes are also restructured following the
models.
Limit how many radically different ways you can
define a Google Map item.

If we need to display an arbitrary HTML embed
item we already have content items to do that,
let's not accept this junk in the GoogleMapMixin.
GoogleMapMixin is now more generic and may be
reused outside just `Location` items, so the
JS code should reflect that.
The `GoogleMapMixin` and thus the `Location` plugin
model now accept explicit latitude/longitude values
for map center and marker locations, instead of
accepting lat/longs as part of description strings.
Set the optional `GOOGLE_MAP_PERMISSIVE_CENTER`
setting to `False` to require admins to enter
explicit latitude/longitude values for the center
point of Google Map items like `Location` in the
admin.

If this setting is `True` or missing, the
`map_center_description` field can be used alone
to set the center point of the map (and the data
model will not have guaranteed lat/long values)
Add manager methods to `GoogleMapMixin` and
`Location` to calculate the distance between the
model instances' location as given in lat/long
values and another given location.

- `annotate_distance_in_km()` takes lat/long
  values and returns results decorated with the
  `distance_in_km` annotation field
- `nearby` takes lat/long values and a
  `proximity_in_km` limit and returns results
  within a certain distance of the other location.
The advanced event listing page now accepts the
'is-nearby' GET parameter with comma-delimted
latitude/longitude/distance values and will
restrict event results to those with locations
within the given distance of the visitor's (or
given) location.

The default template for this page prompts the
visitor to permit location lookup to populate
the lat/longs, or they can be set manually.
@jmurty jmurty merged commit f9221f7 into develop Oct 5, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 73.785% when pulling e60b87b on feature/refactor-location-models into 4e64298 on develop.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants