From dc79b9d05c24ab96f3d79f25b3546ec1dbc72c77 Mon Sep 17 00:00:00 2001 From: reverend Date: Thu, 24 Dec 2020 19:47:17 +0100 Subject: [PATCH] #43 Lat/Long Check when place is submitted --- django_lostplaces/lostplaces/forms.py | 10 +++++++++- django_lostplaces/lostplaces/views/place_views.py | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/django_lostplaces/lostplaces/forms.py b/django_lostplaces/lostplaces/forms.py index 7cd51e3..9cbb37f 100644 --- a/django_lostplaces/lostplaces/forms.py +++ b/django_lostplaces/lostplaces/forms.py @@ -44,7 +44,15 @@ class PlaceForm(forms.ModelForm): class Meta: model = Place fields = '__all__' - exclude = ['submitted_by'] + exclude = ['submitted_by', 'latitude', 'longitute'] + + latitude = forms.IntegerField( + widget=forms.NumberInput(attrs={'min':-90,'max': 90,'type': 'number'}) + ) + + longitude = forms.IntegerField( + widget=forms.NumberInput(attrs={'min':-180,'max': 180,'type': 'number'}) + ) class PlaceImageForm(forms.ModelForm): class Meta: diff --git a/django_lostplaces/lostplaces/views/place_views.py b/django_lostplaces/lostplaces/views/place_views.py index c96726b..0d3ecb4 100644 --- a/django_lostplaces/lostplaces/views/place_views.py +++ b/django_lostplaces/lostplaces/views/place_views.py @@ -104,7 +104,14 @@ class PlaceCreateView(MultiplePlaceImageUploadMixin, IsAuthenticatedMixin, View) self.request, _('Please fill in all required fields.') ) - return render(request, 'place/place_create.html', context={'form': place_form}) + return render( + request=request, + template_name='place/place_create.html', + context={ + 'place_form': place_form, + 'place_image_form': PlaceImageForm() + } + ) class PlaceDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, DeleteView): template_name = 'place/place_delete.html'