当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.query方法代码示例

本文整理汇总了Python中c3smembership.data.model.base.DBSession.query方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.query方法的具体用法?Python DBSession.query怎么用?Python DBSession.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在c3smembership.data.model.base.DBSession的用法示例。


在下文中一共展示了DBSession.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete_by_id

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
 def delete_by_id(cls, staff_id):
     """
     Delete one C3sStaff object by id.
     """
     row = DBSession.query(cls).filter(cls.id == staff_id).first()
     row.groups = []
     DBSession.query(cls).filter(cls.id == staff_id).delete()
开发者ID:C3S,项目名称:c3sMembership,代码行数:9,代码来源:staff.py

示例2: test_create

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def test_create(self):
        """
        Tests the ShareRepository.create method.
        """
        # pylint: disable=no-member
        member1 = DBSession.query(C3sMember).filter(
            C3sMember.membership_number == 'member1').first()
        self.assertEqual(member1.num_shares, 12 + 23)

        share_id = ShareRepository.create('member1', 25, date(2016, 4, 23))
        self.assertEqual(member1.num_shares, 12 + 23 + 25)
        self.assertEqual(len(member1.shares), 3)

        # pylint: disable=no-member
        shares = DBSession.query(Shares).filter(Shares.id == share_id).first()
        self.assertEqual(shares.number, 25)
        self.assertEqual(shares.date_of_acquisition, date(2016, 4, 23))
        self.assertEqual(shares.reference_code, None)
        self.assertEqual(shares.signature_received, False)
        self.assertEqual(shares.signature_received_date, date(1970, 1, 1))
        self.assertEqual(shares.signature_confirmed, False)
        self.assertEqual(shares.signature_confirmed_date, date(1970, 1, 1))
        self.assertEqual(shares.payment_received, False)
        self.assertEqual(shares.payment_received_date, date(1970, 1, 1))
        self.assertEqual(shares.payment_confirmed, False)
        self.assertEqual(shares.payment_confirmed_date, date(1970, 1, 1))
        self.assertEqual(shares.accountant_comment, None)
开发者ID:C3S,项目名称:c3sMembership,代码行数:29,代码来源:test_share_repository.py

示例3: test_get

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def test_get(self):
        """
        Tests the ShareRepository.get method.
        """
        # pylint: disable=no-member
        share = DBSession.query(Shares).filter(
            Shares.reference_code == u'share1').first()
        get_share = ShareRepository.get(share.id)
        self.assertEqual(get_share.id, share.id)

        # pylint: disable=no-member
        share = DBSession.query(Shares).filter(
            Shares.reference_code == u'share2').first()
        get_share = ShareRepository.get(share.id)
        self.assertEqual(get_share.id, share.id)

        # pylint: disable=no-member
        share = DBSession.query(Shares).filter(
            Shares.reference_code == u'share3').first()
        get_share = ShareRepository.get(share.id)
        self.assertEqual(get_share.id, share.id)

        # pylint: disable=no-member
        share = DBSession.query(Shares).filter(
            Shares.reference_code == u'share4').first()
        get_share = ShareRepository.get(share.id)
        self.assertEqual(get_share.id, share.id)
开发者ID:C3S,项目名称:c3sMembership,代码行数:29,代码来源:test_share_repository.py

示例4: delete

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def delete(cls, shares_id):
        """
        Deletes the shares package of the specified shares id.

        Args:
            shares_id: The technical primary key of the shares package to be
                deleted.
        """
        # pylint: disable=no-member
        DBSession.query(Shares).filter(Shares.id == shares_id).delete()
开发者ID:C3S,项目名称:c3sMembership,代码行数:12,代码来源:share_repository.py

示例5: create

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def create(cls, membership_number, shares_quantity,
               board_confirmation=None):
        """
        Create a shares package.

        Args:
            membership_number: The membership number of the member for which
                the shares package is created.
            shares_quantity: The number of shares of the package to be created.
            board_confirmation: Optional. The date on which the board of
                directors confirmed the acquisition of the shares package.

        Returns:
            The technical primary key of the created shares package.
        """
        shares = Shares(
            number=shares_quantity,
            date_of_acquisition=board_confirmation,
        )
        # pylint: disable=no-member
        member = DBSession.query(C3sMember).filter(
            C3sMember.membership_number == membership_number).first()
        # pylint: disable=no-member
        DBSession.add(shares)
        member.shares.append(shares)
        member.num_shares += shares_quantity
        DBSession.flush()
        return shares.id
开发者ID:C3S,项目名称:c3sMembership,代码行数:30,代码来源:share_repository.py

示例6: get_all

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def get_all(cls):
        """
        Get all C3sStaff objects from the database.

        Returns:
            list: list of C3sStaff objects.
        """
        return DBSession.query(cls).all()
开发者ID:C3S,项目名称:c3sMembership,代码行数:10,代码来源:staff.py

