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:
Sumanth V Rao
2021-05-13 07:09:29 +05:30
committed by Tim Abbott
parent 0b337e0819
commit 96c5a9e303
3 changed files with 21 additions and 2 deletions

View File

@@ -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")},
),
]

View File

@@ -1038,7 +1038,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}>"

View File

@@ -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")