Browse Source

Allow groups to always show user as topic source

This will allow individual groups to always show the username on topics,
overriding the usual behavior of only showing username when it's a text
topic. On Tildes itself, this will be useful for groups like ~creative.
merge-requests/64/head
Deimos 6 years ago
parent
commit
ba19809c52
  1. 36
      tildes/alembic/versions/7ac1aad64144_group_add_is_user_treated_as_topic_.py
  2. 3
      tildes/tildes/models/group/group.py
  3. 3
      tildes/tildes/models/topic/topic.py

36
tildes/alembic/versions/7ac1aad64144_group_add_is_user_treated_as_topic_.py

@ -0,0 +1,36 @@
"""Group: add is_user_treated_as_topic_source
Revision ID: 7ac1aad64144
Revises: 61f43e57679a
Create Date: 2019-03-08 23:02:33.848382
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "7ac1aad64144"
down_revision = "61f43e57679a"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"groups",
sa.Column(
"is_user_treated_as_topic_source",
sa.Boolean(),
server_default="false",
nullable=False,
),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("groups", "is_user_treated_as_topic_source")
# ### end Alembic commands ###

3
tildes/tildes/models/group/group.py

@ -47,6 +47,9 @@ class Group(DatabaseModel):
is_admin_posting_only: bool = Column( is_admin_posting_only: bool = Column(
Boolean, nullable=False, server_default="false" Boolean, nullable=False, server_default="false"
) )
is_user_treated_as_topic_source: bool = Column(
Boolean, nullable=False, server_default="false"
)
# Create a GiST index on path as well as the btree one that will be created by the # Create a GiST index on path as well as the btree one that will be created by the
# index=True/unique=True keyword args to Column above. The GiST index supports # index=True/unique=True keyword args to Column above. The GiST index supports

3
tildes/tildes/models/topic/topic.py

@ -452,4 +452,7 @@ class Topic(DatabaseModel):
@property @property
def is_user_treated_as_source(self) -> bool: def is_user_treated_as_source(self) -> bool:
"""Return whether the user that posted the topic is its "source".""" """Return whether the user that posted the topic is its "source"."""
if self.group.is_user_treated_as_topic_source:
return True
return self.is_text_type return self.is_text_type
Loading…
Cancel
Save