Compare commits
No commits in common. "f73fa616d06a5c7eefac5b2df970004812c0a209" and "b42be489dc207face7f6e7d0f44e376a317801de" have entirely different histories.
f73fa616d0
...
b42be489dc
@ -6,9 +6,6 @@ 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.
|
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
|
## Features
|
||||||
- Manage lost places with lots of useful information.
|
- Manage lost places with lots of useful information.
|
||||||
- OSM-Maps
|
- OSM-Maps
|
||||||
@ -149,3 +146,7 @@ Before making the django instance public, you should tweak the config `settings.
|
|||||||
|
|
||||||
|
|
||||||
Run `django_lostplaces/manage.py collectstatic` you should be ready to go.
|
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,5 +1,3 @@
|
|||||||
from django.shortcuts import redirect
|
|
||||||
|
|
||||||
def get_all_subclasses(cls):
|
def get_all_subclasses(cls):
|
||||||
'''
|
'''
|
||||||
Gets all subclasses recursively, does not contain
|
Gets all subclasses recursively, does not contain
|
||||||
@ -11,15 +9,3 @@ def get_all_subclasses(cls):
|
|||||||
subclass_list.append(subclass)
|
subclass_list.append(subclass)
|
||||||
subclass_list += get_all_subclasses(subclass)
|
subclass_list += get_all_subclasses(subclass)
|
||||||
return subclass_list
|
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,11 +10,10 @@ from django.contrib.auth.mixins import UserPassesTestMixin, LoginRequiredMixin
|
|||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
|
|
||||||
from django.shortcuts import redirect, get_object_or_404
|
from django.shortcuts import redirect, get_object_or_404
|
||||||
from django.urls import reverse_lazy, reverse
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from lostplaces.models import Place
|
from lostplaces.models import Place
|
||||||
from lostplaces.common import redirect_referer_or
|
|
||||||
|
|
||||||
class IsAuthenticatedMixin(LoginRequiredMixin, View):
|
class IsAuthenticatedMixin(LoginRequiredMixin, View):
|
||||||
'''
|
'''
|
||||||
@ -109,4 +108,4 @@ class PlaceAssetDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, SingleOb
|
|||||||
place_id = self.get_object().place.id
|
place_id = self.get_object().place.id
|
||||||
self.get_object().delete()
|
self.get_object().delete()
|
||||||
messages.success(self.request, self.success_message)
|
messages.success(self.request, self.success_message)
|
||||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place_id}))
|
return redirect(reverse_lazy('place_detail', kwargs={'pk': place_id}))
|
||||||
|
@ -13,13 +13,12 @@ from django.contrib.messages.views import SuccessMessageMixin
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from django.urls import reverse_lazy, reverse
|
from django.urls import reverse_lazy
|
||||||
|
|
||||||
from lostplaces.models import Place, PlaceImage
|
from lostplaces.models import Place, PlaceImage
|
||||||
from lostplaces.views.base_views import IsAuthenticatedMixin, IsPlaceSubmitterMixin
|
from lostplaces.views.base_views import IsAuthenticatedMixin, IsPlaceSubmitterMixin
|
||||||
from lostplaces.views.place_image_views import MultiplePlaceImageUploadMixin
|
from lostplaces.views.place_image_views import MultiplePlaceImageUploadMixin
|
||||||
from lostplaces.forms import PlaceForm, PlaceImageForm, TagSubmitForm
|
from lostplaces.forms import PlaceForm, PlaceImageForm, TagSubmitForm
|
||||||
from lostplaces.common import redirect_referer_or
|
|
||||||
|
|
||||||
from taggit.models import Tag
|
from taggit.models import Tag
|
||||||
|
|
||||||
@ -136,7 +135,13 @@ class PlaceFavoriteView(IsAuthenticatedMixin, View):
|
|||||||
request.user.explorer.favorite_places.add(place)
|
request.user.explorer.favorite_places.add(place)
|
||||||
request.user.explorer.save()
|
request.user.explorer.save()
|
||||||
|
|
||||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
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})
|
||||||
|
)
|
||||||
|
|
||||||
class PlaceUnfavoriteView(IsAuthenticatedMixin, View):
|
class PlaceUnfavoriteView(IsAuthenticatedMixin, View):
|
||||||
|
|
||||||
@ -146,4 +151,10 @@ class PlaceUnfavoriteView(IsAuthenticatedMixin, View):
|
|||||||
request.user.explorer.favorite_places.remove(place)
|
request.user.explorer.favorite_places.remove(place)
|
||||||
request.user.explorer.save()
|
request.user.explorer.save()
|
||||||
|
|
||||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
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})
|
||||||
|
)
|
@ -6,7 +6,7 @@ from django.views.generic.edit import CreateView
|
|||||||
|
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.urls import reverse_lazy, reverse
|
from django.urls import reverse_lazy
|
||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from django.http import HttpResponseForbidden
|
from django.http import HttpResponseForbidden
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -14,7 +14,6 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
from lostplaces.forms import ExplorerCreationForm, TagSubmitForm
|
from lostplaces.forms import ExplorerCreationForm, TagSubmitForm
|
||||||
from lostplaces.models import Place, PhotoAlbum
|
from lostplaces.models import Place, PhotoAlbum
|
||||||
from lostplaces.views.base_views import IsAuthenticatedMixin
|
from lostplaces.views.base_views import IsAuthenticatedMixin
|
||||||
from lostplaces.common import redirect_referer_or
|
|
||||||
|
|
||||||
from lostplaces.views.base_views import (
|
from lostplaces.views.base_views import (
|
||||||
PlaceAssetCreateView,
|
PlaceAssetCreateView,
|
||||||
@ -80,8 +79,7 @@ class PlaceTagDeleteView(IsAuthenticatedMixin, View):
|
|||||||
place = get_object_or_404(Place, pk=tagged_id)
|
place = get_object_or_404(Place, pk=tagged_id)
|
||||||
tag = get_object_or_404(Tag, pk=tag_id)
|
tag = get_object_or_404(Tag, pk=tag_id)
|
||||||
place.tags.remove(tag)
|
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):
|
def FlatView(request, slug):
|
||||||
if request.LANGUAGE_CODE == 'de':
|
if request.LANGUAGE_CODE == 'de':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user