Browse Source
Add setting to open text links in new tab
merge-requests/14/head
Ivan Fonseca
8 years ago
No known key found for this signature in database
GPG Key ID: 95A9C856EC788689
4 changed files with
42 additions and
0 deletions
-
tildes/alembic/versions/de83b8750123_add_setting_to_open_text_links_in_new_.py
-
tildes/tildes/models/user/user.py
-
tildes/tildes/templates/settings.jinja2
-
tildes/tildes/views/api/web/user.py
|
|
|
@ -0,0 +1,24 @@ |
|
|
|
"""Add setting to open text links in new tab |
|
|
|
|
|
|
|
Revision ID: de83b8750123 |
|
|
|
Revises: 2512581c91b3 |
|
|
|
Create Date: 2018-07-24 03:10:59.485645 |
|
|
|
|
|
|
|
""" |
|
|
|
from alembic import op |
|
|
|
import sqlalchemy as sa |
|
|
|
|
|
|
|
|
|
|
|
# revision identifiers, used by Alembic. |
|
|
|
revision = 'de83b8750123' |
|
|
|
down_revision = '2512581c91b3' |
|
|
|
branch_labels = None |
|
|
|
depends_on = None |
|
|
|
|
|
|
|
|
|
|
|
def upgrade(): |
|
|
|
op.add_column('users', sa.Column('open_new_tab_text', sa.Boolean(), server_default='false', nullable=False)) |
|
|
|
|
|
|
|
|
|
|
|
def downgrade(): |
|
|
|
op.drop_column('users', 'open_new_tab_text') |
|
|
|
@ -86,6 +86,8 @@ class User(DatabaseModel): |
|
|
|
Boolean, nullable=False, server_default='false') |
|
|
|
open_new_tab_internal: bool = Column( |
|
|
|
Boolean, nullable=False, server_default='false') |
|
|
|
open_new_tab_text: bool = Column( |
|
|
|
Boolean, nullable=False, server_default='false') |
|
|
|
is_banned: bool = Column(Boolean, nullable=False, server_default='false') |
|
|
|
is_admin: bool = Column(Boolean, nullable=False, server_default='false') |
|
|
|
home_default_order: Optional[TopicSortOption] = Column( |
|
|
|
|
|
|
|
@ -73,6 +73,20 @@ |
|
|
|
</label> |
|
|
|
</div> |
|
|
|
</li> |
|
|
|
<li> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="form-checkbox"> |
|
|
|
<input |
|
|
|
type="checkbox" |
|
|
|
id="open_new_tab_text" |
|
|
|
name="open_new_tab_text" |
|
|
|
data-js-autosubmit-on-change |
|
|
|
{% if request.user.open_new_tab_text %}checked{% endif %} |
|
|
|
> |
|
|
|
<i class="form-icon"></i> Links in topic and comment text |
|
|
|
</label> |
|
|
|
</div> |
|
|
|
</li> |
|
|
|
</ul> |
|
|
|
</form> |
|
|
|
</li> |
|
|
|
|
|
|
|
@ -116,8 +116,10 @@ def change_open_links_new_tab(request: Request) -> Response: |
|
|
|
|
|
|
|
external = bool(request.params.get('open_new_tab_external')) |
|
|
|
internal = bool(request.params.get('open_new_tab_internal')) |
|
|
|
text = bool(request.params.get('open_new_tab_text')) |
|
|
|
user.open_new_tab_external = external |
|
|
|
user.open_new_tab_internal = internal |
|
|
|
user.open_new_tab_text = text |
|
|
|
|
|
|
|
return IC_NOOP |
|
|
|
|
|
|
|
|