diff --git a/lostplaces/lostplaces_app/models.py b/lostplaces/lostplaces_app/models.py index 6f95679..c5a9b70 100644 --- a/lostplaces/lostplaces_app/models.py +++ b/lostplaces/lostplaces_app/models.py @@ -109,19 +109,11 @@ class Voucher(models.Model): return "Voucher " + str(self.code) -class Place(Taggable, MapablePoint): +class Place(Submittable, Taggable, MapablePoint): """ Place defines a lost place (location, name, description etc.). """ - - 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='places' - ) + location = models.CharField(max_length=50) description = models.TextField() @@ -157,7 +149,7 @@ def generate_image_upload_path(instance, filename): return 'places/' + str(uuid.uuid4())+'.'+filename.split('.')[-1] -class PlaceImage (models.Model): +class PlaceImage (Submittable): """ PlaceImage defines an image file object that points to a file in uploads/. Intermediate image sizes are generated as defined in SIZES. @@ -171,15 +163,7 @@ class PlaceImage (models.Model): on_delete=models.CASCADE, related_name='placeimages' ) - 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='placeimages' - ) - + def __str__(self): """ Returning the name of the corresponding place + id diff --git a/lostplaces/lostplaces_app/tests/models/test_abstract_models.py b/lostplaces/lostplaces_app/tests/models/test_abstract_models.py index 311b989..27195e0 100644 --- a/lostplaces/lostplaces_app/tests/models/test_abstract_models.py +++ b/lostplaces/lostplaces_app/tests/models/test_abstract_models.py @@ -84,7 +84,7 @@ class SubmittableTestCase(ModelTestCase): ) self.assertEqual( submitted_by.remote_field.on_delete, - models.SET_NULL + models.SET_NULL, msg='Expecting %s to be null when reference is delete (models.SET_NULL)' % ( str(submitted_by) )