Skip to content

Commit

Permalink
Fix widget for None icon_url values
Browse files Browse the repository at this point in the history
  • Loading branch information
erick-otenyo committed Mar 15, 2024
1 parent 64262fa commit e949370
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions forecastmanager/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from wagtail.utils.widgets import WidgetWithScript
from wagtail.widget_adapters import WidgetAdapter

from forecastmanager.constants import WEATHER_CONDITION_CHOICES, WEATHER_CONDITION_ICONS
from forecastmanager.constants import WEATHER_CONDITION_ICONS


class WeatherSymbolChooserWidget(WidgetWithScript, widgets.TextInput):
Expand All @@ -22,7 +22,8 @@ def __init__(self, attrs=None):

def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs)
context["widget"]["icon_url"] = static("forecastmanager/weathericons/{0}.png".format(value))
if value:
context["widget"]["icon_url"] = static("forecastmanager/weathericons/{0}.png".format(value))
return context

def render_js_init(self, id_, name, value):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = forecastmanager
version = 0.4.1
version = 0.4.2
description = Integration of Weather City Forecasts Manager in Wagtail Projects.
long_description = file:README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit e949370

Please sign in to comment.