Compare commits
3 Commits
b42be489dc
...
f73fa616d0
Author | SHA1 | Date | |
---|---|---|---|
f73fa616d0 | |||
629a609ff5 | |||
04fe93c7bb |
@ -6,6 +6,9 @@ The software is currently in early development status, neither scope, datamodel(
|
||||
|
||||
We value privacy as a whole, all resources the frontend requires will be shipped with lostplace's distribution. We also try to minimize the use of JavaScript as far as we can and try to offer JS-less alternatives where we can.
|
||||
|
||||
## Contact
|
||||
If you run into any issues, have any questions or If you are interested in this project in general, feel free to get in touch with us via [reverend@reverend2048.de](mailto:reverend@reverend2048.de), we do speak English and German.
|
||||
|
||||
## Features
|
||||
- Manage lost places with lots of useful information.
|
||||
- OSM-Maps
|
||||
@ -146,7 +149,3 @@ Before making the django instance public, you should tweak the config `settings.
|
||||
|
||||
|
||||
Run `django_lostplaces/manage.py collectstatic` you should be ready to go.
|
||||
|
||||
|
||||
### Contact
|
||||
If you run into any issues, have any questions or If you are interested in this project in general, feel free to get in touch with us via [reverend@reverend2048.de](mailto:reverend@reverend2048.de), we do speak English and German.
|
@ -1,3 +1,5 @@
|
||||
from django.shortcuts import redirect
|
||||
|
||||
def get_all_subclasses(cls):
|
||||
'''
|
||||
Gets all subclasses recursively, does not contain
|
||||
@ -9,3 +11,15 @@ def get_all_subclasses(cls):
|
||||
subclass_list.append(subclass)
|
||||
subclass_list += get_all_subclasses(subclass)
|
||||
return subclass_list
|
||||
|
||||
def redirect_referer_or(request, url='/'):
|
||||
'''
|
||||
Returns a django redirect to the requests referer,
|
||||
if there is no referer the redirect will poin to the given url
|
||||
Default url is /
|
||||
'''
|
||||
referer = request.META.get('HTTP_REFERER')
|
||||
if referer is not None:
|
||||
return redirect(referer)
|
||||
else:
|
||||
return redirect(url)
|
@ -10,10 +10,11 @@ from django.contrib.auth.mixins import UserPassesTestMixin, LoginRequiredMixin
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
|
||||
from django.shortcuts import redirect, get_object_or_404
|
||||
from django.urls import reverse_lazy
|
||||
from django.urls import reverse_lazy, reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from lostplaces.models import Place
|
||||
from lostplaces.common import redirect_referer_or
|
||||
|
||||
class IsAuthenticatedMixin(LoginRequiredMixin, View):
|
||||
'''
|
||||
@ -108,4 +109,4 @@ class PlaceAssetDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, SingleOb
|
||||
place_id = self.get_object().place.id
|
||||
self.get_object().delete()
|
||||
messages.success(self.request, self.success_message)
|
||||
return redirect(reverse_lazy('place_detail', kwargs={'pk': place_id}))
|
||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place_id}))
|
||||
|
@ -13,12 +13,13 @@ from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.urls import reverse_lazy
|
||||
from django.urls import reverse_lazy, reverse
|
||||
|
||||
from lostplaces.models import Place, PlaceImage
|
||||
from lostplaces.views.base_views import IsAuthenticatedMixin, IsPlaceSubmitterMixin
|
||||
from lostplaces.views.place_image_views import MultiplePlaceImageUploadMixin
|
||||
from lostplaces.forms import PlaceForm, PlaceImageForm, TagSubmitForm
|
||||
from lostplaces.common import redirect_referer_or
|
||||
|
||||
from taggit.models import Tag
|
||||
|
||||
@ -135,13 +136,7 @@ class PlaceFavoriteView(IsAuthenticatedMixin, View):
|
||||
request.user.explorer.favorite_places.add(place)
|
||||
request.user.explorer.save()
|
||||
|
||||
referer = request.META.get('HTTP_REFERER')
|
||||
if referer is not None:
|
||||
return redirect(referer)
|
||||
else:
|
||||
return redirect(
|
||||
reverse_lazy('place_detail', kwargs={'pk': place.pk})
|
||||
)
|
||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
||||
|
||||
class PlaceUnfavoriteView(IsAuthenticatedMixin, View):
|
||||
|
||||
@ -151,10 +146,4 @@ class PlaceUnfavoriteView(IsAuthenticatedMixin, View):
|
||||
request.user.explorer.favorite_places.remove(place)
|
||||
request.user.explorer.save()
|
||||
|
||||
referer = request.META.get('HTTP_REFERER')
|
||||
if referer is not None:
|
||||
return redirect(referer)
|
||||
else:
|
||||
return redirect(
|
||||
reverse_lazy('place_detail', kwargs={'pk': place.pk})
|
||||
)
|
||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
@ -6,7 +6,7 @@ from django.views.generic.edit import CreateView
|
||||
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.contrib import messages
|
||||
from django.urls import reverse_lazy
|
||||
from django.urls import reverse_lazy, reverse
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.http import HttpResponseForbidden
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@ -14,6 +14,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from lostplaces.forms import ExplorerCreationForm, TagSubmitForm
|
||||
from lostplaces.models import Place, PhotoAlbum
|
||||
from lostplaces.views.base_views import IsAuthenticatedMixin
|
||||
from lostplaces.common import redirect_referer_or
|
||||
|
||||
from lostplaces.views.base_views import (
|
||||
PlaceAssetCreateView,
|
||||
@ -79,7 +80,8 @@ class PlaceTagDeleteView(IsAuthenticatedMixin, View):
|
||||
place = get_object_or_404(Place, pk=tagged_id)
|
||||
tag = get_object_or_404(Tag, pk=tag_id)
|
||||
place.tags.remove(tag)
|
||||
return redirect(reverse_lazy('place_detail', kwargs={'pk': tagged_id}))
|
||||
|
||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': tagged_id}))
|
||||
|
||||
def FlatView(request, slug):
|
||||
if request.LANGUAGE_CODE == 'de':
|
||||
|
Loading…
Reference in New Issue
Block a user