Compare commits
No commits in common. "21217b067fd17cd0b3c78791904e93b9f943dd19" and "b0e775d299c55ed820745f0b486eae255f9155a8" have entirely different histories.
21217b067f
...
b0e775d299
@ -131,15 +131,9 @@ USE_TZ = True
|
|||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
|
||||||
|
|
||||||
# Upload directory
|
|
||||||
MEDIA_URL = '/uploads/'
|
MEDIA_URL = '/uploads/'
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
|
||||||
|
|
||||||
# Thumbnails
|
|
||||||
THUMBNAIL_MEDIA_ROOT = os.path.join(MEDIA_ROOT, 'thumbs/')
|
|
||||||
THUMBNAIL_MEDIA_URL = os.path.join(MEDIA_URL, 'thumbs/')
|
|
||||||
THUMBNAIL_QUALITY = 75
|
|
||||||
|
|
||||||
# Templates to use for authentication
|
# Templates to use for authentication
|
||||||
LOGIN_URL = reverse_lazy('login')
|
LOGIN_URL = reverse_lazy('login')
|
||||||
LOGIN_REDIRECT_URL = reverse_lazy('lostplaces_home')
|
LOGIN_REDIRECT_URL = reverse_lazy('lostplaces_home')
|
||||||
|
@ -4,8 +4,8 @@ from django.conf import settings
|
|||||||
|
|
||||||
settings.THUMBNAIL_ALIASES = {
|
settings.THUMBNAIL_ALIASES = {
|
||||||
'': {
|
'': {
|
||||||
'thumbnail': {'size': (300, 200), 'sharpen': True, 'crop': True},
|
'thumbnail': {'size': (300, 200), 'crop': True},
|
||||||
'hero': {'size': (700, 466), 'sharpen': True, 'crop': True},
|
'hero': {'size': (700, 466), 'crop': True},
|
||||||
'large': {'size': (1920, 1920), 'sharpen': True, 'crop': False},
|
'large': {'size': (1920, 1920), 'crop': False},
|
||||||
},
|
},
|
||||||
}
|
}
|
@ -144,25 +144,20 @@ class Place(Submittable, Taggable, Mapable):
|
|||||||
def generate_image_upload_path(instance, filename):
|
def generate_image_upload_path(instance, filename):
|
||||||
"""
|
"""
|
||||||
Callback for generating path for uploaded images.
|
Callback for generating path for uploaded images.
|
||||||
Returns filename as: placepk-placename{-rndstring}.jpg
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return 'places/' + str(instance.place.pk) + '-' + str(instance.place.name) + '.' + filename.split('.')[-1]
|
return 'places/' + str(uuid.uuid4())+'.'+filename.split('.')[-1]
|
||||||
|
|
||||||
|
|
||||||
class PlaceImage (Submittable):
|
class PlaceImage (Submittable):
|
||||||
"""
|
"""
|
||||||
PlaceImage defines an image file object that points to a file in uploads/.
|
PlaceImage defines an image file object that points to a file in uploads/.
|
||||||
Intermediate image sizes are generated as defined in THUMBNAIL_ALIASES.
|
Intermediate image sizes are generated as defined in SIZES.
|
||||||
PlaceImage references a Place to which it belongs.
|
PlaceImage references a Place to which it belongs.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
description = models.TextField(blank=True)
|
description = models.TextField(blank=True)
|
||||||
filename = ThumbnailerImageField(
|
filename = ThumbnailerImageField(upload_to=generate_image_upload_path)
|
||||||
upload_to=generate_image_upload_path,
|
|
||||||
resize_source=dict(size=(2560, 2560),
|
|
||||||
sharpen=True)
|
|
||||||
)
|
|
||||||
place = models.ForeignKey(
|
place = models.ForeignKey(
|
||||||
Place,
|
Place,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
|
Loading…
Reference in New Issue
Block a user