https://github.com/CTFd/CTFd/milestone/6
This commit is contained in:
Kevin Chung
2019-04-17 01:36:30 -04:00
committed by GitHub
parent 33367422a5
commit b6d54b9ee9
278 changed files with 3659 additions and 13735 deletions

View File

@@ -1,7 +1,7 @@
"""Initial Revision
Revision ID: 8369118943a1
Revises:
Revises:
Create Date: 2018-11-05 01:06:24.495010
"""
@@ -22,43 +22,6 @@ branch_labels = None
depends_on = None
class SQLiteJson(TypeDecorator):
impl = String
class Comparator(String.Comparator):
def __getitem__(self, index):
if isinstance(index, tuple):
index = "$%s" % (
"".join([
"[%s]" % elem if isinstance(elem, int)
else '."%s"' % elem for elem in index
])
)
elif isinstance(index, int):
index = "$[%s]" % index
else:
index = '$."%s"' % index
# json_extract does not appear to return JSON sub-elements
# which is weird.
return func.json_extract(self.expr, index, type_=NullType)
comparator_factory = Comparator
def process_bind_param(self, value, dialect):
if value is not None:
value = json.dumps(value)
return value
def process_result_value(self, value, dialect):
if value is not None:
value = json.loads(value)
return value
JSON = types.JSON().with_variant(SQLiteJson, 'sqlite')
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('challenges',
@@ -70,7 +33,7 @@ def upgrade():
sa.Column('category', sa.String(length=80), nullable=True),
sa.Column('type', sa.String(length=80), nullable=True),
sa.Column('state', sa.String(length=80), nullable=False),
sa.Column('requirements', JSON, nullable=True),
sa.Column('requirements', sa.JSON(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('config',
@@ -142,7 +105,7 @@ def upgrade():
sa.Column('challenge_id', sa.Integer(), nullable=True),
sa.Column('content', sa.Text(), nullable=True),
sa.Column('cost', sa.Integer(), nullable=True),
sa.Column('requirements', JSON, nullable=True),
sa.Column('requirements', sa.JSON(), nullable=True),
sa.ForeignKeyConstraint(['challenge_id'], ['challenges.id'], ),
sa.PrimaryKeyConstraint('id')
)
@@ -186,7 +149,7 @@ def upgrade():
sa.Column('value', sa.Integer(), nullable=True),
sa.Column('category', sa.String(length=80), nullable=True),
sa.Column('icon', sa.Text(), nullable=True),
sa.Column('requirements', JSON, nullable=True),
sa.Column('requirements', sa.JSON(), nullable=True),
sa.ForeignKeyConstraint(['team_id'], ['teams.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')