mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 00:23:49 +00:00
zilencer: Sync name and authentication_methods on RemoteRealm.
This commit is contained in:
committed by
Tim Abbott
parent
4ef6b7cc44
commit
9b1a495e2c
@@ -7,7 +7,7 @@ import requests
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.forms.models import model_to_dict
|
from django.forms.models import model_to_dict
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from pydantic import UUID4, BaseModel, ConfigDict, field_validator
|
from pydantic import UUID4, BaseModel, ConfigDict, Field, field_validator
|
||||||
|
|
||||||
from analytics.models import InstallationCount, RealmCount
|
from analytics.models import InstallationCount, RealmCount
|
||||||
from version import ZULIP_VERSION
|
from version import ZULIP_VERSION
|
||||||
@@ -36,10 +36,13 @@ class RealmDataForAnalytics(BaseModel):
|
|||||||
id: int
|
id: int
|
||||||
host: str
|
host: str
|
||||||
url: str
|
url: str
|
||||||
|
name: str = ""
|
||||||
org_type: int = 0
|
org_type: int = 0
|
||||||
date_created: float
|
date_created: float
|
||||||
deactivated: bool
|
deactivated: bool
|
||||||
|
|
||||||
|
authentication_methods: Dict[str, bool] = Field(default_factory=dict)
|
||||||
|
|
||||||
uuid: UUID4
|
uuid: UUID4
|
||||||
uuid_owner_secret: str
|
uuid_owner_secret: str
|
||||||
|
|
||||||
@@ -224,6 +227,8 @@ def get_realms_info_for_push_bouncer(realm_id: Optional[int] = None) -> List[Rea
|
|||||||
deactivated=realm.deactivated,
|
deactivated=realm.deactivated,
|
||||||
date_created=realm.date_created.timestamp(),
|
date_created=realm.date_created.timestamp(),
|
||||||
org_type=realm.org_type,
|
org_type=realm.org_type,
|
||||||
|
name=realm.name,
|
||||||
|
authentication_methods=realm.authentication_methods_dict(),
|
||||||
)
|
)
|
||||||
for realm in realms
|
for realm in realms
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -984,7 +984,9 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
|||||||
"uuid",
|
"uuid",
|
||||||
"uuid_owner_secret",
|
"uuid_owner_secret",
|
||||||
"host",
|
"host",
|
||||||
|
"name",
|
||||||
"org_type",
|
"org_type",
|
||||||
|
"authentication_methods",
|
||||||
"realm_date_created",
|
"realm_date_created",
|
||||||
"registration_deactivated",
|
"registration_deactivated",
|
||||||
"realm_deactivated",
|
"realm_deactivated",
|
||||||
@@ -997,7 +999,9 @@ class AnalyticsBouncerTest(BouncerTestCase):
|
|||||||
"uuid": realm.uuid,
|
"uuid": realm.uuid,
|
||||||
"uuid_owner_secret": realm.uuid_owner_secret,
|
"uuid_owner_secret": realm.uuid_owner_secret,
|
||||||
"host": realm.host,
|
"host": realm.host,
|
||||||
|
"name": realm.name,
|
||||||
"org_type": realm.org_type,
|
"org_type": realm.org_type,
|
||||||
|
"authentication_methods": realm.authentication_methods_dict(),
|
||||||
"realm_date_created": realm.date_created,
|
"realm_date_created": realm.date_created,
|
||||||
"registration_deactivated": False,
|
"registration_deactivated": False,
|
||||||
"realm_deactivated": False,
|
"realm_deactivated": False,
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 4.2.7 on 2023-11-29 22:43
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("zilencer", "0039_remoterealm_org_type"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="remoterealm",
|
||||||
|
name="authentication_methods",
|
||||||
|
field=models.JSONField(default=dict),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="remoterealm",
|
||||||
|
name="name",
|
||||||
|
field=models.TextField(default=""),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -104,6 +104,10 @@ class RemoteRealm(models.Model):
|
|||||||
# Value obtained's from the remote server's realm.host.
|
# Value obtained's from the remote server's realm.host.
|
||||||
host = models.TextField()
|
host = models.TextField()
|
||||||
|
|
||||||
|
name = models.TextField(default="")
|
||||||
|
|
||||||
|
authentication_methods = models.JSONField(default=dict)
|
||||||
|
|
||||||
org_type = models.PositiveSmallIntegerField(
|
org_type = models.PositiveSmallIntegerField(
|
||||||
default=Realm.ORG_TYPES["unspecified"]["id"],
|
default=Realm.ORG_TYPES["unspecified"]["id"],
|
||||||
choices=[(t["id"], t["name"]) for t in Realm.ORG_TYPES.values()],
|
choices=[(t["id"], t["name"]) for t in Realm.ORG_TYPES.values()],
|
||||||
|
|||||||
@@ -543,6 +543,8 @@ def update_remote_realm_data_for_server(
|
|||||||
realm_deactivated=realm.deactivated,
|
realm_deactivated=realm.deactivated,
|
||||||
realm_date_created=timestamp_to_datetime(realm.date_created),
|
realm_date_created=timestamp_to_datetime(realm.date_created),
|
||||||
org_type=realm.org_type,
|
org_type=realm.org_type,
|
||||||
|
name=realm.name,
|
||||||
|
authentication_methods=realm.authentication_methods,
|
||||||
)
|
)
|
||||||
for realm in server_realms_info
|
for realm in server_realms_info
|
||||||
if realm.uuid not in already_registered_uuids
|
if realm.uuid not in already_registered_uuids
|
||||||
|
|||||||
Reference in New Issue
Block a user