Add long description to collections
This commit is contained in:
@@ -21,7 +21,7 @@ from flask import Blueprint, request, redirect, render_template, flash, abort, u
|
||||
from flask_babel import lazy_gettext, gettext
|
||||
from flask_login import current_user, login_required
|
||||
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 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,
|
||||
"Lower case letters (a-z), digits (0-9), and underscores (_) only")])
|
||||
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"))
|
||||
descriptions = FieldList(
|
||||
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)
|
||||
title = db.Column(db.Unicode(100), 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)
|
||||
private = db.Column(db.Boolean, nullable=False, default=False)
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
|
||||
{{ render_field(form.short_description) }}
|
||||
{{ 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 %}
|
||||
<h2>{{ _("Packages") }}</h2>
|
||||
|
||||
@@ -56,6 +56,11 @@
|
||||
<p>
|
||||
{{ collection.short_description }}
|
||||
</p>
|
||||
{% if collection.long_description %}
|
||||
<div class="markdown mb-5">
|
||||
{{ collection.long_description | markdown }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<section class="mt-5">
|
||||
<h2 class="sr-only">{{ _("Packages") }}</h2>
|
||||
|
||||
Reference in New Issue
Block a user