ui base for reporting issues and missing locations
This commit is contained in:
parent
9664b22a0c
commit
a8d0be6653
10 changed files with 157 additions and 69 deletions
|
@ -1,4 +1,5 @@
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
|
@ -74,6 +75,11 @@ class RoutingViewSet(ViewSet):
|
|||
'destination': form.cleaned_data['destination'].pk,
|
||||
},
|
||||
'options': options.serialize(),
|
||||
'report_issue_url': reverse('site.report', kwargs={
|
||||
'origin': request.POST['origin'],
|
||||
'destination': request.POST['destination'],
|
||||
'options': options.serialize_string()
|
||||
}),
|
||||
'result': route.serialize(locations=visible_locations_for_request(request)),
|
||||
})
|
||||
|
||||
|
|
|
@ -178,6 +178,9 @@ class RouteOptions(models.Model):
|
|||
for name, field in self.get_fields().items()
|
||||
]
|
||||
|
||||
def serialize_string(self):
|
||||
return ','.join('%s=%s' % (key, val) for key, val in self.data.items())
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.request is None or self.request.user.is_authenticated:
|
||||
self.user = self.request.user
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import json
|
||||
import logging
|
||||
import operator
|
||||
import os
|
||||
|
@ -375,7 +374,7 @@ class Router:
|
|||
areas=areas, near_area=near_area, near_poi=near_poi)
|
||||
|
||||
def shortest_path(self, restrictions, options):
|
||||
options_key = json.dumps(options.data, separators=(',', '='), sort_keys=True)[1:-1]
|
||||
options_key = options.serialize_string()
|
||||
cache_key = 'router:shortest_path:%s:%s:%s' % (MapUpdate.current_processed_cache_key(),
|
||||
restrictions.cache_key,
|
||||
options_key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue