コード例 #1
0
ファイル: test_close.py プロジェクト: flashcode/liberapay.com
    def test_epi_clears_communities(self):
        alice = self.make_participant('alice')
        c = alice.create_community('test')
        alice.upsert_community_membership(True, c.id)
        bob = self.make_participant('bob')
        bob.upsert_community_membership(True, c.id)

        assert Community.from_name('test').nmembers == 2  # sanity check

        alice.erase_personal_information()

        assert Community.from_name('test').nmembers == 1
コード例 #2
0
ファイル: test_close.py プロジェクト: liberapay/liberapay.com
    def test_epi_clears_communities(self):
        alice = self.make_participant('alice')
        c = alice.create_community('test')
        alice.upsert_community_membership(True, c.id)
        bob = self.make_participant('bob')
        bob.upsert_community_membership(True, c.id)

        assert Community.from_name('test').nmembers == 2  # sanity check

        alice.erase_personal_information()

        assert Community.from_name('test').nmembers == 1
コード例 #3
0
ファイル: test_close.py プロジェクト: Changaco/liberapay.com
    def test_cpi_clears_communities(self):
        alice = self.make_participant('alice')
        alice.insert_into_communities(True, 'test', 'test')
        bob = self.make_participant('bob')
        bob.insert_into_communities(True, 'test', 'test')

        assert Community.from_slug('test').nmembers == 2  # sanity check

        with self.db.get_cursor() as cursor:
            alice.clear_personal_information(cursor)

        assert Community.from_slug('test').nmembers == 1
コード例 #4
0
ファイル: test_close.py プロジェクト: astiob/liberapay.com
    def test_cpi_clears_communities(self):
        alice = self.make_participant('alice')
        c = alice.create_community('test')
        alice.update_community_status('memberships', True, c.id)
        bob = self.make_participant('bob')
        bob.update_community_status('memberships', True, c.id)

        assert Community.from_name('test').nmembers == 2  # sanity check

        with self.db.get_cursor() as cursor:
            alice.clear_personal_information(cursor)

        assert Community.from_name('test').nmembers == 1
コード例 #5
0
ファイル: __init__.py プロジェクト: YarmoM/liberapay.com
def get_community(state, restrict=False):
    request, response = state['request'], state['response']
    user = state['user']
    name = request.path['name']

    c = Community.from_name(name)
    if request.method in SAFE_METHODS:
        if not c:
            response.redirect('/for/new?name=' + urlquote(name))
        if c.name != name:
            response.redirect('/for/' + c.name +
                              request.line.uri.decoded[5 + len(name):])
    elif not c:
        raise response.error(404)
    elif user.ANON:
        raise AuthRequired

    if restrict:
        if user.ANON:
            raise LoginRequired
        if user.id != c.creator:
            if user.is_admin:
                log_admin_request(user, c.participant, request)
            else:
                _ = state['_']
                raise response.error(
                    403, _("You are not authorized to access this page."))

    return c
コード例 #6
0
ファイル: __init__.py プロジェクト: notbandali/liberapay.com
def get_community(state, restrict=False):
    request, response = state['request'], state['response']
    user = state['user']
    name = request.path['name']

    c = Community.from_name(name)
    if request.method in ('GET', 'HEAD'):
        if not c:
            response.redirect('/for/new?name=' + urlquote(name))
        if c.name != name:
            response.redirect('/for/' + c.name +
                              request.line.uri[5 + len(name):])
    elif not c:
        raise response.error(404)
    elif user.ANON:
        raise AuthRequired

    if restrict:
        if user.ANON:
            raise LoginRequired
        if user.id != c.creator and not user.is_admin:
            _ = state['_']
            raise response.error(
                403, _("You are not authorized to access this page."))

    return c
コード例 #7
0
ファイル: __init__.py プロジェクト: liberapay/liberapay.com
def get_community(state, restrict=False):
    request, response = state['request'], state['response']
    user = state['user']
    name = request.path['name']

    c = Community.from_name(name)
    if request.method in ('GET', 'HEAD'):
        if not c:
            response.redirect('/for/new?name=' + urlquote(name))
        if c.name != name:
            response.redirect('/for/' + c.name + request.line.uri.decoded[5+len(name):])
    elif not c:
        raise response.error(404)
    elif user.ANON:
        raise AuthRequired

    if restrict:
        if user.ANON:
            raise LoginRequired
        if user.id != c.creator:
            if user.is_admin:
                log_admin_request(user, c.participant, request)
            else:
                _ = state['_']
                raise response.error(403, _("You are not authorized to access this page."))

    return c
コード例 #8
0
def get_community(state, restrict=False):
    request, response = state['request'], state['response']
    user = state['user']
    name = request.path['name']

    c = Community.from_name(name)
    if not c:
        raise response.error(404)
    if request.method in SAFE_METHODS:
        if c.name != name:
            response.redirect('/for/' + c.name +
                              request.line.uri.decoded[5 + len(name):])
    elif user.ANON:
        raise AuthRequired
    else:
        user.require_write_permission()

    is_spam = c.participant.marked_as == 'spam'
    if (restrict or is_spam):
        if user.id == c.creator:
            pass
        elif user.is_acting_as('admin'):
            log_admin_request(user, c.participant, request)
        elif restrict:
            if user.ANON:
                raise LoginRequired
            else:
                _ = state['_']
                raise response.error(
                    403, _("You are not authorized to access this page."))
        elif is_spam:
            raise response.render('simplates/spam-profile.spt', state)

    return c
コード例 #9
0
    def test_joining_and_leaving_community(self):
        response = self.client.POST('/alice/communities.json',
                                    {'do': 'join:Test'},
                                    auth_as=self.alice,
                                    xhr=True)

        r = json.loads(response.body)
        assert r['slug'] == 'test'

        response = self.client.POST('/alice/communities.json',
                                    {'do': 'leave:Test'},
                                    auth_as=self.alice,
                                    xhr=True)

        response = self.client.GET('/alice/communities.json',
                                   auth_as=self.alice)

        assert len(json.loads(response.body)) == 0

        # Check that the empty community was deleted
        community = Community.from_slug('test')
        assert not community
コード例 #10
0
    def test_joining_and_leaving_community(self):
        response = self.client.POST( '/alice/communities.json'
                                   , {'do': 'join:Test'}
                                   , auth_as=self.alice
                                   , xhr=True
                                    )

        r = json.loads(response.body)
        assert r['slug'] == 'test'

        response = self.client.POST( '/alice/communities.json'
                                   , {'do': 'leave:Test'}
                                   , auth_as=self.alice
                                   , xhr=True
                                    )

        response = self.client.GET('/alice/communities.json', auth_as=self.alice)

        assert len(json.loads(response.body)) == 0

        # Check that the empty community was deleted
        community = Community.from_slug('test')
        assert not community
コード例 #11
0
 def setUp(self):
     Harness.setUp(self)
     self.alice = self.make_participant("alice")
     self.bob = self.make_participant("bob")
     self.community = Community.create('test', self.alice)
コード例 #12
0
 def test_basic_search_with_results(self):
     alice = self.make_participant('alice')
     Community.create('alice', alice)
     response = self.client.GET('/search?q=alice')
     assert response.code == 200
コード例 #13
0
 def setUp(self):
     Harness.setUp(self)
     self.alice = self.make_participant("alice")
     self.bob = self.make_participant("bob")
     self.community = Community.create('test', self.alice.id)
コード例 #14
0
 def test_basic_search_with_results(self):
     alice = self.make_participant('alice')
     Community.create('alice', alice.id)
     response = self.client.GET('/search?q=alice')
     assert response.code == 200