feat(subscription): support per-subscription seats limit#1284
feat(subscription): support per-subscription seats limit#1284
Conversation
|
@tdrivas CI looks better now 👌 |
thanks! Drop and recreation of the views that are related to the migration updated fields was required. |
suricactus
left a comment
There was a problem hiding this comment.
A few small comments mostly for clarity/deduplication of the code.
suricactus
left a comment
There was a problem hiding this comment.
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?
|
@suricactus thanks for the second round of review! Changes on the admin side are also coming shortly. |
suricactus
left a comment
There was a problem hiding this comment.
Here we are at a good stage, no expected changes for now, except:
- can you reduce the number of migrations to 1 or 2?
- I am still not convinced with
is_seat_flexiblenaming. Don't change it for now, we can live with it. - probably we can move
subscription.Plan.UsageTypeto a more billing related place.
Thanks for the fruitful review.
|
|
@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; |
There was a problem hiding this comment.
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.
suricactus
left a comment
There was a problem hiding this comment.
So far so good here, I will not push any more changes here.
| 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 | ||
| ): |
There was a problem hiding this comment.
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?
57c005c to
c10bc48
Compare
c10bc48 to
ff4b325
Compare
|
Closing and reopening in a new clean PR. |
This PR introduces support for allowing seat limits in specific plans at the subscription level. To this direction a new field named
max_organization_membersis required for theSubscriptionmodel.