Skip to content

Commit

Permalink
server/subscription: tweak min/max length of benefit description
Browse files Browse the repository at this point in the history
  • Loading branch information
frankie567 committed Nov 2, 2023
1 parent 8b06973 commit 2f4879f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 12 additions & 3 deletions server/polar/subscription/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@
TIER_NAME_MIN_LENGTH = 3
TIER_NAME_MAX_LENGTH = 24
TIER_DESCRIPTION_MAX_LENGTH = 240
BENEFIT_DESCRIPTION_MAX_LENGTH = 120
BENEFIT_DESCRIPTION_MIN_LENGTH = 3
BENEFIT_DESCRIPTION_MAX_LENGTH = 42


# SubscriptionBenefitCreate


class SubscriptionBenefitCreateBase(Schema):
description: str = Field(..., max_length=BENEFIT_DESCRIPTION_MAX_LENGTH)
description: str = Field(
...,
min_length=BENEFIT_DESCRIPTION_MIN_LENGTH,
max_length=BENEFIT_DESCRIPTION_MAX_LENGTH,
)
organization_id: UUID4 | None = None
repository_id: UUID4 | None = None
properties: SubscriptionBenefitProperties
Expand Down Expand Up @@ -70,7 +75,11 @@ class SubscriptionBenefitCustomCreate(SubscriptionBenefitCreateBase):


class SubscriptionBenefitUpdateBase(Schema):
description: str | None = Field(None, max_length=BENEFIT_DESCRIPTION_MAX_LENGTH)
description: str | None = Field(
None,
min_length=BENEFIT_DESCRIPTION_MIN_LENGTH,
max_length=BENEFIT_DESCRIPTION_MAX_LENGTH,
)


class SubscriptionBenefitBuiltinUpdate(SubscriptionBenefitUpdateBase):
Expand Down
5 changes: 5 additions & 0 deletions server/tests/subscription/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,11 @@ async def test_neither_organization_nor_repository(
"result in a very ugly output on the subscription page."
),
},
{
"is_tax_applicable": True,
"properties": {},
"description": "Th",
},
{"description": "Subscription Benefit", "properties": {}},
],
)
Expand Down

1 comment on commit 2f4879f

@vercel
Copy link

@vercel vercel bot commented on 2f4879f Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./docs

docs-git-main-polar-sh.vercel.app
docs-polar-sh.vercel.app
docs-sigma-puce.vercel.app
docs.polar.sh

Please sign in to comment.