Skip to content

Commit 1b32258

Browse files
learning nuggets: fix capitalization of role (#39)
1 parent 8475143 commit 1b32258

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

apps/learning_nuggets/templatetags/learning_nuggets_tags.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33

44
register = template.Library()
55

6+
67
@register.simple_tag
78
def get_first_nugget_image(nugget, rendition_spec):
89
"""
910
Gets the first image from a nugget's content StreamField
1011
"""
1112
for block in nugget.specific.content: # Make sure to use .specific
12-
if block.block_type == 'learning_nugget':
13+
if block.block_type == "learning_nugget":
1314
# Adjust this based on your actual block structure
14-
image = block.value.get('image') or block.value.get('thumbnail')
15+
image = block.value.get("image") or block.value.get("thumbnail")
1516
if image:
1617
return get_rendition_or_not_found(image, rendition_spec)
1718
return None
1819

20+
1921
@register.simple_tag
2022
def get_permission(permission_level):
2123
permissions = {
@@ -27,9 +29,8 @@ def get_permission(permission_level):
2729

2830

2931
@register.simple_tag
30-
def get_permission_display(permission_level):
31-
"""For display purposes only - returns capitalized version"""
32-
return permission_level.title()
32+
def get_permission_display(value):
33+
return value[0].upper() + value[1:] if value else value
3334

3435

3536
@register.filter(name="filter_by_block_type")

0 commit comments

Comments
 (0)