remote-support: Show active billing user emails.

This commit is contained in:
Lauryn Menard
2024-02-23 20:18:35 +01:00
committed by Tim Abbott
parent 3d1cf0619b
commit 1f72ab5133
5 changed files with 48 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ from typing import List, Tuple
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import Max, Q, UniqueConstraint
from django.db.models import Max, Q, QuerySet, UniqueConstraint
from django.utils.timezone import now as timezone_now
from typing_extensions import override
@@ -88,6 +88,12 @@ class RemoteZulipServer(models.Model):
def format_requester_for_logs(self) -> str:
return "zulip-server:" + str(self.uuid)
def get_remote_server_billing_users(self) -> QuerySet["RemoteServerBillingUser"]:
return RemoteServerBillingUser.objects.filter(
remote_server=self,
is_active=True,
)
class RemotePushDeviceToken(AbstractPushDeviceToken):
"""Like PushDeviceToken, but for a device connected to a remote server."""
@@ -176,6 +182,12 @@ class RemoteRealm(models.Model):
def __str__(self) -> str:
return f"{self.host} {str(self.uuid)[0:12]}"
def get_remote_realm_billing_users(self) -> QuerySet["RemoteRealmBillingUser"]:
return RemoteRealmBillingUser.objects.filter(
remote_realm=self,
is_active=True,
)
class AbstractRemoteRealmBillingUser(models.Model):
remote_realm = models.ForeignKey(RemoteRealm, on_delete=models.CASCADE)