From a2412e88d2bce8980e3ed9ff983e214688c1e065 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Sat, 1 Aug 2020 11:25:26 +0200 Subject: [PATCH] Added class comments, unified formatting. --- lostplaces/lostplaces_app/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lostplaces/lostplaces_app/models.py b/lostplaces/lostplaces_app/models.py index 43a69bd..11b8c2d 100644 --- a/lostplaces/lostplaces_app/models.py +++ b/lostplaces/lostplaces_app/models.py @@ -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: