Skip to content

Commit b3f2c47

Browse files
committed
only return thumbnail if screenshot exists (fixes test run)
1 parent 8b0b79c commit b3f2c47

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

django/gsmap/models.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,19 @@ def test_exists(pk):
210210
super().save(*args, **kwargs)
211211

212212
def image_twitter(self):
213-
return get_thumbnail(
214-
self.screenshot, '1200x630',
215-
crop='bottom', format='PNG'
216-
)
213+
if bool(self.screenshot):
214+
return get_thumbnail(
215+
self.screenshot, '1200x630',
216+
crop='bottom', format='PNG'
217+
)
218+
return ''
217219

218220
def image_facebook(self):
219-
return get_thumbnail(
220-
self.screenshot, '1200x630',
221-
crop='bottom', format='PNG'
222-
)
221+
if bool(self.screenshot):
222+
return get_thumbnail(
223+
self.screenshot, '1200x630',
224+
crop='bottom', format='PNG'
225+
)
223226

224227
def __str__(self):
225228
if self.municipality:

0 commit comments

Comments
 (0)