Merge commit 'a22c988e948438415d1a58cac627243ae24785f4' into develop
This commit is contained in:
commit
a78f123d1f
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-25 18:14
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('lostplaces', '0004_auto_20201225_1702'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='explorer',
|
||||
name='visited_places',
|
||||
field=models.ManyToManyField(blank=True, related_name='explorer_visits', to='lostplaces.Place', verbose_name='Explorers visited places'),
|
||||
),
|
||||
]
|
@ -62,6 +62,12 @@ class Explorer(models.Model):
|
||||
verbose_name='Explorers favorite places',
|
||||
blank=True
|
||||
)
|
||||
visited_places = models.ManyToManyField(
|
||||
Place,
|
||||
related_name='explorer_visits',
|
||||
verbose_name='Explorers visited places',
|
||||
blank=True
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.user.username
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@ -13,7 +13,7 @@
|
||||
viewBox="0 0 512.07 512.07"
|
||||
width="512"
|
||||
version="1.1"
|
||||
sodipodi:docname="favourite_filled.svg"
|
||||
sodipodi:docname="favorite_filled.svg"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
|
||||
<metadata
|
||||
id="metadata11">
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
@ -90,9 +90,21 @@
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% include 'partials/nav/pagination.html' %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="LP-Section">
|
||||
<div class="LP-PlaceList">
|
||||
<h1 class="LP-Headline">{% trans 'Visited places' %}</h1>
|
||||
<ul class="LP-PlaceList__List">
|
||||
{% for place in explorer.visited_places.all %}
|
||||
<li class="LP-PlaceList__Item">
|
||||
{% include 'partials/place_teaser.html' with place=place extended=True %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% include 'partials/nav/pagination.html' %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
@ -4,11 +4,11 @@
|
||||
{% if request.user %}
|
||||
{% if place in request.user.explorer.favorite_places.all %}
|
||||
<a href="{% url 'place_unfavorite' place_id=place.id %}" class="LP-Link" title="{% trans 'Remove from favorites' %}">
|
||||
<img class="LP-Icon" src="{% static '/icons/favourite_filled.svg' %}" />
|
||||
<img class="LP-Icon" src="{% static '/icons/favorite_filled.svg' %}" />
|
||||
</a>
|
||||
{%else%}
|
||||
<a href="{% url 'place_favorite' place_id=place.id %}" class="LP-Link" title="{% trans 'Save as favorite' %}">
|
||||
<img class="LP-Icon" src="{% static '/icons/favourite.svg' %}" />
|
||||
<img class="LP-Icon" src="{% static '/icons/favorite.svg' %}" />
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -0,0 +1,14 @@
|
||||
{%load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% if request.user %}
|
||||
{% if place in request.user.explorer.visited_places.all %}
|
||||
<a href="{% url 'place_visit_delete' place_id=place.id %}" class="LP-Link" title="{% trans 'Remove from visits' %}">
|
||||
<img class="LP-Icon" src="{% static '/icons/pin_filled.svg' %}" />
|
||||
</a>
|
||||
{%else%}
|
||||
<a href="{% url 'place_visit_create' place_id=place.id %}" class="LP-Link" title="{% trans 'Save as visited' %}">
|
||||
<img class="LP-Icon" src="{% static '/icons/pin.svg' %}" />
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -31,7 +31,7 @@
|
||||
<div class="LP-PlaceTeaser__Icons">
|
||||
<ul class="LP-Icon__List">
|
||||
<li class="LP-Icon__Item">{% include 'partials/icons/place_favorite.html' with place=place%}</li>
|
||||
<li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/pin.svg' %}" /></li>
|
||||
<li class="LP-Icon__Item">{% include 'partials/icons/place_visited.html' with place=place%}</li>
|
||||
<li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/flag.svg' %}" /></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<article class="LP-PlaceDetail">
|
||||
|
||||
<header class="LP-PlaceDetail__Header">
|
||||
<h1 class="LP-Headline">{{ place.name }} {% include 'partials/icons/place_favorite.html' %}</h1>
|
||||
<h1 class="LP-Headline">{{ place.name }} {% include 'partials/icons/place_favorite.html' %} {% include 'partials/icons/place_visited.html' %}</h1>
|
||||
{% if place.placeimages.first.filename.hero.url %}
|
||||
<figure class="LP-PlaceDetail__Image">
|
||||
<img src="{{ place.placeimages.first.filename.hero.url }}" class="LP-Image" />
|
||||
|
@ -4,6 +4,8 @@
|
||||
from django.urls import path
|
||||
from lostplaces.views import (
|
||||
HomeView,
|
||||
FlatView,
|
||||
OSMMapView,
|
||||
PlaceDetailView,
|
||||
PlaceListView,
|
||||
PlaceCreateView,
|
||||
@ -13,37 +15,39 @@ from lostplaces.views import (
|
||||
PlaceTagSubmitView,
|
||||
PlaceFavoriteView,
|
||||
PlaceUnfavoriteView,
|
||||
PhotoAlbumCreateView,
|
||||
PhotoAlbumDeleteView,
|
||||
PlaceVisitCreateView,
|
||||
PlaceVisitDeleteView,
|
||||
PlaceImageCreateView,
|
||||
PlaceImageDeleteView,
|
||||
FlatView,
|
||||
PhotoAlbumCreateView,
|
||||
PhotoAlbumDeleteView,
|
||||
ExplorerProfileView,
|
||||
ExplorerProfileUpdateView,
|
||||
OSMMapView
|
||||
ExplorerProfileUpdateView
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path('', HomeView.as_view(), name='lostplaces_home'),
|
||||
path('place/<int:pk>/', PlaceDetailView.as_view(), name='place_detail'),
|
||||
path('place/create/', PlaceCreateView.as_view(), name='place_create'),
|
||||
path('photo_album/create/<int:place_id>', PhotoAlbumCreateView.as_view(), name='photo_album_create'),
|
||||
path('photo_album/delete/<int:pk>', PhotoAlbumDeleteView.as_view(), name='photo_album_delete'),
|
||||
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('place_image/delete/<int:pk>', PlaceImageDeleteView.as_view(), name='place_image_delete'),
|
||||
path('flat/<slug:slug>/', FlatView, name='flatpage'),
|
||||
|
||||
# POST-only URLs for tag submission
|
||||
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('osm/', OSMMapView.as_view(), name='osm'),
|
||||
|
||||
path('explorer/<int:explorer_id>/', ExplorerProfileView.as_view(), name='explorer_profile'),
|
||||
path('explorer/update/', ExplorerProfileUpdateView.as_view(), name='explorer_profile_update'),
|
||||
|
||||
path('explorer/favorite/<int:place_id>/', PlaceFavoriteView.as_view(), name='place_favorite'),
|
||||
path('explorer/unfavorite/<int:place_id>/', PlaceUnfavoriteView.as_view(), name='place_unfavorite'),
|
||||
path('osm/', OSMMapView.as_view(), name='osm')
|
||||
path('place/', PlaceListView.as_view(), name='place_list'),
|
||||
path('place/<int:pk>/', PlaceDetailView.as_view(), name='place_detail'),
|
||||
path('place/create/', PlaceCreateView.as_view(), name='place_create'),
|
||||
path('place/update/<int:pk>/', PlaceUpdateView.as_view(), name='place_edit'),
|
||||
path('place/delete/<int:pk>/', PlaceDeleteView.as_view(), name='place_delete'),
|
||||
path('place/tag/create/<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/fav/create/<int:place_id>/', PlaceFavoriteView.as_view(), name='place_favorite'),
|
||||
path('place/fav/delete/<int:place_id>/', PlaceUnfavoriteView.as_view(), name='place_unfavorite'),
|
||||
path('place/visit/create/<int:place_id>/', PlaceVisitCreateView.as_view(), name='place_visit_create'),
|
||||
path('place/visit/delete/<int:place_id>/', PlaceVisitDeleteView.as_view(), name='place_visit_delete'),
|
||||
|
||||
path('place_image/create/<int:place_id>/', PlaceImageCreateView.as_view(), name='place_image_create'),
|
||||
path('place_image/delete/<int:pk>/', PlaceImageDeleteView.as_view(), name='place_image_delete'),
|
||||
|
||||
path('photo_album/create/<int:place_id>/', PhotoAlbumCreateView.as_view(), name='photo_album_create'),
|
||||
path('photo_album/delete/<int:pk>/', PhotoAlbumDeleteView.as_view(), name='photo_album_delete')
|
||||
]
|
||||
|
@ -147,3 +147,23 @@ class PlaceUnfavoriteView(IsAuthenticatedMixin, View):
|
||||
request.user.explorer.save()
|
||||
|
||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
||||
|
||||
class PlaceVisitCreateView(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.visited_places.add(place)
|
||||
request.user.explorer.save()
|
||||
|
||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
||||
|
||||
class PlaceVisitDeleteView(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.visited_places.remove(place)
|
||||
request.user.explorer.save()
|
||||
|
||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
||||
|
Loading…
Reference in New Issue
Block a user