From 75bcc9103778b8c78e0a9e063339578db50b4040 Mon Sep 17 00:00:00 2001 From: reverend Date: Sun, 13 Sep 2020 14:39:21 +0200 Subject: [PATCH] Refactoring places images related name --- lostplaces/lostplaces_app/models.py | 31 ++++++++++++++++--- lostplaces/lostplaces_app/templates/home.html | 2 +- .../lostplaces_app/templates/home_unauth.html | 2 +- .../templates/place/place_detail.html | 6 ++-- .../templates/place/place_list.html | 2 +- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/lostplaces/lostplaces_app/models.py b/lostplaces/lostplaces_app/models.py index 27b60cc..c6b3ca1 100644 --- a/lostplaces/lostplaces_app/models.py +++ b/lostplaces/lostplaces_app/models.py @@ -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): diff --git a/lostplaces/lostplaces_app/templates/home.html b/lostplaces/lostplaces_app/templates/home.html index c16bd0e..c71bed0 100644 --- a/lostplaces/lostplaces_app/templates/home.html +++ b/lostplaces/lostplaces_app/templates/home.html @@ -23,7 +23,7 @@
- +