user_groups: Add deactivated field to NamedUserGroup model.

This commit is contained in:
Sahil Batra 2024-05-15 18:46:05 +05:30 committed by Tim Abbott
parent f0c0eef8dc
commit bef7cfe00f
4 changed files with 23 additions and 3 deletions

View File

@ -753,13 +753,14 @@ def bulk_import_named_user_groups(data: TableData) -> None:
group["is_system_group"],
group["can_manage_group_id"],
group["can_mention_group_id"],
group["deactivated"],
)
for group in data["zerver_namedusergroup"]
]
query = SQL(
"""
INSERT INTO zerver_namedusergroup (usergroup_ptr_id, realm_id, name, description, is_system_group, can_manage_group_id, can_mention_group_id)
INSERT INTO zerver_namedusergroup (usergroup_ptr_id, realm_id, name, description, is_system_group, can_manage_group_id, can_mention_group_id, deactivated)
VALUES %s
"""
)

View File

@ -614,7 +614,7 @@ def bulk_create_system_user_groups(groups: list[dict[str, str]], realm: Realm) -
user_group_ids = [id for (id,) in cursor.fetchall()]
rows = [
SQL("({},{},{},{},{},{},{})").format(
SQL("({},{},{},{},{},{},{},{})").format(
Literal(user_group_ids[idx]),
Literal(realm.id),
Literal(group["name"]),
@ -622,12 +622,13 @@ def bulk_create_system_user_groups(groups: list[dict[str, str]], realm: Realm) -
Literal(True),
Literal(initial_group_setting_value),
Literal(initial_group_setting_value),
Literal(False),
)
for idx, group in enumerate(groups)
]
query = SQL(
"""
INSERT INTO zerver_namedusergroup (usergroup_ptr_id, realm_id, name, description, is_system_group, can_manage_group_id, can_mention_group_id)
INSERT INTO zerver_namedusergroup (usergroup_ptr_id, realm_id, name, description, is_system_group, can_manage_group_id, can_mention_group_id, deactivated)
VALUES {rows}
"""
).format(rows=SQL(", ").join(rows))

View File

@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-05-15 13:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zerver", "0577_merge_20240829_0153"),
]
operations = [
migrations.AddField(
model_name="namedusergroup",
name="deactivated",
field=models.BooleanField(default=False, db_default=False),
),
]

View File

@ -60,6 +60,7 @@ class NamedUserGroup(UserGroup): # type: ignore[django-manager-missing] # djang
)
realm_for_sharding = models.ForeignKey("zerver.Realm", on_delete=CASCADE, db_column="realm_id")
deactivated = models.BooleanField(default=False, db_default=False)
# We do not have "Full members" and "Everyone on the internet"
# group here since there isn't a separate role value for full