Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(admin): minor improvements #4862

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add OrganisationSubscriptionInformationCache to django admin
  • Loading branch information
matthewelwell committed Nov 25, 2024
commit 5a9ecd4c32e6e4a30e1c704e029a4b9fd071bc09
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
Loading