File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
apps/learning_nuggets/templatetags Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 33
44register = template .Library ()
55
6+
67@register .simple_tag
78def 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
2022def 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" )
You can’t perform that action at this time.
0 commit comments