Skip to content

Commit

Permalink
Show active users count in org admin listview
Browse files Browse the repository at this point in the history
  • Loading branch information
faebebin committed Jul 3, 2023
1 parent 44a410f commit 1933cfa
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions docker-app/qfieldcloud/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,22 +1105,17 @@ class OrganizationAdmin(QFieldCloudModelAdmin):
"organization_owner__email__iexact",
)

readonly_fields = ("date_joined", "storage_usage__field", "active_users_count")
readonly_fields = ("date_joined", "storage_usage__field")

list_select_related = ("organization_owner",)
list_select_related = ("organization_owner", "useraccount")

list_filter = ("date_joined",)

autocomplete_fields = ("organization_owner",)

@admin.display(description=_("Active users (last billing period)"))
def active_users_count(self, instance) -> int | None:
# The relation 'current_subscription_vw' is not instantiated unless the organization
# does have a current subscription
if hasattr(instance, "current_subscription_vw"):
return instance.current_subscription_vw.active_users_count
else:
return None
@admin.display(description=_("Active members"))
def active_users_count(self, instance) -> int:
return instance.useraccount.current_subscription.active_users_simple_count

@admin.display(description=_("Owner"))
def organization_owner__link(self, instance):
Expand Down

0 comments on commit 1933cfa

Please sign in to comment.