Compare commits
No commits in common. "8f048369bfe2031859ad7e6616fee70264e84bcf" and "abca9468837f6e170ab643923cfb657c5c1403d4" have entirely different histories.
8f048369bf
...
abca946883
@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 3.1.1 on 2020-10-04 19:37
|
||||||
|
# Edited by reverend
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.utils.timezone
|
||||||
|
from django.utils.timezone import utc
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lostplaces', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='Voucher'
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='Expireable'
|
||||||
|
)
|
||||||
|
]
|
@ -1,22 +0,0 @@
|
|||||||
# Generated by Django 3.1.1 on 2020-10-04 19:37
|
|
||||||
# Edited by reverend
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.utils.timezone
|
|
||||||
from django.utils.timezone import utc
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('lostplaces', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.DeleteModel(
|
|
||||||
name='Voucher'
|
|
||||||
),
|
|
||||||
migrations.DeleteModel(
|
|
||||||
name='Expireable'
|
|
||||||
)
|
|
||||||
]
|
|
@ -28,11 +28,7 @@ class Explorer(models.Model):
|
|||||||
related_name='explorer'
|
related_name='explorer'
|
||||||
)
|
)
|
||||||
|
|
||||||
favorite_places = models.ManyToManyField(
|
favorite_places = models.ManyToManyField(Place, related_name='favorite_places', verbose_name='Explorers favorite places')
|
||||||
Place,
|
|
||||||
related_name='favorite_places',
|
|
||||||
verbose_name='Explorers favorite places'
|
|
||||||
)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.user.username
|
return self.user.username
|
||||||
|
@ -11,8 +11,6 @@ from lostplaces.views import (
|
|||||||
PlaceDeleteView,
|
PlaceDeleteView,
|
||||||
PlaceTagDeleteView,
|
PlaceTagDeleteView,
|
||||||
PlaceTagSubmitView,
|
PlaceTagSubmitView,
|
||||||
PlaceFavoriteView,
|
|
||||||
PlaceUnfavoriteView,
|
|
||||||
PhotoAlbumCreateView,
|
PhotoAlbumCreateView,
|
||||||
PhotoAlbumDeleteView,
|
PhotoAlbumDeleteView,
|
||||||
PlaceImageCreateView,
|
PlaceImageCreateView,
|
||||||
@ -38,10 +36,5 @@ urlpatterns = [
|
|||||||
path('place/tag/<int:tagged_id>', PlaceTagSubmitView.as_view(), name='place_tag_submit'),
|
path('place/tag/<int:tagged_id>', PlaceTagSubmitView.as_view(), name='place_tag_submit'),
|
||||||
path('place/tag/delete/<int:tagged_id>/<int:tag_id>', PlaceTagDeleteView.as_view(), name='place_tag_delete'),
|
path('place/tag/delete/<int:tagged_id>/<int:tag_id>', PlaceTagDeleteView.as_view(), name='place_tag_delete'),
|
||||||
|
|
||||||
path('explorer/<int:explorer_id>/', ExplorerProfileView.as_view(), name='explorer_profile'),
|
path('explorer/<int:explorer_id>/', ExplorerProfileView.as_view(), name='explorer_profile')
|
||||||
|
|
||||||
path('explorer/favorite/<int:place_id>/', PlaceFavoriteView.as_view(), name='place_favorite'),
|
|
||||||
path('explorer/unfavorite/<int:place_id>/', PlaceUnfavoriteView.as_view(), name='place_favorite')
|
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@ -119,35 +119,3 @@ class PlaceDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, DeleteView):
|
|||||||
|
|
||||||
def get_place(self):
|
def get_place(self):
|
||||||
return self.get_object()
|
return self.get_object()
|
||||||
|
|
||||||
class PlaceFavoriteView(IsAuthenticatedMixin, View):
|
|
||||||
|
|
||||||
def get(self, request, place_id):
|
|
||||||
place = get_object_or_404(Place, id=place_id)
|
|
||||||
if request.user is not None:
|
|
||||||
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})
|
|
||||||
)
|
|
||||||
|
|
||||||
class PlaceUnfavoriteView(IsAuthenticatedMixin, View):
|
|
||||||
|
|
||||||
def get(self, request, place_id):
|
|
||||||
place = get_object_or_404(Place, id=place_id)
|
|
||||||
if request.user is not None:
|
|
||||||
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})
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user