Skip to content

Commit

Permalink
Implemented router to handle single page view calls. Added coordinate…
Browse files Browse the repository at this point in the history
…s to url to allow user to store specific map locations. (#1403)

---
Router_mixin includes all functions that update the state of the current page.

Forms submitted in project detail are intercepted and handled through ajax to prevent redirects.

Custom headers raise form errors, which are then handled in router_mixins formSubmission

Custom headers raise permission errors, and redirects for anonymous and non-permissioned users and handled in router

Routes are provided with two functions: updatePage and updateState which determine what other events to fire.

The only times a map will move on automatically are when a location detail is reached through an outside url, or when first reaching a project page.

Added tab to url to redirect to specific tabs in location detail views.

Added catiline library to turn the blocking part of L.TileLayer.GeoJSON into a webworker
  • Loading branch information
linzjax committed May 11, 2017
1 parent a60e07f commit 5955e40
Show file tree
Hide file tree
Showing 68 changed files with 4,233 additions and 8,263 deletions.
7 changes: 7 additions & 0 deletions cadasta/accounts/views/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def form_valid(self, form):

return super().form_valid(form)

def render_to_response(self, context, **kwargs):
render = super().render_to_response(context, **kwargs)
if ('next' in self.request.GET):
render['Anonymous-User'] = True

return render


class ConfirmEmail(ConfirmEmailView):
def post(self, *args, **kwargs):
Expand Down
19 changes: 19 additions & 0 deletions cadasta/core/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,22 @@ def _get_content_types_to_selectors(self):
ContentType.objects.get(app_label=a, model=m)
] = v
return content_type_to_selectors


class FormErrorMixin():
def render_to_response(self, context, **kwargs):
render = super().render_to_response(context, **kwargs)
if (self.request.POST):
render['Form-Error'] = True

return render


class SpatialUnitCoords():
def render_to_response(self, context, **kwargs):
render = super().render_to_response(context, **kwargs)
location_extent = context['location'].geometry.extent
lng, lat, lng2, lat2 = location_extent
render['Coordinates'] = lat, lng, lat2, lng2

return render
Loading

0 comments on commit 5955e40

Please sign in to comment.