Coverage for polar/models/trial_redemption.py: 91%
21 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 15:52 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 15:52 +0000
1from typing import TYPE_CHECKING 1ab
2from uuid import UUID 1ab
4from sqlalchemy import ForeignKey, String, Uuid 1ab
5from sqlalchemy.ext.associationproxy import AssociationProxy, association_proxy 1ab
6from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship 1ab
8from polar.kit.db.models import RecordModel 1ab
10if TYPE_CHECKING: 10 ↛ 11line 10 didn't jump to line 11 because the condition on line 10 was never true1ab
11 from polar.models import Customer, Organization, Product
14class TrialRedemption(RecordModel): 1ab
15 __tablename__ = "trial_redemptions" 1ab
17 customer_email: Mapped[str] = mapped_column(String, nullable=False, index=True) 1ab
18 payment_method_fingerprint: Mapped[str | None] = mapped_column( 1ab
19 String, nullable=True, index=True
20 )
22 customer_id: Mapped[UUID] = mapped_column( 1ab
23 Uuid, ForeignKey("customers.id", ondelete="cascade"), nullable=False, index=True
24 )
26 @declared_attr 1ab
27 def customer(cls) -> Mapped["Customer"]: 1ab
28 return relationship("Customer", lazy="raise") 1ab
30 organization: AssociationProxy["Organization"] = association_proxy( 1ab
31 "customer", "organization"
32 )
34 product_id: Mapped[UUID | None] = mapped_column( 1ab
35 Uuid, ForeignKey("products.id", ondelete="cascade"), nullable=True, index=True
36 )
38 @declared_attr 1ab
39 def product(cls) -> Mapped["Product | None"]: 1ab
40 return relationship("Product", lazy="raise") 1ab