Compare commits
7 Commits
8f048369bf
...
4a43a4bf37
Author | SHA1 | Date | |
---|---|---|---|
4a43a4bf37 | |||
61cf148417 | |||
d547ee9db3 | |||
c7b699f615 | |||
86f95a5dd0 | |||
916c4b80f7 | |||
b31dc9fc5f |
@ -31,7 +31,8 @@ class Explorer(models.Model):
|
||||
favorite_places = models.ManyToManyField(
|
||||
Place,
|
||||
related_name='favorite_places',
|
||||
verbose_name='Explorers favorite places'
|
||||
verbose_name='Explorers favorite places',
|
||||
blank=True
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
|
163
django_lostplaces/lostplaces/static/icons/favourite_filled.svg
Normal file
163
django_lostplaces/lostplaces/static/icons/favourite_filled.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 108 KiB |
@ -50,9 +50,7 @@
|
||||
<ul class="LP-PlaceList__List">
|
||||
{% for place in place_list %}
|
||||
<li class="LP-PlaceList__Item">
|
||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||
{% include 'partials/place_teaser.html' with place=place extended=True %}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -21,9 +21,7 @@
|
||||
<ul class="LP-PlaceGrid__Grid">
|
||||
{% for place in place_list %}
|
||||
<li class="LP-PlaceGrid__Item">
|
||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||
{% include 'partials/place_teaser.html' with place=place%}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -0,0 +1,14 @@
|
||||
{%load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% 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' %}" />
|
||||
</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' %}" />
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -1,6 +1,7 @@
|
||||
{%load static %}
|
||||
|
||||
<article class="LP-PlaceTeaser {% if extended %} LP-PlaceTeaser--extended{% endif %}">
|
||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||
<div class="LP-PlaceTeaser__Image">
|
||||
{% if place.placeimages.all|length > 0 %}
|
||||
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url}}" />
|
||||
@ -8,6 +9,7 @@
|
||||
<img class="LP-Image" src="{% static 'images/missing_image.png' %}" />
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
<div class="LP-PlaceTeaser__Meta">
|
||||
<div class="LP-PlaceTeaser__Info">
|
||||
<span class="LP-PlaceTeaser__Title">
|
||||
@ -28,7 +30,7 @@
|
||||
</div>
|
||||
<div class="LP-PlaceTeaser__Icons">
|
||||
<ul class="LP-Icon__List">
|
||||
<li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/favourite.svg' %}" /></li>
|
||||
<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/location.svg' %}" /></li>
|
||||
<li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/flag.svg' %}" /></li>
|
||||
</ul>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<article class="LP-PlaceDetail">
|
||||
|
||||
<header class="LP-PlaceDetail__Header">
|
||||
<h1 class="LP-Headline">{{ place.name }}</h1>
|
||||
<h1 class="LP-Headline">{{ place.name }} {% include 'partials/icons/place_favorite.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" />
|
||||
|
@ -17,9 +17,7 @@
|
||||
<ul class="LP-PlaceList__List">
|
||||
{% for place in place_list %}
|
||||
<li class="LP-PlaceList__Item">
|
||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||
{% include 'partials/place_teaser.html' with place=place extended=True %}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -41,7 +41,7 @@ urlpatterns = [
|
||||
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')
|
||||
path('explorer/unfavorite/<int:place_id>/', PlaceUnfavoriteView.as_view(), name='place_unfavorite')
|
||||
|
||||
|
||||
]
|
||||
|
@ -128,7 +128,7 @@ class PlaceFavoriteView(IsAuthenticatedMixin, View):
|
||||
request.user.explorer.favorite_places.add(place)
|
||||
request.user.explorer.save()
|
||||
|
||||
referer = request.META.get('HTTP_referer')
|
||||
referer = request.META.get('HTTP_REFERER')
|
||||
if referer is not None:
|
||||
return redirect(referer)
|
||||
else:
|
||||
@ -144,7 +144,7 @@ class PlaceUnfavoriteView(IsAuthenticatedMixin, View):
|
||||
request.user.explorer.favorite_places.remove(place)
|
||||
request.user.explorer.save()
|
||||
|
||||
referer = request.META.get('HTTP_referer')
|
||||
referer = request.META.get('HTTP_REFERER')
|
||||
if referer is not None:
|
||||
return redirect(referer)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user