mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 14:34:21 +01:00
Show descriptions and optional fields
This commit is contained in:
@@ -25,7 +25,16 @@ def RegistrationForm(*args, **kwargs):
|
||||
|
||||
new_fields = UserFields.query.all()
|
||||
for field in new_fields:
|
||||
setattr(_RegistrationForm, f"fields[{field.id}]", StringField(field.name))
|
||||
validators = []
|
||||
if field.required:
|
||||
validators.append(InputRequired())
|
||||
setattr(
|
||||
_RegistrationForm,
|
||||
f"fields[{field.id}]",
|
||||
StringField(
|
||||
field.name, description=field.description, validators=validators
|
||||
),
|
||||
)
|
||||
|
||||
return _RegistrationForm(*args, **kwargs)
|
||||
|
||||
|
||||
@@ -42,7 +42,17 @@ def SettingsForm(*args, **kwargs):
|
||||
|
||||
new_fields = UserFields.query.filter_by(editable=True).all()
|
||||
for field in new_fields:
|
||||
setattr(_SettingsForm, f"fields[{field.id}]", StringField(field.name))
|
||||
validators = []
|
||||
if field.required:
|
||||
validators.append(InputRequired())
|
||||
|
||||
setattr(
|
||||
_SettingsForm,
|
||||
f"fields[{field.id}]",
|
||||
StringField(
|
||||
field.name, description=field.description, validators=validators
|
||||
),
|
||||
)
|
||||
|
||||
return _SettingsForm(*args, **kwargs)
|
||||
|
||||
|
||||
@@ -91,7 +91,17 @@ def UserEditForm(*args, **kwargs):
|
||||
|
||||
new_fields = UserFields.query.all()
|
||||
for field in new_fields:
|
||||
setattr(_UserEditForm, f"fields[{field.id}]", StringField(field.name))
|
||||
validators = []
|
||||
if field.required:
|
||||
validators.append(InputRequired())
|
||||
|
||||
setattr(
|
||||
_UserEditForm,
|
||||
f"fields[{field.id}]",
|
||||
StringField(
|
||||
field.name, description=field.description, validators=validators
|
||||
),
|
||||
)
|
||||
|
||||
return _UserEditForm(*args, **kwargs)
|
||||
|
||||
@@ -113,6 +123,16 @@ def UserCreateForm(*args, **kwargs):
|
||||
|
||||
new_fields = UserFields.query.all()
|
||||
for field in new_fields:
|
||||
setattr(_UserCreateForm, f"fields[{field.id}]", StringField(field.name))
|
||||
validators = []
|
||||
if field.required:
|
||||
validators.append(InputRequired())
|
||||
|
||||
setattr(
|
||||
_UserCreateForm,
|
||||
f"fields[{field.id}]",
|
||||
StringField(
|
||||
field.name, description=field.description, validators=validators
|
||||
),
|
||||
)
|
||||
|
||||
return _UserCreateForm(*args, **kwargs)
|
||||
|
||||
@@ -14,21 +14,32 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.website.label }}
|
||||
<small class="float-right text-muted align-text-bottom">Optional</small>
|
||||
{{ form.website(class="form-control") }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.affiliation.label }}
|
||||
<small class="float-right text-muted align-text-bottom">Optional</small>
|
||||
{{ form.affiliation(class="form-control") }}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ form.country.label }}
|
||||
<small class="float-right text-muted align-text-bottom">Optional</small>
|
||||
{{ form.country(class="form-control custom-select") }}
|
||||
</div>
|
||||
|
||||
{% for k, v in form.extra %}
|
||||
<div class="form-group">
|
||||
<b>{{ v.label }}</b>
|
||||
{% if v.flags.required is false %}
|
||||
<small class="float-right text-muted align-text-bottom">Optional</small>
|
||||
{% endif %}
|
||||
{{ v(class="form-control") }}
|
||||
{% if v.description %}
|
||||
<small class="form-text text-muted">
|
||||
{{ v.description }}
|
||||
</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
@@ -28,7 +28,15 @@
|
||||
{% for k, v in form.extra %}
|
||||
<div class="form-group">
|
||||
<b>{{ v.label }}</b>
|
||||
{% if v.flags.required is false %}
|
||||
<small class="float-right text-muted align-text-bottom">Optional</small>
|
||||
{% endif %}
|
||||
{{ v(class="form-control") }}
|
||||
{% if v.description %}
|
||||
<small class="form-text text-muted">
|
||||
{{ v.description }}
|
||||
</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
@@ -27,21 +27,38 @@
|
||||
<div class="form-group">
|
||||
<b>{{ form.name.label }}</b>
|
||||
{{ form.name(class="form-control", value=name) }}
|
||||
<small class="form-text text-muted">
|
||||
Your username on the site
|
||||
</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<b>{{ form.email.label }}</b>
|
||||
{{ form.email(class="form-control", value=email) }}
|
||||
<small class="form-text text-muted">
|
||||
Never shown to the public
|
||||
</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<b>{{ form.password.label }}</b>
|
||||
{{ form.password(class="form-control", value=password) }}
|
||||
<small class="form-text text-muted">
|
||||
Password used to log into your account
|
||||
</small>
|
||||
</div>
|
||||
{{ form.nonce() }}
|
||||
|
||||
{% for k, v in form.extra %}
|
||||
<div class="form-group">
|
||||
<b>{{ v.label }}</b>
|
||||
{% if v.flags.required is false %}
|
||||
<small class="float-right text-muted align-text-bottom">Optional</small>
|
||||
{% endif %}
|
||||
{{ v(class="form-control") }}
|
||||
{% if v.description %}
|
||||
<small class="form-text text-muted">
|
||||
{{ v.description }}
|
||||
</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user