Skip to content

Commit

Permalink
chore(admin): minor improvements (#4862)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewelwell authored Nov 26, 2024
1 parent c0e3b3f commit 94a7f49
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 27 deletions.
70 changes: 69 additions & 1 deletion api/organisations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
from django.contrib import admin
from django.db.models import Count, Q

from organisations.models import Organisation, Subscription, UserOrganisation
from organisations.models import (
Organisation,
OrganisationSubscriptionInformationCache,
Subscription,
UserOrganisation,
)
from projects.models import Project


Expand All @@ -13,6 +18,8 @@ class ProjectInline(admin.StackedInline):
extra = 0
show_change_link = True

classes = ("collapse",)


class SubscriptionInline(admin.StackedInline):
model = Subscription
Expand All @@ -29,12 +36,73 @@ class UserOrganisationInline(admin.TabularInline):
verbose_name_plural = "Users"


class OrganisationSubscriptionInformationCacheInline(admin.StackedInline):
model = OrganisationSubscriptionInformationCache
extra = 0
show_change_link = False
classes = ("collapse",)

fieldsets = (
(
None,
{
"fields": [],
"description": "This data is relevant in SaaS only. It should all be managed automatically via "
"webhooks from Chargebee and recurring tasks but may need to be edited in certain "
"situtations.",
},
),
(
"Usage Information",
{
"classes": ["collapse"],
"fields": ["api_calls_24h", "api_calls_7d", "api_calls_30d"],
},
),
(
"Billing Information",
{
"classes": ["collapse"],
"fields": [
"current_billing_term_starts_at",
"current_billing_term_ends_at",
"chargebee_email",
],
},
),
(
"Allowances",
{
"description": "These fields shouldn't need to be edited, as it should be managed automatically, "
"but sometimes things get out of sync - in which case, we can edit them here.",
"fields": [
"allowed_seats",
"allowed_30d_api_calls",
"allowed_projects",
"audit_log_visibility_days",
"feature_history_visibility_days",
],
},
),
)

readonly_fields = (
"api_calls_24h",
"api_calls_7d",
"api_calls_30d",
"current_billing_term_starts_at",
"current_billing_term_ends_at",
"chargebee_email",
)


@admin.register(Organisation)
class OrganisationAdmin(admin.ModelAdmin):
inlines = [
ProjectInline,
SubscriptionInline,
UserOrganisationInline,
OrganisationSubscriptionInformationCacheInline,
]
list_display = (
"id",
Expand Down
30 changes: 5 additions & 25 deletions api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ djangorestframework-simplejwt = "^5.3.1"
optional = true

[tool.poetry.group.auth-controller.dependencies]
flagsmith-auth-controller = { git = "https://github.com/flagsmith/flagsmith-auth-controller", tag = "v0.1.2" }
flagsmith-auth-controller = { git = "https://github.com/flagsmith/flagsmith-auth-controller", tag = "v0.1.3" }

[tool.poetry.group.saml]
optional = true
Expand Down

0 comments on commit 94a7f49

Please sign in to comment.