mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 14:02:24 +01:00
Fix two form and validation issues
This commit is contained in:
parent
8191e3fe63
commit
a3371d538c
@ -23,7 +23,7 @@ from flask_babel import lazy_gettext, LazyString
|
|||||||
|
|
||||||
from app.logic.LogicError import LogicError
|
from app.logic.LogicError import LogicError
|
||||||
from app.models import User, Package, PackageType, MetaPackage, Tag, ContentWarning, db, Permission, AuditSeverity, \
|
from app.models import User, Package, PackageType, MetaPackage, Tag, ContentWarning, db, Permission, AuditSeverity, \
|
||||||
License, UserRank, PackageDevState
|
License, PackageDevState
|
||||||
from app.utils import add_audit_log, has_blocked_domains, diff_dictionaries, describe_difference
|
from app.utils import add_audit_log, has_blocked_domains, diff_dictionaries, describe_difference
|
||||||
from app.utils.url import clean_youtube_url
|
from app.utils.url import clean_youtube_url
|
||||||
|
|
||||||
@ -103,8 +103,7 @@ def validate(data: dict):
|
|||||||
if value is not None:
|
if value is not None:
|
||||||
check(value.startswith("http://") or value.startswith("https://"),
|
check(value.startswith("http://") or value.startswith("https://"),
|
||||||
key + " must start with http:// or https://")
|
key + " must start with http:// or https://")
|
||||||
|
check(validators.url(value), key + " must be a valid URL")
|
||||||
check(validators.url(value, public=True), key + " must be a valid URL")
|
|
||||||
|
|
||||||
|
|
||||||
def do_edit_package(user: User, package: Package, was_new: bool, was_web: bool, data: dict,
|
def do_edit_package(user: User, package: Package, was_new: bool, was_web: bool, data: dict,
|
||||||
|
@ -141,7 +141,7 @@
|
|||||||
{% macro render_radio_field(field, hint=None, label=None, label_visible=true) -%}
|
{% macro render_radio_field(field, hint=None, label=None, label_visible=true) -%}
|
||||||
<div class="form-group mb-3 {% if field.errors %}has-danger{% endif %} {{ kwargs.pop('class_', '') }}">
|
<div class="form-group mb-3 {% if field.errors %}has-danger{% endif %} {{ kwargs.pop('class_', '') }}">
|
||||||
{{ render_label(field, label, label_visible) }}
|
{{ render_label(field, label, label_visible) }}
|
||||||
{% for value, label, checked in field.iter_choices() %}
|
{% for value, label, checked, render_kw in field.iter_choices() %}
|
||||||
<div class="form-check my-1">
|
<div class="form-check my-1">
|
||||||
<label class="form-check-label">
|
<label class="form-check-label">
|
||||||
<input class="form-check-input" type="radio" name="{{ field.id }}" id="{{ field.id }}" value="{{ value }}"{% if checked %} checked{% endif %}>
|
<input class="form-check-input" type="radio" name="{{ field.id }}" id="{{ field.id }}" value="{{ value }}"{% if checked %} checked{% endif %}>
|
||||||
@ -158,7 +158,7 @@
|
|||||||
|
|
||||||
{% macro render_toggle_field(field, icons=[]) -%}
|
{% macro render_toggle_field(field, icons=[]) -%}
|
||||||
<div class="btn-group" role="group" >
|
<div class="btn-group" role="group" >
|
||||||
{% for value, label, checked in field.iter_choices() %}
|
{% for value, label, checked, render_kw in field.iter_choices() %}
|
||||||
<input type="radio" class="btn-check" name="{{ field.id }}" id="{{ field.id }}-{{ value }}" value="{{ value }}" autocomplete="off" {% if checked %} checked{% endif %}>
|
<input type="radio" class="btn-check" name="{{ field.id }}" id="{{ field.id }}-{{ value }}" value="{{ value }}" autocomplete="off" {% if checked %} checked{% endif %}>
|
||||||
<label class="btn btn-primary" for="{{ field.id }}-{{ value }}">
|
<label class="btn btn-primary" for="{{ field.id }}-{{ value }}">
|
||||||
{% set icon = icons[value] %}
|
{% set icon = icons[value] %}
|
||||||
|
Loading…
Reference in New Issue
Block a user