mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +01:00
Add connection_info to Challenges model (#1965)
* Closes #1964 * Adds connection_info to Challenges
This commit is contained in:
@@ -85,6 +85,7 @@ class Challenges(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(80))
|
||||
description = db.Column(db.Text)
|
||||
connection_info = db.Column(db.Text)
|
||||
max_attempts = db.Column(db.Integer, default=0)
|
||||
value = db.Column(db.Integer)
|
||||
category = db.Column(db.String(80))
|
||||
|
||||
@@ -53,6 +53,7 @@ class BaseChallenge(object):
|
||||
"name": challenge.name,
|
||||
"value": challenge.value,
|
||||
"description": challenge.description,
|
||||
"connection_info": challenge.connection_info,
|
||||
"category": challenge.category,
|
||||
"state": challenge.state,
|
||||
"max_attempts": challenge.max_attempts,
|
||||
|
||||
@@ -102,6 +102,7 @@ class DynamicValueChallenge(BaseChallenge):
|
||||
"decay": challenge.decay,
|
||||
"minimum": challenge.minimum,
|
||||
"description": challenge.description,
|
||||
"connection_info": challenge.connection_info,
|
||||
"category": challenge.category,
|
||||
"state": challenge.state,
|
||||
"max_attempts": challenge.max_attempts,
|
||||
|
||||
@@ -34,6 +34,18 @@
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block connection_info %}
|
||||
<div class="form-group">
|
||||
<label>
|
||||
Connection Info<br>
|
||||
<small class="form-text text-muted">
|
||||
Use this to specify a link, hostname, or connection instructions for your challenge.
|
||||
</small>
|
||||
</label>
|
||||
<input type="text" class="form-control chal-connection-info" name="connection_info" value="{{ challenge.connection_info | default('', true) }}">
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block value %}
|
||||
<div class="form-group">
|
||||
<label for="value">
|
||||
|
||||
@@ -38,6 +38,18 @@
|
||||
|
||||
<span class="challenge-desc">{% block description %}{{ challenge.html }}{% endblock %}</span>
|
||||
|
||||
<span class="challenge-connection-info">
|
||||
{% block connection_info %}
|
||||
{% set conn = challenge.connection_info %}
|
||||
{% if not conn %}
|
||||
{% elif conn.startswith("http") %}
|
||||
{{ conn | urlize(target="_blank") }}
|
||||
{% else %}
|
||||
<code>{{ conn }}</code>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</span>
|
||||
|
||||
<div class="challenge-hints hint-row row">
|
||||
{% for hint in hints %}
|
||||
<div class='col-md-12 hint-button-wrapper text-center mb-3'>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
"""Add connection_info column to Challenges
|
||||
|
||||
Revision ID: 6012fe8de495
|
||||
Revises: ef87d69ec29a
|
||||
Create Date: 2021-07-30 03:50:54.219124
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "6012fe8de495"
|
||||
down_revision = "ef87d69ec29a"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column("challenges", sa.Column("connection_info", sa.Text(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column("challenges", "connection_info")
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user