Skip to content

feat(subscription): support per-subscription seats limit#1284

Closed
tdrivas wants to merge 1 commit intomasterfrom
QF-5474_seats
Closed

feat(subscription): support per-subscription seats limit#1284
tdrivas wants to merge 1 commit intomasterfrom
QF-5474_seats

Conversation

@tdrivas
Copy link
Contributor

@tdrivas tdrivas commented Jul 11, 2025

This PR introduces support for allowing seat limits in specific plans at the subscription level. To this direction a new field named max_organization_members is required for the Subscription model.

@duke-nyuki
Copy link
Collaborator

@gounux
Copy link
Member

gounux commented Jul 11, 2025

@tdrivas CI looks better now 👌

@tdrivas
Copy link
Contributor Author

tdrivas commented Jul 11, 2025

@tdrivas CI looks better now 👌

thanks! Drop and recreation of the views that are related to the migration updated fields was required.

@tdrivas tdrivas requested a review from suricactus July 11, 2025 10:46
Copy link
Collaborator

@suricactus suricactus left a comment

Choose a reason for hiding this comment

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

A few small comments mostly for clarity/deduplication of the code.

@tdrivas tdrivas requested a review from suricactus July 28, 2025 12:00
Copy link
Collaborator

@suricactus suricactus left a comment

Choose a reason for hiding this comment

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

Thanks for the review address. I have a second round of things to be done/improved.

Also, I note a few fields that you have added to the models, which is fine, but they are not presented in the Django admin. Can we expose these fields to Django admin?

@tdrivas
Copy link
Contributor Author

tdrivas commented Jul 29, 2025

@suricactus thanks for the second round of review! Changes on the admin side are also coming shortly.

@tdrivas tdrivas requested a review from suricactus July 29, 2025 13:53
Copy link
Collaborator

@suricactus suricactus left a comment

Choose a reason for hiding this comment

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

Here we are at a good stage, no expected changes for now, except:

  1. can you reduce the number of migrations to 1 or 2?
  2. I am still not convinced with is_seat_flexible naming. Don't change it for now, we can live with it.
  3. probably we can move subscription.Plan.UsageType to a more billing related place.

@tdrivas
Copy link
Contributor Author

tdrivas commented Aug 7, 2025

Here we are at a good stage, no expected changes for now, except:

  1. can you reduce the number of migrations to 1 or 2?
  2. I am still not convinced with is_seat_flexible naming. Don't change it for now, we can live with it.
  3. probably we can move subscription.Plan.UsageType to a more billing related place.

Thanks for the fruitful review.

  1. Done
  2. Yep, lets live with it for now
  3. Finally, I moved the entire field to a more billing related place without breaking anything here.

@suricactus
Copy link
Collaborator

@tdrivas can we make the CI happy again?

@tdrivas
Copy link
Contributor Author

tdrivas commented Sep 3, 2025

@tdrivas can we make the CI happy again?

Thanks a lot @suricactus for the contribution on the migration issue. Checking now for other issues on CI.

migrations.RunSQL(
sql=migrations.RunSQL.noop,
reverse_sql="""
DROP VIEW IF EXISTS current_subscriptions_vw;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am still not convinced this is the right way to go: two queries in one migration step.

If this is the only way to go, please add a

NOTE: while suboptimal to run two queries per migration step, this is the only working solution to recreate the `current_subscriptions_vw` on rollback so far.

Copy link
Collaborator

@suricactus suricactus left a comment

Choose a reason for hiding this comment

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

So far so good here, I will not push any more changes here.

Comment on lines 845 to 868
plan_max_organization_members = self.organization.useraccount.current_subscription.plan.max_organization_members
max_organization_members = (
self.organization.useraccount.current_subscription.max_organization_members
)

if (
max_organization_members > -1
plan_max_organization_members > -1
and self.organization.members.count() >= max_organization_members
):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, I find the logic here a bit confusing. Basically we do the following:

check if the plan has max_organization_members
AND
check if the current organization has more than the subscription max_organization_members.

Would it make more sense to check for the max_organization_members in the same model in both conditions?

@suricactus
Copy link
Collaborator

Closing and reopening in a new clean PR.

@suricactus suricactus closed this Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants