# -*- coding: utf-8 -*-

from django import template

from admin_interface.models import Theme


register = template.Library()


@register.assignment_tag(takes_context = True)
def get_admin_interface_theme(context):

    theme = None
    request = context.get('request', None)

    if request:
        theme = getattr(request, 'admin_interface_theme', None)

    if not theme:
        theme = Theme.get_active_theme()

    if request:
        request.admin_interface_theme = theme

    return theme


# -*- coding: utf-8 -*-

from django import template

from admin_interface.models import Theme


register = template.Library()


@register.simple_tag(takes_context = True)
def get_admin_interface_theme(context):

    theme = None
    request = context.get('request', None)

    if request:
        theme = getattr(request, 'admin_interface_theme', None)

    if not theme:
        theme = Theme.get_active_theme()

    if request:
        request.admin_interface_theme = theme

    return theme


Fix a Django deprecation warning
Fix a Django deprecation warning

Replace deprecated assignment_tag:

`python/lib/python3.5/site-packages/admin_interface/templatetags/admin_interface_tags.py:11: RemovedInDjango20Warning: assignment_tag() is deprecated. Use simple_tag() instead`