示例7: get_invitees

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def get_invitees(cls, general_assembly_number, invitees_count):
        """
        Gets a number of members which have not yet been invited to the general
        assembly.

        Queries the database for members, where:

        - members are members
        - members have not received their invitation email yet

        Args:
            general_assembly_number: Integer. The number of the general
                assembly for which the invitees are returned.
            invitees_count: Integer. Number of invitees returned at maximum.

        Returns:
            A list member objects.
        """
        # pylint: disable=no-member
        # In SqlAlchemy the True comparison must be done as "a == True" and not
        # in the python default way "a is True". Therefore:
        # pylint: disable=singleton-comparison
        return (
            # Get members
            DBSession.query(C3sMember)
            # combine with the general assembly requested as a cross join with
            # the one general assembly row
            .join(
                GeneralAssembly,
                GeneralAssembly.number == general_assembly_number)
            # combine them with invitations for this member to this general
            # assembly if any
            .outerjoin(
                GeneralAssemblyInvitation,
                and_(
                    C3sMember.id == GeneralAssemblyInvitation.member_id,
                    GeneralAssemblyInvitation.general_assembly_id ==
                    GeneralAssembly.id
                )
            )
            # but only
            .filter(
                and_(
                    # if no invitation has been sent
                    GeneralAssemblyInvitation.id == None,
                    # and the member has membership at the assmebly date
                    C3sMember.is_member_filter(GeneralAssembly.date),
                )
            )
            # get as many as requested
            .slice(0, invitees_count)
            # and get all of the actual records
            .all()
        )
开发者ID:C3S,项目名称:c3sMembership,代码行数:56,代码来源:general_assembly_repository.py

示例8: get_by_login

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def get_by_login(cls, login):
        """
        Get C3sStaff object by login.

        Args:
            login: the login of the C3sStaff object to be returned.

        Returns:
            * **object**: C3sStaff object with relevant login, if exists.
            * **None**: if login can't be found.
        """
        return DBSession.query(cls).filter(cls.login == login).first()
开发者ID:C3S,项目名称:c3sMembership,代码行数:14,代码来源:staff.py

示例9: get_by_id

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def get_by_id(cls, staff_id):
        """
        Get C3sStaff object by id.

        Args:
            id: the id of the C3sStaff object to be returned.

        Returns:
            * **object**: C3sStaff object with relevant id, if exists.
            * **None**: if id can't be found.
        """
        return DBSession.query(cls).filter(cls.id == staff_id).first()
开发者ID:C3S,项目名称:c3sMembership,代码行数:14,代码来源:staff.py

示例10: set_reference_code

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def set_reference_code(cls, shares_id, reference_code):
        """
        Sets the reference code of the shares package.

        Args:
            shares_id: The technical primary key of the shares package for
                which the payment confirmation is set.
            reference_code: The reference code which is set.
        """
        # pylint: disable=no-member
        shares = DBSession.query(Shares).filter(Shares.id == shares_id).first()
        shares.reference_code = reference_code
开发者ID:C3S,项目名称:c3sMembership,代码行数:14,代码来源:share_repository.py

示例11: get

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def get(cls, shares_id):
        """
        Gets the shares package for the specified shares id.

        Args:
            shares_id: The technical primary key of the shares package for
                which the payment confirmation is set.

        Returns:
            The shares package for the specified shares id.
        """
        # pylint: disable=no-member
        return DBSession.query(Shares).filter(Shares.id == shares_id).first()
开发者ID:C3S,项目名称:c3sMembership,代码行数:15,代码来源:share_repository.py

示例12: test_set_reference_code

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def test_set_reference_code(self):
        """
        Tests the ShareRepository.set_reference_code method.
        """
        # pylint: disable=no-member
        member1 = DBSession.query(C3sMember).filter(
            C3sMember.membership_number == 'member1').first()
        shares = member1.shares[0]

        ShareRepository.set_reference_code(shares.id, u'test_reference_code')
        self.assertEqual(shares.reference_code, u'test_reference_code')

        ShareRepository.set_reference_code(shares.id, None)
        self.assertEqual(shares.reference_code, None)
开发者ID:C3S,项目名称:c3sMembership,代码行数:16,代码来源:test_share_repository.py

示例13: get_member

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def get_member(cls, membership_number):
        """
        Gets the member of the specified membership number.

        Args:
            membership_number: The membership number of the member which is
                returned.

        Returns:
            The membership of the specified membership number.
        """
        # pylint: disable=no-member
        return DBSession.query(C3sMember).filter(
            C3sMember.membership_number == membership_number).first()
开发者ID:C3S,项目名称:c3sMembership,代码行数:16,代码来源:member_repository.py

示例14: get_member_by_token

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def get_member_by_token(cls, token):
        """
        Find a member by token used for GA and BarCamp

        This is needed when a user returns from reading her email
        and clicking on a link containing the token.

        Returns:
            object: C3sMember object
        """
        # pylint: disable=no-member
        return (
            DBSession.query(C3sMember)
            .join(GeneralAssemblyInvitation)
            .filter(GeneralAssemblyInvitation.token == token)
            .first()
        )
开发者ID:C3S,项目名称:c3sMembership,代码行数:19,代码来源:general_assembly_repository.py

示例15: _members_query

# 需要导入模块: from c3smembership.data.model.base import DBSession [as 别名]
# 或者: from c3smembership.data.model.base.DBSession import query [as 别名]
    def _members_query(cls, effective_date=None):
        """
        Gets the query to retrieve members accepted until and including the
        specified effective date.

        Args:
            effective_date: Optional. The date on which the membership has been
                accepted. If not specified system date is used as effective
                date.

        Returns:
            The query to retrieve members accepted until and including the
            specified effective date.
        """
        # pylint: disable=no-member
        return DBSession.query(C3sMember) \
            .filter(cls._is_member_filter(effective_date))
开发者ID:C3S,项目名称:c3sMembership,代码行数:19,代码来源:member_repository.py


注:本文中的c3smembership.data.model.base.DBSession.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。