diff --git a/tildes/alembic/versions/1996feae620d_change_troll_and_flame_comment_tags_to_.py b/tildes/alembic/versions/1996feae620d_change_troll_and_flame_comment_tags_to_.py new file mode 100644 index 0000000..7621c5d --- /dev/null +++ b/tildes/alembic/versions/1996feae620d_change_troll_and_flame_comment_tags_to_.py @@ -0,0 +1,51 @@ +"""Change Troll and Flame comment tags to Malice + +Revision ID: 1996feae620d +Revises: b825165870d9 +Create Date: 2018-09-18 00:42:30.213639 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "1996feae620d" +down_revision = "b825165870d9" +branch_labels = None +depends_on = None + + +def upgrade(): + # ALTER TYPE doesn't work from inside a transaction, disable it + connection = None + if not op.get_context().as_sql: + connection = op.get_bind() + connection.execution_options(isolation_level="AUTOCOMMIT") + + op.execute("ALTER TYPE commenttagoption ADD VALUE IF NOT EXISTS 'MALICE'") + + # re-activate the transaction for any future migrations + if connection is not None: + connection.execution_options(isolation_level="READ_COMMITTED") + + # delete all "flame" tags where the user also tagged the same comment as "troll" + # (so that we don't violate constraint when converting both to "malice") + op.execute( + """ + DELETE FROM comment_tags AS flame_tag + WHERE tag = 'FLAME' AND + EXISTS (SELECT * FROM comment_tags + WHERE user_id = flame_tag.user_id + AND comment_id = flame_tag.comment_id + AND tag = 'TROLL'); + """ + ) + + # convert all the old "troll" and "flame" tags to "malice" ones + op.execute("UPDATE comment_tags SET tag = 'MALICE' WHERE tag IN ('FLAME', 'TROLL')") + + +def downgrade(): + # not a proper revert, changing Malice back to Flame is about all we can do + op.execute("UPDATE comment_tags SET tag = 'FLAME' WHERE tag = 'MALICE'") diff --git a/tildes/scss/_themes.scss b/tildes/scss/_themes.scss index 21f23ba..2667ffc 100644 --- a/tildes/scss/_themes.scss +++ b/tildes/scss/_themes.scss @@ -121,8 +121,7 @@ .label-comment-tag-joke { @include specialtag($comment-tag-joke-color, $is-light); } .label-comment-tag-noise { @include specialtag($comment-tag-noise-color, $is-light); } .label-comment-tag-offtopic { @include specialtag($comment-tag-offtopic-color, $is-light); } - .label-comment-tag-troll { @include specialtag($comment-tag-troll-color, $is-light); } - .label-comment-tag-flame { @include specialtag($comment-tag-flame-color, $is-light); } + .label-comment-tag-malice { @include specialtag($comment-tag-malice-color, $is-light); } } %collapsed-theme { diff --git a/tildes/scss/_variables.scss b/tildes/scss/_variables.scss index ec3da40..c2e4d07 100644 --- a/tildes/scss/_variables.scss +++ b/tildes/scss/_variables.scss @@ -39,8 +39,7 @@ $topic-tag-spoiler-color: $yellow; $comment-tag-joke-color: $cyan; $comment-tag-noise-color: $yellow; $comment-tag-offtopic-color: $orange; -$comment-tag-troll-color: $green; -$comment-tag-flame-color: $red; +$comment-tag-malice-color: $red; $sidebar-width: 300px; diff --git a/tildes/scss/modules/_btn.scss b/tildes/scss/modules/_btn.scss index 46311d2..f978ce1 100644 --- a/tildes/scss/modules/_btn.scss +++ b/tildes/scss/modules/_btn.scss @@ -113,10 +113,6 @@ @include tagbutton($comment-tag-offtopic-color); } -.btn-comment-tag-troll { - @include tagbutton($comment-tag-troll-color); -} - -.btn-comment-tag-flame { - @include tagbutton($comment-tag-flame-color); +.btn-comment-tag-malice { + @include tagbutton($comment-tag-malice-color); } diff --git a/tildes/tildes/enums.py b/tildes/tildes/enums.py index 4648783..20a9714 100644 --- a/tildes/tildes/enums.py +++ b/tildes/tildes/enums.py @@ -41,8 +41,7 @@ class CommentTagOption(enum.Enum): JOKE = enum.auto() NOISE = enum.auto() OFFTOPIC = enum.auto() - TROLL = enum.auto() - FLAME = enum.auto() + MALICE = enum.auto() class LogEventType(enum.Enum):