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: