Skip to content

Commit

Permalink
[#3656] Fix broken default logo image
Browse files Browse the repository at this point in the history
If you go to the sysadmin config page, and if you don't change the logo image and just click Update, the logo image will break.
The reason is because its been given wrong path to the image.
  • Loading branch information
Aleksandar Jovanov authored and tino097 committed Dec 10, 2018
1 parent 6913a18 commit eb42425
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions ckan/logic/action/update.py
Expand Up @@ -7,6 +7,7 @@
import time
import json
import mimetypes
import os

from ckan.common import config
import paste.deploy.converters as converters
Expand Down Expand Up @@ -1274,11 +1275,25 @@ def config_option_update(context, data_dict):
model.Session.rollback()
raise ValidationError(errors)

image_in_ckan = False
ckan_images_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
'..', '..', 'public', 'base', 'images'))

for key, value in data.iteritems():

# Set full Logo url
if key =='ckan.site_logo' and value and not value.startswith('http'):
value = h.url_for_static('uploads/admin/{0}'.format(value))
if key == 'ckan.site_logo' and value and not value.startswith('http'):
for f in os.listdir(ckan_images_path):
if f == value:
image_in_ckan = True
break

if image_in_ckan:
image_path = 'base/images/'
else:
image_path = 'uploads/admin/'

value = h.url_for_static('{0}{1}'.format(image_path, value))

# Save value in database
model.set_system_info(key, value)
Expand Down

0 comments on commit eb42425

Please sign in to comment.