-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show username and group icons in navbar
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Various utility template tags for the BMA project.""" | ||
|
||
from django import template | ||
from django.conf import settings | ||
from django.template.context import RequestContext | ||
from django.utils.safestring import mark_safe | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag(takes_context=True) | ||
def get_group_icons( | ||
context: RequestContext, | ||
) -> str: | ||
"""Return icons representing group memberships.""" | ||
output = "" | ||
if settings.BMA_CREATOR_GROUP_NAME in context["request"].user.groups.values_list("name", flat=True): | ||
output += '<i class="fa-solid fa-user-ninja"></i> ' | ||
if settings.BMA_MODERATOR_GROUP_NAME in context["request"].user.groups.values_list("name", flat=True): | ||
output += '<i class="fa-solid fa-user-shield"></i> ' | ||
if settings.BMA_CURATOR_GROUP_NAME in context["request"].user.groups.values_list("name", flat=True): | ||
output += '<i class="fa-solid fa-user-astronaut"></i> ' | ||
return mark_safe(output) # noqa: S308 |