Added class comments, unified formatting.

This commit is contained in:
Marcus Scholz 2020-08-01 11:25:26 +02:00
parent 0fefaf66dd
commit a2412e88d2

View File

@ -26,6 +26,7 @@ class Place (models.Model):
"""
Place defines a lost place (location, name, description etc.).
"""
name = models.CharField(max_length=50)
submitted_by = models.ForeignKey(
Explorer,
@ -46,9 +47,15 @@ def generate_image_upload_path(instance, filename):
"""
Callback for generating path for uploaded images
"""
return 'places/' + str(uuid.uuid4())+'.'+filename.split('.')[-1]
class PlaceImage (models.Model):
"""
PlaceImage defines an image file object that points to a file in uploads/.
Intermediate image sizes are generated as defined in SIZES.
PlaceImage references a Place to which it belongs.
"""
SIZES=(
{'code': 'thumbnail', 'wxh': '390x390'},
@ -80,6 +87,7 @@ class PlaceImage (models.Model):
Returning the name of the corresponding place + id
of this image as textual represntation of this instance
"""
return ' '.join([self.place.name, str(self.pk)])
# These two auto-delete files from filesystem when they are unneeded: