Using abstract modls
This commit is contained in:
parent
b52d96a55e
commit
cea3a909b5
@ -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
|
||||
|
@ -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)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user