コード例 #1
0
ファイル: test_mozillians.py プロジェクト: Nolski/airmozilla
    def test_in_groups(self, rget, rlogging):

        def mocked_get(url, **options):
            if 'peterbe' in url:
                return Response(IN_GROUPS)
            raise NotImplementedError(url)
        rget.side_effect = mocked_get

        ok_(not mozillians.in_groups('*****@*****.**', 'losers'))
        ok_(mozillians.in_groups('*****@*****.**', 'winners'))
        ok_(mozillians.in_groups('*****@*****.**', ['winners', 'losers']))
コード例 #2
0
ファイル: test_mozillians.py プロジェクト: mythmon/airmozilla
    def test_in_groups(self, rget, rlogging):
        def mocked_get(url, **options):
            if 'peterbe' in url:
                return Response(IN_GROUPS)
            raise NotImplementedError(url)

        rget.side_effect = mocked_get

        ok_(not mozillians.in_groups('*****@*****.**', 'losers'))
        ok_(mozillians.in_groups('*****@*****.**', 'winners'))
        ok_(mozillians.in_groups('*****@*****.**', ['winners', 'losers']))
コード例 #3
0
ファイル: views.py プロジェクト: LeoMcA/airmozilla
def can_view_event(event, user):
    """return True if the current user has right to view this event"""
    if event.privacy == Event.PRIVACY_PUBLIC:
        return True
    elif not user.is_active:
        return False

    # you're logged in
    if event.privacy == Event.PRIVACY_COMPANY:
        # but then it's not good enough to be contributor
        if is_contributor(user):
            return False
    else:
        if not is_contributor(user):
            # staff can always see it
            return True
        curated_groups = [
            x[0] for x in
            CuratedGroup.objects.filter(event=event).values_list('name')
        ]
        if curated_groups:
            return mozillians.in_groups(
                user.email,
                curated_groups
            )

    return True
コード例 #4
0
ファイル: utils.py プロジェクト: nehaummareddy/airmozilla
def can_edit_event(event, user, default='manage:events'):
    if (not user.has_perm('main.change_event_others')
            and user != event.creator):
        return redirect(default)
    if event.privacy == Event.PRIVACY_COMPANY and is_contributor(user):
        return redirect(default)
    elif (CuratedGroup.objects.filter(event=event) and is_contributor(user)):
        # Editing this event requires that you're also part of that curated
        # group.
        curated_group_names = [
            x[0] for x in CuratedGroup.objects.filter(
                event=event).values_list('name')
        ]
        if not mozillians.in_groups(user.email, curated_group_names):
            return redirect(default)
コード例 #5
0
ファイル: utils.py プロジェクト: EricSekyere/airmozilla
def can_edit_event(event, user, default='manage:events'):
    if (not user.has_perm('main.change_event_others') and
            user != event.creator):
        return redirect(default)
    if event.privacy == Event.PRIVACY_COMPANY and is_contributor(user):
        return redirect(default)
    elif (
        CuratedGroup.objects.filter(event=event) and is_contributor(user)
    ):
        # Editing this event requires that you're also part of that curated
        # group.
        curated_group_names = [
            x[0] for x in
            CuratedGroup.objects.filter(event=event).values_list('name')
        ]
        if not mozillians.in_groups(
            user.email,
            curated_group_names
        ):
            return redirect(default)
コード例 #6
0
def can_view_event(event, user):
    """return True if the current user has right to view this event"""
    if event.privacy == Event.PRIVACY_PUBLIC:
        return True
    elif not user.is_active:
        return False

    # you're logged in
    if event.privacy == Event.PRIVACY_COMPANY:
        # but then it's not good enough to be contributor
        if is_contributor(user):
            return False
    else:
        if not is_contributor(user):
            # staff can always see it
            return True
        curated_groups = [
            x[0] for x in CuratedGroup.objects.filter(
                event=event).values_list('name')
        ]
        if curated_groups:
            return mozillians.in_groups(user.email, curated_groups)

    return True