Skip to content

Commit

Permalink
campaign detail view display None as - with gray background
Browse files Browse the repository at this point in the history
  • Loading branch information
Nik Sauer committed Jan 30, 2025
1 parent 7a5ed74 commit 8e0d299
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/campaign/templatetags/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def at(l, id):
@register.filter
def to_rgb(tup):
if tup is None:
return '80, 80, 80'
return '100, 100, 100'
return ','.join([str(x) for x in tup])
9 changes: 8 additions & 1 deletion app/campaign/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ def get_context_data(self, **kwargs):
room_current_values = {}
for room in campaign.rooms.all():
room_current_values[room.pk] = room_calculate_current_values(room)


print(room_current_values[room.pk])
# for better dispaying set alle values that are None to '- '
for i in range(0, len(room_current_values[room.pk]), 2):
if room_current_values[room.pk][i] is None:
room_current_values[room.pk][i] = '- '
print(room_current_values[room.pk])

context['room_current_values'] = room_current_values

return context
Expand Down
4 changes: 2 additions & 2 deletions app/main/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_current_mean(dimension):
current_tvoc = get_current_mean(Dimension.TVOC)
tvoc_color = Dimension.get_color(Dimension.TVOC, current_tvoc) if current_tvoc else None

return (
return [
current_temperature,
temperature_color,
current_pm2_5,
Expand All @@ -124,4 +124,4 @@ def get_current_mean(dimension):
co2_color,
current_tvoc,
tvoc_color
)
]

0 comments on commit 8e0d299

Please sign in to comment.