예제 #1
0
def get_allowed_apps_choices(user=None):
    """É o ``get_allowed_apps`` com retorno adaptado para o select html"""
    user = user or tl.get_user()
    if user is None:
        return []
    return [[app_label, app_name] for app_label, app_name in settings.APP_CONTENT_TYPES \
            if app_label in get_allowed_apps(user)]
예제 #2
0
def get_allowed_apps(user=None):
    """Se o usuário tiver alguma permissão de uma app, ela será permitida."""
    user = user or tl.get_user()
    if user is None:
        return []
    all_apps = [i[0] for i in settings.APP_CONTENT_TYPES]
    return [g.name.split('_')[0] for g in user.groups.all() if all_apps]