mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 14:02:24 +01:00
Add long description to collections
This commit is contained in:
parent
c04cb14eec
commit
cea315048b
@ -21,7 +21,7 @@ from flask import Blueprint, request, redirect, render_template, flash, abort, u
|
|||||||
from flask_babel import lazy_gettext, gettext
|
from flask_babel import lazy_gettext, gettext
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from wtforms import StringField, BooleanField, SubmitField, FieldList, HiddenField
|
from wtforms import StringField, BooleanField, SubmitField, FieldList, HiddenField, TextAreaField
|
||||||
from wtforms.validators import InputRequired, Length, Optional, Regexp
|
from wtforms.validators import InputRequired, Length, Optional, Regexp
|
||||||
|
|
||||||
from app.models import Collection, db, Package, Permission, CollectionPackage, User, UserRank, AuditSeverity
|
from app.models import Collection, db, Package, Permission, CollectionPackage, User, UserRank, AuditSeverity
|
||||||
@ -77,6 +77,7 @@ class CollectionForm(FlaskForm):
|
|||||||
name = StringField("URL", [Optional(), Length(1, 20), Regexp("^[a-z0-9_]", 0,
|
name = StringField("URL", [Optional(), Length(1, 20), Regexp("^[a-z0-9_]", 0,
|
||||||
"Lower case letters (a-z), digits (0-9), and underscores (_) only")])
|
"Lower case letters (a-z), digits (0-9), and underscores (_) only")])
|
||||||
short_description = StringField(lazy_gettext("Short Description"), [Optional(), Length(0, 200)])
|
short_description = StringField(lazy_gettext("Short Description"), [Optional(), Length(0, 200)])
|
||||||
|
long_description = TextAreaField(lazy_gettext("Page Content"), [Optional()], filters=[nonempty_or_none])
|
||||||
private = BooleanField(lazy_gettext("Private"))
|
private = BooleanField(lazy_gettext("Private"))
|
||||||
descriptions = FieldList(
|
descriptions = FieldList(
|
||||||
StringField(lazy_gettext("Short Description"), [Optional(), Length(0, 500)], filters=[nonempty_or_none]),
|
StringField(lazy_gettext("Short Description"), [Optional(), Length(0, 500)], filters=[nonempty_or_none]),
|
||||||
|
@ -44,6 +44,7 @@ class Collection(db.Model):
|
|||||||
name = db.Column(db.Unicode(100), nullable=False)
|
name = db.Column(db.Unicode(100), nullable=False)
|
||||||
title = db.Column(db.Unicode(100), nullable=False)
|
title = db.Column(db.Unicode(100), nullable=False)
|
||||||
short_description = db.Column(db.Unicode(200), nullable=False)
|
short_description = db.Column(db.Unicode(200), nullable=False)
|
||||||
|
long_description = db.Column(db.UnicodeText, nullable=True)
|
||||||
created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
|
created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
|
||||||
private = db.Column(db.Boolean, nullable=False, default=False)
|
private = db.Column(db.Boolean, nullable=False, default=False)
|
||||||
|
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
{{ render_field(form.short_description) }}
|
{{ render_field(form.short_description) }}
|
||||||
{{ render_checkbox_field(form.private, class_="my-3") }}
|
{{ render_checkbox_field(form.private, class_="my-3") }}
|
||||||
|
{% if collection %}
|
||||||
|
{{ render_field(form.long_description, fieldclass="form-control markdown") }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if collection and collection.items %}
|
{% if collection and collection.items %}
|
||||||
<h2>{{ _("Packages") }}</h2>
|
<h2>{{ _("Packages") }}</h2>
|
||||||
|
@ -56,6 +56,11 @@
|
|||||||
<p>
|
<p>
|
||||||
{{ collection.short_description }}
|
{{ collection.short_description }}
|
||||||
</p>
|
</p>
|
||||||
|
{% if collection.long_description %}
|
||||||
|
<div class="markdown mb-5">
|
||||||
|
{{ collection.long_description | markdown }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<section class="mt-5">
|
<section class="mt-5">
|
||||||
<h2 class="sr-only">{{ _("Packages") }}</h2>
|
<h2 class="sr-only">{{ _("Packages") }}</h2>
|
||||||
|
25
migrations/versions/20f2aa2f40b9_.py
Normal file
25
migrations/versions/20f2aa2f40b9_.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 20f2aa2f40b9
|
||||||
|
Revises: 89dfa0043f9c
|
||||||
|
Create Date: 2023-08-19 01:35:20.100549
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '20f2aa2f40b9'
|
||||||
|
down_revision = '89dfa0043f9c'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.add_column('collection', sa.Column('long_description', sa.UnicodeText(), nullable=True, server_default=None))
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
with op.batch_alter_table('collection', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('long_description')
|
Loading…
Reference in New Issue
Block a user