mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
Smallest/Fastest/Easiest/Least Invasive way to get custom templates
This commit is contained in:
parent
5460094085
commit
0f492e3bf4
3 changed files with 18 additions and 4 deletions
|
|
@ -31,6 +31,9 @@ class AvatarConf(AppConf):
|
|||
FACEBOOK_GET_ID = None
|
||||
CACHE_ENABLED = True
|
||||
RANDOMIZE_HASHES = False
|
||||
ADD_TEMPLATE = ''
|
||||
CHANGE_TEMPLATE = ''
|
||||
DELETE_TEMPLATE = ''
|
||||
|
||||
def configure_auto_generate_avatar_sizes(self, value):
|
||||
return value or getattr(settings, 'AVATAR_AUTO_GENERATE_SIZES',
|
||||
|
|
|
|||
|
|
@ -80,7 +80,8 @@ def add(request, extra_context=None, next_override=None,
|
|||
'next': next_override or _get_next(request),
|
||||
}
|
||||
context.update(extra_context)
|
||||
return render(request, 'avatar/add.html', context)
|
||||
template_name = settings.AVATAR_ADD_TEMPLATE or 'avatar/add.html'
|
||||
return render(request, template_name, context)
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
@ -120,7 +121,8 @@ def change(request, extra_context=None, next_override=None,
|
|||
'next': next_override or _get_next(request)
|
||||
}
|
||||
context.update(extra_context)
|
||||
return render(request, 'avatar/change.html', context)
|
||||
template_name = settings.AVATAR_CHANGE_TEMPLATE or 'avatar/change.html'
|
||||
return render(request, template_name, context)
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
@ -155,8 +157,8 @@ def delete(request, extra_context=None, next_override=None, *args, **kwargs):
|
|||
'next': next_override or _get_next(request),
|
||||
}
|
||||
context.update(extra_context)
|
||||
|
||||
return render(request, 'avatar/confirm_delete.html', context)
|
||||
template_name = settings.AVATAR_DELETE_TEMPLATE or 'avatar/confirm_delete.html'
|
||||
return render(request, template_name, context)
|
||||
|
||||
|
||||
def render_primary(request, user=None, size=settings.AVATAR_DEFAULT_SIZE):
|
||||
|
|
|
|||
|
|
@ -170,6 +170,15 @@ AVATAR_STORAGE_DIR
|
|||
non-filesystem storage device, this will simply be appended to the beginning
|
||||
of the file name. Defaults to ``avatars``.
|
||||
|
||||
AVATAR_ADD_TEMPLATE
|
||||
Path to the Django template to use for adding a new avatar. Defaults to ``avatar/add.html``.
|
||||
|
||||
AVATAR_CHANGE_TEMPLATE
|
||||
Path to the Django template to use for changing a user's avatar. Defaults to ``avatar/change.html``.
|
||||
|
||||
AVATAR_DELETE_TEMPLATE
|
||||
Path to the Django template to use for confirming a delete of a user's avatar. Defaults to ``avatar/avatar/confirm_delete.html``.
|
||||
|
||||
Management Commands
|
||||
-------------------
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue