diff --git a/tildes/alembic/versions/4241b0202fd4_add_setting_to_open_group_and_user_.py b/tildes/alembic/versions/4241b0202fd4_add_setting_to_open_group_and_user_.py new file mode 100644 index 0000000..47f1add --- /dev/null +++ b/tildes/alembic/versions/4241b0202fd4_add_setting_to_open_group_and_user_.py @@ -0,0 +1,36 @@ +"""Add setting to open group and user links in new tab + +Revision ID: 4241b0202fd4 +Revises: 34753d8124b4 +Create Date: 2020-02-06 16:59:10.720154 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "4241b0202fd4" +down_revision = "34753d8124b4" +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column( + "users", + sa.Column( + "open_new_tab_group", sa.Boolean(), server_default="false", nullable=False + ), + ) + op.add_column( + "users", + sa.Column( + "open_new_tab_user", sa.Boolean(), server_default="false", nullable=False + ), + ) + + +def downgrade(): + op.drop_column("users", "open_new_tab_user") + op.drop_column("users", "open_new_tab_group") diff --git a/tildes/scripts/clean_private_data.py b/tildes/scripts/clean_private_data.py index 408a8d8..3ad6424 100644 --- a/tildes/scripts/clean_private_data.py +++ b/tildes/scripts/clean_private_data.py @@ -197,6 +197,8 @@ class DataCleaner: "open_new_tab_external": DEFAULT, "open_new_tab_internal": DEFAULT, "open_new_tab_text": DEFAULT, + "open_new_tab_group": DEFAULT, + "open_new_tab_user": DEFAULT, "theme_default": DEFAULT, "permissions": DEFAULT, "home_default_order": DEFAULT, diff --git a/tildes/tildes/models/user/user.py b/tildes/tildes/models/user/user.py index c6db4b4..56d9f1f 100644 --- a/tildes/tildes/models/user/user.py +++ b/tildes/tildes/models/user/user.py @@ -103,6 +103,8 @@ class User(DatabaseModel): Boolean, nullable=False, server_default="false" ) open_new_tab_text: bool = Column(Boolean, nullable=False, server_default="false") + open_new_tab_group: bool = Column(Boolean, nullable=False, server_default="false") + open_new_tab_user: bool = Column(Boolean, nullable=False, server_default="false") theme_default: str = Column(Text) show_tags_in_listings: bool = Column( Boolean, nullable=False, server_default="false" diff --git a/tildes/tildes/templates/bookmarks.jinja2 b/tildes/tildes/templates/bookmarks.jinja2 index 1dafa2e..05ab1c7 100644 --- a/tildes/tildes/templates/bookmarks.jinja2 +++ b/tildes/tildes/templates/bookmarks.jinja2 @@ -1,7 +1,7 @@ {% extends 'base_user_menu.jinja2' %} {% from 'macros/comments.jinja2' import render_single_comment with context %} -{% from 'macros/links.jinja2' import link_to_group %} +{% from 'macros/links.jinja2' import link_to_group with context %} {% from 'macros/topics.jinja2' import render_topic_for_listing with context %} {% block title %}Bookmarks{% endblock %} diff --git a/tildes/tildes/templates/error_group_not_found.jinja2 b/tildes/tildes/templates/error_group_not_found.jinja2 index f852eaa..dcb8b63 100644 --- a/tildes/tildes/templates/error_group_not_found.jinja2 +++ b/tildes/tildes/templates/error_group_not_found.jinja2 @@ -3,7 +3,7 @@ {% extends 'base_no_sidebar.jinja2' %} -{% from 'macros/links.jinja2' import link_to_group %} +{% from 'macros/links.jinja2' import link_to_group with context %} {% block title %} Group not found diff --git a/tildes/tildes/templates/groups.jinja2 b/tildes/tildes/templates/groups.jinja2 index 94eb418..414f599 100644 --- a/tildes/tildes/templates/groups.jinja2 +++ b/tildes/tildes/templates/groups.jinja2 @@ -4,7 +4,7 @@ {% extends 'base_no_sidebar.jinja2' %} {% from 'macros/groups.jinja2' import render_group_subscription_box with context %} -{% from 'macros/links.jinja2' import link_to_group %} +{% from 'macros/links.jinja2' import link_to_group with context %} {% block title %}Browse groups{% endblock %} diff --git a/tildes/tildes/templates/macros/comments.jinja2 b/tildes/tildes/templates/macros/comments.jinja2 index 3ce46da..6d553d0 100644 --- a/tildes/tildes/templates/macros/comments.jinja2 +++ b/tildes/tildes/templates/macros/comments.jinja2 @@ -4,7 +4,7 @@ {% from 'buttons.jinja2' import post_action_toggle_button with context %} {% from 'datetime.jinja2' import adaptive_date_responsive %} {% from 'forms.jinja2' import markdown_textarea %} -{% from 'links.jinja2' import link_to_user %} +{% from 'links.jinja2' import link_to_user with context %} {% from 'utils.jinja2' import pluralize %} {% macro render_single_comment(comment) %} diff --git a/tildes/tildes/templates/macros/links.jinja2 b/tildes/tildes/templates/macros/links.jinja2 index e583224..168c2cf 100644 --- a/tildes/tildes/templates/macros/links.jinja2 +++ b/tildes/tildes/templates/macros/links.jinja2 @@ -3,12 +3,20 @@ {% macro link_to_user(user) -%} {% if user.is_real_user %} - {{ user.username }} + {{ user.username }} {% else %} {{ user.username }} {% endif %} {%- endmacro %} {% macro link_to_group(group) -%} - ~{{ group.path }} + ~{{ group.path }} {%- endmacro %} diff --git a/tildes/tildes/templates/macros/topics.jinja2 b/tildes/tildes/templates/macros/topics.jinja2 index 5852760..73ff559 100644 --- a/tildes/tildes/templates/macros/topics.jinja2 +++ b/tildes/tildes/templates/macros/topics.jinja2 @@ -3,7 +3,7 @@ {% from 'macros/buttons.jinja2' import post_action_toggle_button with context %} {% from 'macros/datetime.jinja2' import adaptive_date_responsive %} -{% from 'macros/links.jinja2' import link_to_group, link_to_user %} +{% from 'macros/links.jinja2' import link_to_group, link_to_user with context %} {% from 'utils.jinja2' import pluralize %} {% macro render_topic_for_listing(topic, show_group=False, rank=None) %} diff --git a/tildes/tildes/templates/messages.jinja2 b/tildes/tildes/templates/messages.jinja2 index 575e318..1584ee0 100644 --- a/tildes/tildes/templates/messages.jinja2 +++ b/tildes/tildes/templates/messages.jinja2 @@ -4,7 +4,7 @@ {% extends 'base_user_menu.jinja2' %} {% from 'macros/datetime.jinja2' import adaptive_date_responsive %} -{% from 'macros/links.jinja2' import link_to_user %} +{% from 'macros/links.jinja2' import link_to_user with context %} {% block title %}Message Inbox{% endblock %} diff --git a/tildes/tildes/templates/notifications_unread.jinja2 b/tildes/tildes/templates/notifications_unread.jinja2 index 8d6b925..0258c07 100644 --- a/tildes/tildes/templates/notifications_unread.jinja2 +++ b/tildes/tildes/templates/notifications_unread.jinja2 @@ -4,7 +4,7 @@ {% extends 'base_user_menu.jinja2' %} {% from 'macros/comments.jinja2' import comment_label_options_template, comment_reply_template, render_single_comment with context %} -{% from 'macros/links.jinja2' import link_to_group %} +{% from 'macros/links.jinja2' import link_to_group with context %} {% block title %}Unread notifications{% endblock %} diff --git a/tildes/tildes/templates/search.jinja2 b/tildes/tildes/templates/search.jinja2 index 6fd27ba..42df497 100644 --- a/tildes/tildes/templates/search.jinja2 +++ b/tildes/tildes/templates/search.jinja2 @@ -4,7 +4,7 @@ {% extends 'topic_listing.jinja2' %} {% from 'macros/forms.jinja2' import search_form %} -{% from 'macros/links.jinja2' import link_to_group %} +{% from 'macros/links.jinja2' import link_to_group with context %} {% block title %}Search results: {{ search }}{% endblock %} diff --git a/tildes/tildes/templates/settings.jinja2 b/tildes/tildes/templates/settings.jinja2 index 53365ea..2c2680d 100644 --- a/tildes/tildes/templates/settings.jinja2 +++ b/tildes/tildes/templates/settings.jinja2 @@ -144,6 +144,34 @@ +