@register.simple_tag(takes_context=True)
def check_edit_index_permit(context):
    """
    Checks request.user for permission to EDIT DOCUMENT INDEX in MUI

    In fact he must be in search group in security.
    Set's up context variable 'index_permitted'
    it can be used farther in IF template compassion.
    """
    # Do nothing if context variable has already been set
    if 'edit_index_permitted' in context:
        return ''
    user = context['request'].user
    permission = False
    if not user.is_superuser:
        groups = user.groups.all()
        for group in groups:
            if group.name == SEC_GROUP_NAMES['edit_index']:
                permission = True
    else:
        permission = True
    context['edit_index_permitted'] = permission
    return ''
dataset/ETHPy150Open adlibre/Adlibre-DMS/adlibre_dms/apps/mdtui/templatetags/mui_permissions.py/check_edit_index_permit/original