-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4879 from wbaid/config-allow-document-uploads
make file submissions dis/allowable
- Loading branch information
Showing
16 changed files
with
311 additions
and
19 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
securedrop/alembic/versions/523fff3f969c_add_versioned_instance_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""add versioned instance config | ||
Revision ID: 523fff3f969c | ||
Revises: 3da3fcab826a | ||
Create Date: 2019-11-02 23:06:12.161868 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '523fff3f969c' | ||
down_revision = '3da3fcab826a' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('instance_config', | ||
sa.Column('version', sa.Integer(), nullable=False), | ||
sa.Column('valid_until', sa.DateTime(), nullable=True), | ||
sa.Column('allow_document_uploads', sa.Boolean(), nullable=True), | ||
|
||
sa.PrimaryKeyConstraint('version'), | ||
sa.UniqueConstraint('valid_until'), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
# Data migration: Since allow_document_uploads is the first | ||
# instance_config setting (column), all we have to do is insert a | ||
# row with its default value. | ||
conn = op.get_bind() | ||
conn.execute("""INSERT INTO instance_config (allow_document_uploads) VALUES (1)""") | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('instance_config') | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,9 @@ | |
|
||
&:focus | ||
outline: none | ||
|
||
.wide | ||
width: 100% | ||
|
||
textarea | ||
width: 100% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from sqlalchemy import text | ||
from sqlalchemy.exc import OperationalError | ||
|
||
from db import db | ||
from journalist_app import create_app | ||
|
||
|
||
instance_config_sql = "SELECT * FROM instance_config" | ||
|
||
|
||
class UpgradeTester: | ||
def __init__(self, config): | ||
self.config = config | ||
self.app = create_app(config) | ||
|
||
def load_data(self): | ||
pass | ||
|
||
def check_upgrade(self): | ||
with self.app.app_context(): | ||
db.engine.execute(text(instance_config_sql)).fetchall() | ||
|
||
|
||
class DowngradeTester: | ||
def __init__(self, config): | ||
self.config = config | ||
self.app = create_app(config) | ||
|
||
def load_data(self): | ||
pass | ||
|
||
def check_downgrade(self): | ||
with self.app.app_context(): | ||
try: | ||
db.engine.execute(text(instance_config_sql)).fetchall() | ||
|
||
# The SQLite driver appears to return this rather than the | ||
# expected NoSuchTableError. | ||
except OperationalError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.