<commit_before>from .utils import organization_manager
from .models import Organization


def organizations(request):
    """
    Add some generally useful metadata to the template context
    """
    # selected organization
    orga = organization_manager.get_selected_organization(request)

    # all user authorized organizations
    if not request.user or not request.user.is_authenticated():
        user_organizations = None
    else:
        user_organizations = request.user.organizations.all()

    return {
        'user_organizations': user_organizations,
        'selected_organization': orga,
    }
<commit_msg>Use owner or member filter for the dropdown<commit_after>from django.db.models import Q

from .utils import organization_manager
from .models import Organization


def organizations(request):
    """
    Add some generally useful metadata to the template context
    """
    # selected organization
    orga = organization_manager.get_selected_organization(request)

    # all user authorized organizations
    if not request.user or not request.user.is_authenticated():
        user_organizations = None
    else:
        user = request.user
        user_organizations = (Organization.objects
            .filter(Q(members=user) | Q(owner=user)))

    return {
        'user_organizations': user_organizations,
        'selected_organization': orga,
    }

{'fraction_non_alphanumeric': 0.07241129616220131, 'fraction_numerical': 0.0, 'mean_word_length': 3.3873015873015873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2547360', 'n_tokens_mistral': 354, 'n_tokens_neox': 340, 'n_words': 101}