예제 #1
0
def test_get_database_table(data_fixture):
    user = data_fixture.create_user()
    table = data_fixture.create_database_table(user=user)
    table_2 = data_fixture.create_database_table()
    handler = TableHandler()

    with pytest.raises(UserNotInGroupError):
        handler.get_table(user=user, table_id=table_2.id)

    with pytest.raises(TableDoesNotExist):
        handler.get_table(user=user, table_id=99999)

    table_copy = handler.get_table(user=user, table_id=table.id)
    assert table_copy.id == table.id
예제 #2
0
    def can_add(self, user, web_socket_id, table_id, **kwargs):
        """
        The user should only have access to this page if the table exists and if he
        has access to the table.
        """

        if not table_id:
            return False

        try:
            handler = TableHandler()
            handler.get_table(user, table_id)
        except (UserNotInGroupError, TableDoesNotExist):
            return False

        return True
예제 #3
0
def test_get_database_table(data_fixture):
    user = data_fixture.create_user()
    table = data_fixture.create_database_table(user=user)
    data_fixture.create_database_table()
    handler = TableHandler()

    with pytest.raises(TableDoesNotExist):
        handler.get_table(table_id=99999)

    # If the error is raised we know for sure that the base query has resolved.
    with pytest.raises(AttributeError):
        handler.get_table(
            table_id=table.id,
            base_queryset=Table.objects.prefetch_related("UNKNOWN"))

    table_copy = handler.get_table(table_id=table.id)
    assert table_copy.id == table.id
예제 #4
0
파일: pages.py 프로젝트: jbjuin/baserow
    def can_add(self, user, web_socket_id, table_id, **kwargs):
        """
        The user should only have access to this page if the table exists and if he
        has access to the table.
        """

        if not table_id:
            return False

        try:
            handler = TableHandler()
            table = handler.get_table(table_id)
            table.database.group.has_user(user, raise_error=True)
        except (UserNotInGroup, TableDoesNotExist):
            return False

        return True