mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	models: Fix bug in unique_together condition on RealmPlayground.
We don't need to worry about breaking already configured playgrounds since this tweak makes the condition less strict.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							634a8ad345
						
					
				
				
					commit
					98253f261e
				
			@@ -0,0 +1,17 @@
 | 
			
		||||
# Generated by Django 3.2.2 on 2021-05-13 00:16
 | 
			
		||||
 | 
			
		||||
from django.db import migrations
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ("zerver", "0324_fix_deletion_cascade_behavior"),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.AlterUniqueTogether(
 | 
			
		||||
            name="realmplayground",
 | 
			
		||||
            unique_together={("realm", "pygments_language", "name")},
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -1040,7 +1040,7 @@ class RealmPlayground(models.Model):
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        unique_together = (("realm", "name"),)
 | 
			
		||||
        unique_together = (("realm", "pygments_language", "name"),)
 | 
			
		||||
 | 
			
		||||
    def __str__(self) -> str:
 | 
			
		||||
        return f"<RealmPlayground({self.realm.string_id}): {self.pygments_language} {self.name}>"
 | 
			
		||||
 
 | 
			
		||||
@@ -77,7 +77,9 @@ class RealmPlaygroundTests(ZulipTestCase):
 | 
			
		||||
        self.assert_json_success(resp)
 | 
			
		||||
 | 
			
		||||
        resp = self.api_post(iago, "/json/realm/playgrounds", payload)
 | 
			
		||||
        self.assert_json_error(resp, "Realm playground with this Realm and Name already exists.")
 | 
			
		||||
        self.assert_json_error(
 | 
			
		||||
            resp, "Realm playground with this Realm, Pygments language and Name already exists."
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_not_realm_admin(self) -> None:
 | 
			
		||||
        hamlet = self.example_user("hamlet")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user