View for submitting additionale place images

This commit is contained in:
reverend 2020-09-26 09:48:06 +02:00
parent 277cac323e
commit b4bd86ed44
4 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,28 @@
{% extends 'global.html'%}
{% block maincontent %}
<form class="LP-Form" method="POST" enctype="multipart/form-data">
<fieldset class="LP-Form__Fieldset">
<legend class="LP-Form__Legend">Submit images to an place</legend>
{% csrf_token %}
<div class="LP-Form__Composition">
<div class="LP-Form__Field">
{% include 'partials/form/inputField.html' with field=form.filename %}
</div>
</div>
<div class="LP-Form__Composition LP-Form__Composition--buttons">
<div class="LP-Form__Field LP-Form__Button LP-Input">
<button class="LP-Button">Submitt</button>
</div>
<div class="LP-Form__Field LP-Form__Button LP-Input">
<a class="LP-Link" href="{% url 'place_list' %}">
<button type="button" class="LP-Button LP-Button--cancel">Cancel</button>
</a>
</div>
</div>
</fieldset>
</form>
{% endblock maincontent %}

View File

@ -13,6 +13,7 @@ from lostplaces.views import (
PlaceTagSubmitView,
PhotoAlbumCreateView,
PhotoAlbumDeleteView,
PlaceImageCreateView,
FlatView
)
@ -25,6 +26,7 @@ urlpatterns = [
path('place/update/<int:pk>/', PlaceUpdateView.as_view(), name='place_edit'),
path('place/delete/<int:pk>/', PlaceDeleteView.as_view(), name='place_delete'),
path('place/', PlaceListView.as_view(), name='place_list'),
path('place_image/create/<int:place_id>', PlaceImageCreateView.as_view(), name='place_image_create'),
path('flat/<slug:slug>/', FlatView, name='flatpage'),
# POST-only URLs for tag submission

View File

@ -4,3 +4,4 @@
from lostplaces.views.base_views import *
from lostplaces.views.views import *
from lostplaces.views.place_views import *
from lostplaces.views.place_image_views import *

View File

@ -0,0 +1,18 @@
from django.views import View
from django.shortcuts import get_object_or_404
from lostplaces.views.base_views import PlaceAssetCreateView
from lostplaces.models import PlaceImage, Place
class PlaceImageCreateView(PlaceAssetCreateView):
model = PlaceImage
fields = ['filename']
template_name = 'place_image/place_image_create.html'
success_message = 'Place Images submitted'
def post(self, request, place_id, *args, **kwargs):
place = get_object_or_404(Place, pk=place_id)
super().post(request, place_id)
self.object.place = place
self.object = self.request.user
self.object.save()