Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
models: Excise NULL from pointlessly nullable fields.
Anders Kaseorg1c228de049c1
diff --git a/zerver/lib/types.py b/zerver/lib/types.pyindex 62a7930cd3f..f585faf8c13 100644--- a/zerver/lib/types.py+++ b/zerver/lib/types.py@@ -23,8 +23,8 @@ class ProfileDataElementBase(TypedDict):id: intname: strtype: int- hint: Optional[str]- field_data: Optional[str]+ hint: str+ field_data: strorder: int@@ -144,7 +144,7 @@ class RawStreamDict(TypedDict):first_message_id: Optional[int]history_public_to_subscribers: boolid: int- invite_only: Optional[bool]+ invite_only: boolis_web_public: boolmessage_retention_days: Optional[int]name: str@@ -162,7 +162,7 @@ class RawSubscriptionDict(TypedDict):color: strdesktop_notifications: Optional[bool]email_notifications: Optional[bool]- is_muted: Optional[bool]+ is_muted: boolpin_to_top: boolpush_notifications: Optional[bool]recipient_id: int@@ -187,10 +187,9 @@ class SubscriptionStreamDict(TypedDict):first_message_id: Optional[int]history_public_to_subscribers: boolin_home_view: bool- # Bug: invite_only should be bool.- invite_only: Optional[bool]+ invite_only: boolis_announcement_only: bool- is_muted: Optional[bool]+ is_muted: boolis_web_public: boolmessage_retention_days: Optional[int]name: str@@ -210,7 +209,7 @@ class NeverSubscribedStreamDict(TypedDict):description: strfirst_message_id: Optional[int]history_public_to_subscribers: bool- invite_only: Optional[bool]+ invite_only: boolis_announcement_only: boolis_web_public: boolmessage_retention_days: Optional[int]diff --git a/zerver/migrations/0392_non_nullable_fields.py b/zerver/migrations/0392_non_nullable_fields.pynew file mode 100644index 00000000000..7eb9609a7ea--- /dev/null+++ b/zerver/migrations/0392_non_nullable_fields.py@@ -0,0 +1,43 @@+# Generated by Django 3.2.12 on 2022-04-27 19:14++from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ("zerver", "0391_alter_stream_history_public_to_subscribers"),+ ]++ operations = [+ migrations.AlterField(+ model_name="customprofilefield",+ name="field_data",+ field=models.TextField(default=""),+ ),+ migrations.AlterField(+ model_name="customprofilefield",+ name="hint",+ field=models.CharField(default="", max_length=80),+ ),+ migrations.AlterField(+ model_name="realmuserdefault",+ name="enter_sends",+ field=models.BooleanField(default=False),+ ),+ migrations.AlterField(+ model_name="stream",+ name="invite_only",+ field=models.BooleanField(default=False),+ ),+ migrations.AlterField(+ model_name="subscription",+ name="is_muted",+ field=models.BooleanField(default=False),+ ),+ migrations.AlterField(+ model_name="userprofile",+ name="enter_sends",+ field=models.BooleanField(default=False),+ ),+ ]diff --git a/zerver/models.py b/zerver/models.pyindex f4fd48a85f7..5817e8f0583 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -1454,7 +1454,7 @@ class UserBaseSettings(models.Model):"""# UI settings- enter_sends: Optional[bool] = models.BooleanField(null=True, default=False)+ enter_sends: bool = models.BooleanField(default=False)# display settingsleft_side_userlist: bool = models.BooleanField(default=False)@@ -2388,7 +2388,7 @@ class Stream(models.Model):"policy_name": gettext_lazy("Public, protected history"),},}- invite_only: Optional[bool] = models.BooleanField(null=True, default=False)+ invite_only: bool = models.BooleanField(default=False)history_public_to_subscribers: bool = models.BooleanField(default=True)# Whether this stream's content should be published by the web-public archive features@@ -3517,7 +3517,7 @@ class Subscription(models.Model):role: int = models.PositiveSmallIntegerField(default=ROLE_MEMBER, db_index=True)# Whether this user had muted this stream.- is_muted: Optional[bool] = models.BooleanField(null=True, default=False)+ is_muted: bool = models.BooleanField(default=False)DEFAULT_STREAM_COLOR = "#c2c2c2"color: str = models.CharField(max_length=10, default=DEFAULT_STREAM_COLOR)@@ -4361,7 +4361,7 @@ class CustomProfileField(models.Model):id: int = models.AutoField(auto_created=True, primary_key=True, verbose_name="ID")realm: Realm = models.ForeignKey(Realm, on_delete=CASCADE)name: str = models.CharField(max_length=NAME_MAX_LENGTH)- hint: Optional[str] = models.CharField(max_length=HINT_MAX_LENGTH, default="", null=True)+ hint: str = models.CharField(max_length=HINT_MAX_LENGTH, default="")order: int = models.IntegerField(default=0)SHORT_TEXT = 1@@ -4423,12 +4423,12 @@ class CustomProfileField(models.Model):# type/name/hint.## The format depends on the type. Field types SHORT_TEXT, LONG_TEXT,- # DATE, URL, and USER leave this null. Fields of type SELECT store the+ # DATE, URL, and USER leave this empty. Fields of type SELECT store the# choices' descriptions.## Note: There is no performance overhead of using TextField in PostgreSQL.# See https://www.postgresql.org/docs/9.0/static/datatype-character.html- field_data: Optional[str] = models.TextField(default="", null=True)+ field_data: str = models.TextField(default="")class Meta:unique_together = ("realm", "name")