Refactoring places images related name

This commit is contained in:
reverend 2020-09-13 14:39:21 +02:00
parent c78ff60231
commit 75bcc91037
5 changed files with 33 additions and 10 deletions

View File

@ -21,18 +21,24 @@ from taggit.managers import TaggableManager
# Create your models here.
class Taggable(models.Model):
'''
This abstract model represtens an object that is taggalble
using django-taggit
'''
class Meta:
abstract = True
tags = TaggableManager(blank=True)
class MapablePoint(models.Model):
'''
This abstract model class represents an object that can be
displayed on a map.
'''
class Meta:
abstract = True
name = models.CharField(max_length=50)
latitude = models.FloatField(
validators=[
MinValueValidator(-90),
@ -46,6 +52,23 @@ class MapablePoint(models.Model):
]
)
class Submittable(models.Model):
'''
This abstract model class represents an object that can be submitted by
an explorer.
'''
class Meta:
abstract = True
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
submitted_by = models.ForeignKey(
Explorer,
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name='%(class)s'
)
class Explorer(models.Model):
"""
Profile that is linked to the a User.
@ -147,7 +170,7 @@ class PlaceImage (models.Model):
place = models.ForeignKey(
Place,
on_delete=models.CASCADE,
related_name='images'
related_name='placeimages'
)
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
submitted_by = models.ForeignKey(
@ -155,7 +178,7 @@ class PlaceImage (models.Model):
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name='images'
related_name='placeimages'
)
def __str__(self):

View File

@ -23,7 +23,7 @@
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
<article class="LP-PlaceTeaser">
<div class="LP-PlaceTeaser__Image">
<img class="LP-Image" src="{{ place.images.first.filename.thumbnail.url}}" />
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url}}" />
</div>
<div class="LP-PlaceTeaser__Meta">
<div class="LP-PlaceTeaser__Info">

View File

@ -34,7 +34,7 @@
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
<article class="LP-PlaceTeaser">
<div class="LP-PlaceTeaser__Image">
<img class="LP-Image" src="{{ place.images.first.filename.thumbnail.url}}" />
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url}}" />
</div>
<div class="LP-PlaceTeaser__Meta">
<div class="LP-PlaceTeaser__Info">

View File

@ -23,9 +23,9 @@
<header class="LP-PlaceDetail__Header">
<h1 class="LP-Headline">{{ place.name }}</h1>
{% if place.images.first.filename.hero.url %}
{% if place.placeimages.first.filename.hero.url %}
<figure class="LP-PlaceDetail__Image">
<img src="{{ place.images.first.filename.hero.url }}" class="LP-Image" />
<img src="{{ place.placeimages.first.filename.hero.url }}" class="LP-Image" />
</figure>
{% endif %}
</header>
@ -92,7 +92,7 @@
<h1 class="LP-Headline">Bilder</h1>
<div class="LP-ImageGrid">
<ul class="LP-ImageGrid__Container">
{% for place_image in place.images.all %}
{% for place_image in place.placeimages.all %}
<li class="LP-ImageGrid__Item">
<a href="{{ place_image.filename.large.url }}" class="LP-Link"><img class="LP-Image" src="{{ place_image.filename.thumbnail.url }}"></a>
</li>

View File

@ -19,7 +19,7 @@
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
<article class="LP-PlaceTeaser LP-PlaceTeaser--extended">
<div class="LP-PlaceTeaser__Image">
<img class="LP-Image" src="{{ place.images.first.filename.thumbnail.url }}" />
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url }}" />
</div>
<div class="LP-PlaceTeaser__Meta">
<div class="LP-PlaceTeaser__Info">