Compare commits
6 Commits
27-Favorit
...
d04e986419
Author | SHA1 | Date | |
---|---|---|---|
d04e986419 | |||
cbbda88850 | |||
981c440ce3 | |||
c7368f5c44 | |||
20dd880a11 | |||
946c3091c0 |
@@ -14,7 +14,6 @@ from django.db.models.signals import post_save
|
|||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
|
||||||
from lostplaces.models.abstract_models import Expireable
|
from lostplaces.models.abstract_models import Expireable
|
||||||
from lostplaces.models.place import Place
|
|
||||||
|
|
||||||
class Explorer(models.Model):
|
class Explorer(models.Model):
|
||||||
"""
|
"""
|
||||||
@@ -28,13 +27,6 @@ class Explorer(models.Model):
|
|||||||
related_name='explorer'
|
related_name='explorer'
|
||||||
)
|
)
|
||||||
|
|
||||||
favorite_places = models.ManyToManyField(
|
|
||||||
Place,
|
|
||||||
related_name='favorite_places',
|
|
||||||
verbose_name='Explorers favorite places',
|
|
||||||
blank=True
|
|
||||||
)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.user.username
|
return self.user.username
|
||||||
|
|
||||||
@@ -49,11 +41,13 @@ def save_user_profile(sender, instance, **kwargs):
|
|||||||
|
|
||||||
class Voucher(Expireable):
|
class Voucher(Expireable):
|
||||||
"""
|
"""
|
||||||
Vouchers are authorization to created_when = models.DateTimeField(auto_now_add=True)
|
Vouchers are authorization tokens to allow the registration of new users.
|
||||||
expires_when = models.DateTimeField()kens to allow the registration of new users.
|
|
||||||
A voucher has a code, a creation and a deletion date, which are all
|
A voucher has a code, a creation and a deletion date, which are all
|
||||||
positional. Creation date is being set automatically during voucher
|
positional. Creation date is being set automatically during voucher
|
||||||
creation.
|
creation.
|
||||||
|
|
||||||
|
created_when = models.DateTimeField(auto_now_add=True)
|
||||||
|
expires_when = models.DateTimeField()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
code = models.CharField(unique=True, max_length=30)
|
code = models.CharField(unique=True, max_length=30)
|
||||||
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 108 KiB |
@@ -14,6 +14,22 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="LP-UserInfo__Meta">
|
<div class="LP-UserInfo__Meta">
|
||||||
<table>
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="LP-UserInfo__Key">
|
||||||
|
<span class="LP-Paragraph">{% trans 'Name' %}</span>
|
||||||
|
</td>
|
||||||
|
<td class="LP-UserInfo__Value">
|
||||||
|
<span class="LP-Paragraph">{{explorer.user.first_name}} {{explorer.user.last_name}}</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="LP-UserInfo__Key">
|
||||||
|
<span class="LP-Paragraph">{% trans 'E-Mail' %}</span>
|
||||||
|
</td>
|
||||||
|
<td class="LP-UserInfo__Value">
|
||||||
|
<span class="LP-Paragraph">{{explorer.user.email}}</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="LP-UserInfo__Key">
|
<td class="LP-UserInfo__Key">
|
||||||
<span class="LP-Paragraph">{% trans 'Joined' %}</span>
|
<span class="LP-Paragraph">{% trans 'Joined' %}</span>
|
||||||
@@ -50,7 +66,9 @@
|
|||||||
<ul class="LP-PlaceList__List">
|
<ul class="LP-PlaceList__List">
|
||||||
{% for place in place_list %}
|
{% for place in place_list %}
|
||||||
<li class="LP-PlaceList__Item">
|
<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 %}
|
{% include 'partials/place_teaser.html' with place=place extended=True %}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -21,7 +21,9 @@
|
|||||||
<ul class="LP-PlaceGrid__Grid">
|
<ul class="LP-PlaceGrid__Grid">
|
||||||
{% for place in place_list %}
|
{% for place in place_list %}
|
||||||
<li class="LP-PlaceGrid__Item">
|
<li class="LP-PlaceGrid__Item">
|
||||||
|
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||||
{% include 'partials/place_teaser.html' with place=place%}
|
{% include 'partials/place_teaser.html' with place=place%}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -1,14 +0,0 @@
|
|||||||
{%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,7 +1,6 @@
|
|||||||
{%load static %}
|
{%load static %}
|
||||||
|
|
||||||
<article class="LP-PlaceTeaser {% if extended %} LP-PlaceTeaser--extended{% endif %}">
|
<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">
|
<div class="LP-PlaceTeaser__Image">
|
||||||
{% if place.placeimages.all|length > 0 %}
|
{% if place.placeimages.all|length > 0 %}
|
||||||
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url}}" />
|
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url}}" />
|
||||||
@@ -9,7 +8,6 @@
|
|||||||
<img class="LP-Image" src="{% static 'images/missing_image.png' %}" />
|
<img class="LP-Image" src="{% static 'images/missing_image.png' %}" />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
|
||||||
<div class="LP-PlaceTeaser__Meta">
|
<div class="LP-PlaceTeaser__Meta">
|
||||||
<div class="LP-PlaceTeaser__Info">
|
<div class="LP-PlaceTeaser__Info">
|
||||||
<span class="LP-PlaceTeaser__Title">
|
<span class="LP-PlaceTeaser__Title">
|
||||||
@@ -30,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="LP-PlaceTeaser__Icons">
|
<div class="LP-PlaceTeaser__Icons">
|
||||||
<ul class="LP-Icon__List">
|
<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/favourite.svg' %}" /></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/location.svg' %}" /></li>
|
||||||
<li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/flag.svg' %}" /></li>
|
<li class="LP-Icon__Item"><img class="LP-Icon" src="{% static '/icons/flag.svg' %}" /></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
<article class="LP-PlaceDetail">
|
<article class="LP-PlaceDetail">
|
||||||
|
|
||||||
<header class="LP-PlaceDetail__Header">
|
<header class="LP-PlaceDetail__Header">
|
||||||
<h1 class="LP-Headline">{{ place.name }} {% include 'partials/icons/place_favorite.html' %}</h1>
|
<h1 class="LP-Headline">{{ place.name }}</h1>
|
||||||
{% if place.placeimages.first.filename.hero.url %}
|
{% if place.placeimages.first.filename.hero.url %}
|
||||||
<figure class="LP-PlaceDetail__Image">
|
<figure class="LP-PlaceDetail__Image">
|
||||||
<img src="{{ place.placeimages.first.filename.hero.url }}" class="LP-Image" />
|
<img src="{{ place.placeimages.first.filename.hero.url }}" class="LP-Image" />
|
||||||
|
@@ -17,7 +17,9 @@
|
|||||||
<ul class="LP-PlaceList__List">
|
<ul class="LP-PlaceList__List">
|
||||||
{% for place in place_list %}
|
{% for place in place_list %}
|
||||||
<li class="LP-PlaceList__Item">
|
<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 %}
|
{% include 'partials/place_teaser.html' with place=place extended=True %}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@@ -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_unfavorite')
|
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@@ -34,12 +34,8 @@ class ExplorerProfileView(IsAuthenticatedMixin, View):
|
|||||||
|
|
||||||
context['asset_count'] = asset_count
|
context['asset_count'] = asset_count
|
||||||
|
|
||||||
print(context['assets'])
|
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request=request,
|
request=request,
|
||||||
template_name='explorer/profile.html',
|
template_name='explorer/profile.html',
|
||||||
context=context
|
context=context
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@@ -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})
|
|
||||||
)
|
|
Reference in New Issue
Block a user