Refactoring places images related name
This commit is contained in:
parent
c78ff60231
commit
75bcc91037
@ -21,18 +21,24 @@ from taggit.managers import TaggableManager
|
|||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
class Taggable(models.Model):
|
class Taggable(models.Model):
|
||||||
|
'''
|
||||||
|
This abstract model represtens an object that is taggalble
|
||||||
|
using django-taggit
|
||||||
|
'''
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
tags = TaggableManager(blank=True)
|
tags = TaggableManager(blank=True)
|
||||||
|
|
||||||
class MapablePoint(models.Model):
|
class MapablePoint(models.Model):
|
||||||
|
'''
|
||||||
|
This abstract model class represents an object that can be
|
||||||
|
displayed on a map.
|
||||||
|
'''
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
|
|
||||||
latitude = models.FloatField(
|
latitude = models.FloatField(
|
||||||
validators=[
|
validators=[
|
||||||
MinValueValidator(-90),
|
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):
|
class Explorer(models.Model):
|
||||||
"""
|
"""
|
||||||
Profile that is linked to the a User.
|
Profile that is linked to the a User.
|
||||||
@ -147,7 +170,7 @@ class PlaceImage (models.Model):
|
|||||||
place = models.ForeignKey(
|
place = models.ForeignKey(
|
||||||
Place,
|
Place,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
related_name='images'
|
related_name='placeimages'
|
||||||
)
|
)
|
||||||
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
|
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
|
||||||
submitted_by = models.ForeignKey(
|
submitted_by = models.ForeignKey(
|
||||||
@ -155,7 +178,7 @@ class PlaceImage (models.Model):
|
|||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
related_name='images'
|
related_name='placeimages'
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||||
<article class="LP-PlaceTeaser">
|
<article class="LP-PlaceTeaser">
|
||||||
<div class="LP-PlaceTeaser__Image">
|
<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>
|
||||||
<div class="LP-PlaceTeaser__Meta">
|
<div class="LP-PlaceTeaser__Meta">
|
||||||
<div class="LP-PlaceTeaser__Info">
|
<div class="LP-PlaceTeaser__Info">
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||||
<article class="LP-PlaceTeaser">
|
<article class="LP-PlaceTeaser">
|
||||||
<div class="LP-PlaceTeaser__Image">
|
<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>
|
||||||
<div class="LP-PlaceTeaser__Meta">
|
<div class="LP-PlaceTeaser__Meta">
|
||||||
<div class="LP-PlaceTeaser__Info">
|
<div class="LP-PlaceTeaser__Info">
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
|
|
||||||
<header class="LP-PlaceDetail__Header">
|
<header class="LP-PlaceDetail__Header">
|
||||||
<h1 class="LP-Headline">{{ place.name }}</h1>
|
<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">
|
<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>
|
</figure>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</header>
|
</header>
|
||||||
@ -92,7 +92,7 @@
|
|||||||
<h1 class="LP-Headline">Bilder</h1>
|
<h1 class="LP-Headline">Bilder</h1>
|
||||||
<div class="LP-ImageGrid">
|
<div class="LP-ImageGrid">
|
||||||
<ul class="LP-ImageGrid__Container">
|
<ul class="LP-ImageGrid__Container">
|
||||||
{% for place_image in place.images.all %}
|
{% for place_image in place.placeimages.all %}
|
||||||
<li class="LP-ImageGrid__Item">
|
<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>
|
<a href="{{ place_image.filename.large.url }}" class="LP-Link"><img class="LP-Image" src="{{ place_image.filename.thumbnail.url }}"></a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||||
<article class="LP-PlaceTeaser LP-PlaceTeaser--extended">
|
<article class="LP-PlaceTeaser LP-PlaceTeaser--extended">
|
||||||
<div class="LP-PlaceTeaser__Image">
|
<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>
|
||||||
<div class="LP-PlaceTeaser__Meta">
|
<div class="LP-PlaceTeaser__Meta">
|
||||||
<div class="LP-PlaceTeaser__Info">
|
<div class="LP-PlaceTeaser__Info">
|
||||||
|
Loading…
Reference in New Issue
Block a user