Compare commits
13 Commits
3c5b447d4c
...
27-Favorit
Author | SHA1 | Date | |
---|---|---|---|
4a43a4bf37 | |||
61cf148417 | |||
d547ee9db3 | |||
c7b699f615 | |||
86f95a5dd0 | |||
916c4b80f7 | |||
b31dc9fc5f | |||
8f048369bf | |||
f974469996 | |||
dbbd7b0802 | |||
abca946883 | |||
4bacd1a28d | |||
086789aa88 |
@@ -1,4 +1,4 @@
|
|||||||
# Generated by Django 3.1.1 on 2020-11-29 17:46
|
# Generated by Django 3.1.1 on 2020-09-28 18:39
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
@@ -14,11 +14,19 @@ class Migration(migrations.Migration):
|
|||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('taggit', '0003_taggeditem_add_unique_index'),
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('taggit', '0003_taggeditem_add_unique_index'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Expireable',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('created_when', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('expires_when', models.DateTimeField()),
|
||||||
|
],
|
||||||
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Explorer',
|
name='Explorer',
|
||||||
fields=[
|
fields=[
|
||||||
@@ -30,13 +38,13 @@ class Migration(migrations.Migration):
|
|||||||
name='Place',
|
name='Place',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('name', models.CharField(max_length=50, verbose_name='Name')),
|
('name', models.CharField(max_length=50)),
|
||||||
('latitude', models.FloatField(help_text='Latitude in decimal format: e. g. 41.40338', validators=[django.core.validators.MinValueValidator(-90), django.core.validators.MaxValueValidator(90)], verbose_name='Latitude')),
|
('latitude', models.FloatField(validators=[django.core.validators.MinValueValidator(-90), django.core.validators.MaxValueValidator(90)])),
|
||||||
('longitude', models.FloatField(help_text='Longitude in decimal format: e. g. 2.17403', validators=[django.core.validators.MinValueValidator(-180), django.core.validators.MaxValueValidator(180)], verbose_name='Longitude')),
|
('longitude', models.FloatField(validators=[django.core.validators.MinValueValidator(-180), django.core.validators.MaxValueValidator(180)])),
|
||||||
('submitted_when', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Submission date')),
|
('submitted_when', models.DateTimeField(auto_now_add=True, null=True)),
|
||||||
('location', models.CharField(max_length=50, verbose_name='Location')),
|
('location', models.CharField(max_length=50)),
|
||||||
('description', models.TextField(help_text="Description of the place: e.g. how to get there, where to be careful, the place's history...", verbose_name='Description')),
|
('description', models.TextField()),
|
||||||
('submitted_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='places', to='lostplaces.explorer', verbose_name='Submitter')),
|
('submitted_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='places', to='lostplaces.explorer')),
|
||||||
('tags', taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')),
|
('tags', taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
@@ -46,24 +54,20 @@ class Migration(migrations.Migration):
|
|||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Voucher',
|
name='Voucher',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('expireable_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='lostplaces.expireable')),
|
||||||
('created_when', models.DateTimeField(auto_now_add=True, verbose_name='Creation date')),
|
|
||||||
('expires_when', models.DateTimeField(verbose_name='Expiration date')),
|
|
||||||
('code', models.CharField(max_length=30, unique=True)),
|
('code', models.CharField(max_length=30, unique=True)),
|
||||||
],
|
],
|
||||||
options={
|
bases=('lostplaces.expireable',),
|
||||||
'abstract': False,
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='PlaceImage',
|
name='PlaceImage',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('submitted_when', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Submission date')),
|
('submitted_when', models.DateTimeField(auto_now_add=True, null=True)),
|
||||||
('description', models.TextField(blank=True, verbose_name='Description')),
|
('description', models.TextField(blank=True)),
|
||||||
('filename', easy_thumbnails.fields.ThumbnailerImageField(help_text='Optional: One or more images to upload', upload_to=lostplaces.models.place.generate_image_upload_path, verbose_name='Filename(s)')),
|
('filename', easy_thumbnails.fields.ThumbnailerImageField(upload_to=lostplaces.models.place.generate_image_upload_path)),
|
||||||
('place', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='placeimages', to='lostplaces.place')),
|
('place', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='placeimages', to='lostplaces.place')),
|
||||||
('submitted_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='placeimages', to='lostplaces.explorer', verbose_name='Submitter')),
|
('submitted_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='placeimages', to='lostplaces.explorer')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'abstract': False,
|
'abstract': False,
|
||||||
@@ -73,11 +77,11 @@ class Migration(migrations.Migration):
|
|||||||
name='PhotoAlbum',
|
name='PhotoAlbum',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('submitted_when', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Submission date')),
|
('submitted_when', models.DateTimeField(auto_now_add=True, null=True)),
|
||||||
('url', models.URLField(verbose_name='URL')),
|
('url', models.URLField()),
|
||||||
('label', models.CharField(max_length=100, verbose_name='link text')),
|
('label', models.CharField(max_length=100)),
|
||||||
('place', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='photoalbums', to='lostplaces.place')),
|
('place', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='photoalbums', to='lostplaces.place')),
|
||||||
('submitted_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='photoalbums', to='lostplaces.explorer', verbose_name='Submitter')),
|
('submitted_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='photoalbums', to='lostplaces.explorer')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'abstract': False,
|
'abstract': False,
|
||||||
|
@@ -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'
|
||||||
|
)
|
||||||
|
]
|
25
django_lostplaces/lostplaces/migrations/0003_voucher.py
Normal file
25
django_lostplaces/lostplaces/migrations/0003_voucher.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Generated by Django 3.1.1 on 2020-10-04 19:52
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lostplaces', '0002_reomve_vouchers'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Voucher',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('created_when', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('expires_when', models.DateTimeField()),
|
||||||
|
('code', models.CharField(max_length=30, unique=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
@@ -14,6 +14,7 @@ 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):
|
||||||
"""
|
"""
|
||||||
@@ -27,6 +28,13 @@ 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
|
||||||
|
|
||||||
|
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 |
@@ -45,65 +45,63 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section class="LP-Section">
|
<section class="LP-Section">
|
||||||
<div class="LP-PlaceList">
|
<div class="LP-PlaceList">
|
||||||
<h1 class="LP-Headline">{% trans 'Places submitted by' %} {{explorer.user.username}}</h1>
|
<h1 class="LP-Headline">{% trans 'Places submitted by' %} {{explorer.user.username}}</h1>
|
||||||
<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 %}
|
</li>
|
||||||
</a>
|
{% endfor %}
|
||||||
</li>
|
</ul>
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{% include 'partials/nav/pagination.html' %}
|
{% include 'partials/nav/pagination.html' %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="LP-Section">
|
<section class="LP-Section">
|
||||||
<h1 class="LP-Headline">{% trans 'Images submitted by' %} {{explorer.user.username}}</h1>
|
<h1 class="LP-Headline">{% trans 'Images submitted by' %} {{explorer.user.username}}</h1>
|
||||||
<div class="LP-ImageGrid">
|
<div class="LP-ImageGrid">
|
||||||
<ul class="LP-ImageGrid__Container">
|
<ul class="LP-ImageGrid__Container">
|
||||||
{% for place_image in assets.placeimages.all %}
|
{% for place_image in assets.placeimages.all %}
|
||||||
<li class="LP-ImageGrid__Item">
|
<li class="LP-ImageGrid__Item">
|
||||||
<a href="{{ place_image.filename.large.url }}" class="LP-Link">
|
<a href="{{ place_image.filename.large.url }}" class="LP-Link">
|
||||||
<img class="LP-Image" src="{{ place_image.filename.thumbnail.url }}">
|
<img class="LP-Image" src="{{ place_image.filename.thumbnail.url }}">
|
||||||
</a>
|
</a>
|
||||||
{% if user.explorer == place_image.submitted_by%}
|
{% if user.explorer == place_image.submitted_by%}
|
||||||
<span class="LP-ImageGrid__DeleteItem" title="Bild löschen">
|
<span class="LP-ImageGrid__DeleteItem" title="Bild löschen">
|
||||||
<a href="{% url 'place_image_delete' pk=place_image.id %}" class="LP-Link">
|
<a href="{% url 'place_image_delete' pk=place_image.id %}" class="LP-Link">
|
||||||
<img class="LP-Icon" src="{% static 'icons/cancel.svg' %}" />
|
<img class="LP-Icon" src="{% static 'icons/cancel.svg' %}" />
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class=" LP-Section">
|
<section class=" LP-Section">
|
||||||
<h1 class="LP-Headline">{% trans 'Photo albums submitted by' %} {{explorer.user.username}}</h1>
|
<h1 class="LP-Headline">{% trans 'Photo albums submitted by' %} {{explorer.user.username}}</h1>
|
||||||
<div class="LP-LinkList">
|
<div class="LP-LinkList">
|
||||||
<ul class="LP-LinkList__Container">
|
<ul class="LP-LinkList__Container">
|
||||||
{% for photo_album in assets.photoalbums.all %}
|
{% for photo_album in assets.photoalbums.all %}
|
||||||
<li class="LP-LinkList__Item">
|
<li class="LP-LinkList__Item">
|
||||||
<a target="_blank" href="{{photo_album.url}}" class="LP-Link">
|
<a target="_blank" href="{{photo_album.url}}" class="LP-Link">
|
||||||
<span class="LP-Text">{{photo_album.label}}</span>
|
<span class="LP-Text">{{photo_album.label}}</span>
|
||||||
</a>
|
</a>
|
||||||
{% if user.explorer == photo_album.submitted_by%}
|
{% if user.explorer == photo_album.submitted_by%}
|
||||||
<a href="{% url 'photo_album_delete' pk=photo_album.pk%}" class="LP-Link LP-LinkList__ItemHover" title="Delete Photo Album">
|
<a href="{% url 'photo_album_delete' pk=photo_album.pk%}" class="LP-Link LP-LinkList__ItemHover" title="Delete Photo Album">
|
||||||
<div class="RV-Iconized__Container RV-Iconized__Container--small">
|
<div class="RV-Iconized__Container RV-Iconized__Container--small">
|
||||||
{% icon 'trash' className="RV-Iconized__Icon" %}
|
{% icon 'trash' className="RV-Iconized__Icon" %}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{% endblock maincontent %}
|
{% endblock maincontent %}
|
@@ -21,9 +21,7 @@
|
|||||||
<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>
|
||||||
|
@@ -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,13 +1,15 @@
|
|||||||
{%load static %}
|
{%load static %}
|
||||||
|
|
||||||
<article class="LP-PlaceTeaser {% if extended %} LP-PlaceTeaser--extended{% endif %}">
|
<article class="LP-PlaceTeaser {% if extended %} LP-PlaceTeaser--extended{% endif %}">
|
||||||
<div class="LP-PlaceTeaser__Image">
|
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||||
{% if place.placeimages.all|length > 0 %}
|
<div class="LP-PlaceTeaser__Image">
|
||||||
|
{% 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}}" />
|
||||||
{% else %}
|
{% else %}
|
||||||
<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">
|
||||||
@@ -20,15 +22,15 @@
|
|||||||
<div class="LP-PlaceTeaser__Description">
|
<div class="LP-PlaceTeaser__Description">
|
||||||
<p class="LP-Paragraph">
|
<p class="LP-Paragraph">
|
||||||
{% if place.description|length > 210 %}
|
{% if place.description|length > 210 %}
|
||||||
{{place.description|truncatechars:210|truncatewords:-1}}
|
{{place.description|truncatechars:210|truncatewords:-1}}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{place.description}}
|
{{place.description}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
</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"><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/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 }}</h1>
|
<h1 class="LP-Headline">{{ place.name }} {% include 'partials/icons/place_favorite.html' %}</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,9 +17,7 @@
|
|||||||
<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,6 +11,8 @@ from lostplaces.views import (
|
|||||||
PlaceDeleteView,
|
PlaceDeleteView,
|
||||||
PlaceTagDeleteView,
|
PlaceTagDeleteView,
|
||||||
PlaceTagSubmitView,
|
PlaceTagSubmitView,
|
||||||
|
PlaceFavoriteView,
|
||||||
|
PlaceUnfavoriteView,
|
||||||
PhotoAlbumCreateView,
|
PhotoAlbumCreateView,
|
||||||
PhotoAlbumDeleteView,
|
PhotoAlbumDeleteView,
|
||||||
PlaceImageCreateView,
|
PlaceImageCreateView,
|
||||||
@@ -36,5 +38,10 @@ 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')
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
@@ -119,3 +119,35 @@ 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