mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-11 08:43:10 +00:00
Move avatar tag into wagtailadmin_tags
This commit is contained in:
parent
5b8ca7d7e7
commit
ff6ca55b12
12 changed files with 21 additions and 29 deletions
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load avatar i18n %}
|
||||
{% load wagtailadmin_tags i18n %}
|
||||
|
||||
{% block titletag %}{% trans "Change profile picture" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load avatar staticfiles i18n %}
|
||||
{% load wagtailadmin_tags staticfiles i18n %}
|
||||
{% block titletag %}{% trans "Dashboard" %}{% endblock %}
|
||||
{% block bodyclass %}homepage{% endblock %}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load wagtailadmin_tags %}
|
||||
{% load avatar %}
|
||||
{% load i18n %}
|
||||
{% load l10n %}
|
||||
{% block titletag %}{% blocktrans with title=page.get_admin_display_title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }}: {{ title }}{% endblocktrans %}{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% load i18n wagtailadmin_tags avatar %}
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
{% load l10n %}
|
||||
|
||||
<table class="listing">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% load avatar wagtailadmin_tags %}
|
||||
{% load wagtailadmin_tags %}
|
||||
{% load i18n %}
|
||||
<nav class="nav-main">
|
||||
<ul>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% load avatar %}
|
||||
{% load wagtailadmin_tags %}
|
||||
|
||||
<span class="avatar small">
|
||||
<img src="{% avatar_url user size=25 %}" />
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django import template
|
||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def avatar_url(context, user, size=50):
|
||||
"""
|
||||
A template tag that receives a user and size and return
|
||||
the appropiate avatar url for that user.
|
||||
Example usage: {% avatar_url request.user 50 %}
|
||||
"""
|
||||
|
||||
if hasattr(user, 'wagtail_userprofile'): # A user could not have profile yet, so this is necessay
|
||||
return user.wagtail_userprofile.get_avatar_url(size=size)
|
||||
return static('wagtailadmin/images/default-user-avatar.svg')
|
||||
|
|
@ -5,6 +5,7 @@ from django.conf import settings
|
|||
from django.contrib.admin.utils import quote
|
||||
from django.contrib.humanize.templatetags.humanize import intcomma
|
||||
from django.contrib.messages.constants import DEFAULT_TAGS as MESSAGE_TAGS
|
||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||
from django.template.defaultfilters import stringfilter
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.html import conditional_escape
|
||||
|
|
@ -371,3 +372,16 @@ def _abs(val):
|
|||
@register.filter
|
||||
def admin_urlquote(value):
|
||||
return quote(value)
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=True)
|
||||
def avatar_url(context, user, size=50):
|
||||
"""
|
||||
A template tag that receives a user and size and return
|
||||
the appropiate avatar url for that user.
|
||||
Example usage: {% avatar_url request.user 50 %}
|
||||
"""
|
||||
|
||||
if hasattr(user, 'wagtail_userprofile'): # A user could not have profile yet, so this is necessary
|
||||
return user.wagtail_userprofile.get_avatar_url(size=size)
|
||||
return static('wagtailadmin/images/default-user-avatar.svg')
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load wagtailadmin_tags i18n staticfiles avatar %}
|
||||
{% load wagtailadmin_tags i18n staticfiles %}
|
||||
|
||||
{% block extra_css %}
|
||||
{{ block.super }}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load avatar %}
|
||||
{% block titletag %}{% trans "groups" %}{% endblock %}
|
||||
{% block extra_js %}
|
||||
{{ block.super }}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load avatar %}
|
||||
{% block titletag %}{% trans "Users" %}{% endblock %}
|
||||
{% block extra_js %}
|
||||
{{ block.super }}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
{% load i18n wagtailusers_tags %}
|
||||
{% load avatar %}
|
||||
{% load i18n wagtailusers_tags wagtailadmin_tags %}
|
||||
<table class="listing">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
|||
Loading…
Reference in a new issue