mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	This commit replaces the allow_community_topic_editing boolean with integer field edit_topic_policy and includes both frontend and backend changes. We also update settings_ui.disable_sub_settings_onchange to not change the color of label as we did previously when the setting was a checkbox. But now as the setting is dropdown we keep the label as it is and we don't do anything with label when disabling dropdowns. Also, this function was used only here so we can safely change this.
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
# Generated by Django 3.2.2 on 2021-05-26 09:43
 | 
						|
 | 
						|
from django.db import migrations
 | 
						|
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
 | 
						|
from django.db.migrations.state import StateApps
 | 
						|
 | 
						|
 | 
						|
def migrate_to_edit_topic_policy(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
 | 
						|
    Realm = apps.get_model("zerver", "Realm")
 | 
						|
    Realm.POLICY_EVERYONE = 5
 | 
						|
    Realm.POLICY_ADMINS_ONLY = 2
 | 
						|
    Realm.objects.filter(allow_community_topic_editing=False).update(
 | 
						|
        edit_topic_policy=Realm.POLICY_ADMINS_ONLY
 | 
						|
    )
 | 
						|
    Realm.objects.filter(allow_community_topic_editing=True).update(
 | 
						|
        edit_topic_policy=Realm.POLICY_EVERYONE
 | 
						|
    )
 | 
						|
 | 
						|
 | 
						|
def reverse_migrate_to_edit_topic_policy(
 | 
						|
    apps: StateApps, schema_editor: DatabaseSchemaEditor
 | 
						|
) -> None:
 | 
						|
    Realm = apps.get_model("zerver", "Realm")
 | 
						|
    Realm.POLICY_EVERYONE = 5
 | 
						|
    Realm.POLICY_ADMINS_ONLY = 2
 | 
						|
    Realm.objects.filter(edit_topic_policy=Realm.POLICY_ADMINS_ONLY).update(
 | 
						|
        allow_community_topic_editing=False
 | 
						|
    )
 | 
						|
    Realm.objects.filter(edit_topic_policy=Realm.POLICY_EVERYONE).update(
 | 
						|
        allow_community_topic_editing=True
 | 
						|
    )
 | 
						|
 | 
						|
 | 
						|
class Migration(migrations.Migration):
 | 
						|
 | 
						|
    dependencies = [
 | 
						|
        ("zerver", "0327_realm_edit_topic_policy"),
 | 
						|
    ]
 | 
						|
 | 
						|
    operations = [
 | 
						|
        migrations.RunPython(
 | 
						|
            migrate_to_edit_topic_policy,
 | 
						|
            reverse_code=reverse_migrate_to_edit_topic_policy,
 | 
						|
            elidable=True,
 | 
						|
        ),
 | 
						|
    ]
 |