mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 10:33:54 +00:00
models: Remove type prefixes from __str__ values.
The Django convention is for __repr__ to include the type and __str__
to omit it. In fact its default __repr__ implementation for models
automatically adds a type prefix to __str__, which has resulted in the
type being duplicated:
>>> UserProfile.objects.first()
<UserProfile: <UserProfile: emailgateway@zulip.com <Realm: zulipinternal 1>>>
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Anders Kaseorg
parent
f66136fcc2
commit
2d9b2a2a05
@@ -17,7 +17,7 @@ class FillState(models.Model):
|
||||
state = models.PositiveSmallIntegerField()
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"<FillState: {self.property} {self.end_time} {self.state}>"
|
||||
return f"{self.property} {self.end_time} {self.state}"
|
||||
|
||||
|
||||
# The earliest/starting end_time in FillState
|
||||
@@ -59,7 +59,7 @@ class InstallationCount(BaseCount):
|
||||
]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"<InstallationCount: {self.property} {self.subgroup} {self.value}>"
|
||||
return f"{self.property} {self.subgroup} {self.value}"
|
||||
|
||||
|
||||
class RealmCount(BaseCount):
|
||||
@@ -82,7 +82,7 @@ class RealmCount(BaseCount):
|
||||
index_together = ["property", "end_time"]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"<RealmCount: {self.realm} {self.property} {self.subgroup} {self.value}>"
|
||||
return f"{self.realm!r} {self.property} {self.subgroup} {self.value}"
|
||||
|
||||
|
||||
class UserCount(BaseCount):
|
||||
@@ -108,7 +108,7 @@ class UserCount(BaseCount):
|
||||
index_together = ["property", "realm", "end_time"]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"<UserCount: {self.user} {self.property} {self.subgroup} {self.value}>"
|
||||
return f"{self.user!r} {self.property} {self.subgroup} {self.value}"
|
||||
|
||||
|
||||
class StreamCount(BaseCount):
|
||||
@@ -134,6 +134,4 @@ class StreamCount(BaseCount):
|
||||
index_together = ["property", "realm", "end_time"]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return (
|
||||
f"<StreamCount: {self.stream} {self.property} {self.subgroup} {self.value} {self.id}>"
|
||||
)
|
||||
return f"{self.stream!r} {self.property} {self.subgroup} {self.value} {self.id}"
|
||||
|
||||
Reference in New Issue
Block a user