Skip to content
Snippets Groups Projects
Commit 86b28795 authored by Julian's avatar Julian
Browse files

Build a reusable avatar content snippet with a preference regarding the use of personal photos

parent b8ba0027
No related branches found
No related tags found
1 merge request!907Resolve "Feature: Account Menu in Top Navbar"
......@@ -403,6 +403,16 @@ class PersonChangeNotificationContact(StringPreference):
verbose_name = _("Contact for notification if a person changes their data")
@site_preferences_registry.register
class PersonPreferPhoto(BooleanPreference):
"""Preference, whether personal photos should be displayed instead of avatars."""
section = account
name = "person_prefer_photo"
default = False
verbose_name = _("Prefer personal photos over avatars")
@site_preferences_registry.register
class PDFFileExpirationDuration(IntegerPreference):
"""PDF file expiration duration."""
......
{% load rules i18n %}
{% has_perm 'core.view_avatar_rule' request.user person_or_user as can_view_avatar %}
{% has_perm 'core.view_photo_rule' request.user person_or_user as can_view_photo %}
{% if SITE_PREFERENCES.account__person_prefer_photo and person_or_user.photo and can_view_photo %}
<div class="{% firstof class "clip-circle" %}">
<img class="{% firstof img_class "hundred-percent" %}" src="{{ person_or_user.photo.url }}"
alt="{{ person_or_user.full_name }}" {% if title %} title="{{ person_or_user.full_name }}"{% endif %}/>
</div>
{% elif person_or_user.identicon_url %}
{# If this is a person #}
<div class="{% firstof class "clip-circle" %}">
{% if can_view_avatar %}
<img class="{% firstof img_class "hundred-percent" %}" src="{{ person_or_user.avatar_url }}"
alt="{{ person_or_user.full_name }} ({% trans "Avatar" %})" {% if title %}
title="{{ person_or_user.full_name }} ({% trans "Avatar" %})"{% endif %}/>
{% else %}
<img class="{% firstof img_class "hundred-percent" %}" src="{{ person_or_user.identicon_url }}"
alt="{{ person_or_user.full_name }} ({% trans "Identicon" %})" {% if title %}
title="{{ person_or_user.full_name }} ({% trans "Identicon" %})"{% endif %} />
{% endif %}
</div>
{% else %}
{# There is a user without a person #}
<div class="{% firstof class "clip-circle" %} no-image">
<i class="material-icons">person</i>
</div>
{% endif %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment