refactor: add map marker to context on update

This commit is contained in:
James Graham
2021-01-15 16:32:57 +00:00
parent 9db870bcb0
commit 59f717829a
4 changed files with 31 additions and 36 deletions

View File

@@ -57,7 +57,8 @@ class ProfileView(permissions.UserIsLinkedPersonMixin, DetailView):
# pk was not provided in URL
return self.request.user.person
def get_context_data(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
def get_context_data(self,
**kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
"""Add current :class:`PersonAnswerSet` to context."""
context = super().get_context_data(**kwargs)
@@ -74,6 +75,14 @@ class PersonUpdateView(permissions.UserIsLinkedPersonMixin, UpdateView):
template_name = 'people/person/update.html'
form_class = forms.PersonAnswerSetForm
def get_context_data(self,
**kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
context = super().get_context_data(**kwargs)
context['map_markers'] = [get_map_data(self.object)]
return context
def get_initial(self) -> typing.Dict[str, typing.Any]:
return {
'person_id': self.object.id,
@@ -129,7 +138,8 @@ class PersonMapView(LoginRequiredMixin, ListView):
model = models.Person
template_name = 'people/person/map.html'
def get_context_data(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
def get_context_data(self,
**kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
context = super().get_context_data(**kwargs)
context['map_markers'] = [