diff --git a/app/blueprints/admin/tagseditor.py b/app/blueprints/admin/tagseditor.py
index 39d69e89..3d351ee2 100644
--- a/app/blueprints/admin/tagseditor.py
+++ b/app/blueprints/admin/tagseditor.py
@@ -33,9 +33,10 @@ def tag_list():
return render_template("admin/tags/list.html", tags=Tag.query.order_by(db.asc(Tag.title)).all())
class TagForm(FlaskForm):
- title = StringField("Title", [InputRequired(), Length(3,100)])
- name = StringField("Name", [Optional(), Length(1, 20), Regexp("^[a-z0-9_]", 0, "Lower case letters (a-z), digits (0-9), and underscores (_) only")])
- submit = SubmitField("Save")
+ title = StringField("Title", [InputRequired(), Length(3,100)])
+ description = TextAreaField("Description", [InputRequired(), Length(0, 500)])
+ name = StringField("Name", [Optional(), Length(1, 20), Regexp("^[a-z0-9_]", 0, "Lower case letters (a-z), digits (0-9), and underscores (_) only")])
+ submit = SubmitField("Save")
@bp.route("/tags/new/", methods=["GET", "POST"])
@bp.route("/tags//edit/", methods=["GET", "POST"])
@@ -54,6 +55,7 @@ def create_edit_tag(name=None):
if request.method == "POST" and form.validate():
if tag is None:
tag = Tag(form.title.data)
+ tag.description = form.description.data
db.session.add(tag)
else:
form.populate_obj(tag)
diff --git a/app/blueprints/packages/packages.py b/app/blueprints/packages/packages.py
index 5a775b2c..3b9ca4af 100644
--- a/app/blueprints/packages/packages.py
+++ b/app/blueprints/packages/packages.py
@@ -197,6 +197,12 @@ def download(package):
return redirect(release.getDownloadURL(), code=302)
+def makeLabel(obj):
+ if obj.description:
+ return "{}: {}".format(obj.title, obj.description)
+ else:
+ return obj.title
+
class PackageForm(FlaskForm):
name = StringField("Name (Technical)", [InputRequired(), Length(1, 100), Regexp("^[a-z0-9_]+$", 0, "Lower case letters (a-z), digits (0-9), and underscores (_) only")])
title = StringField("Title (Human-readable)", [InputRequired(), Length(3, 100)])
@@ -206,8 +212,8 @@ class PackageForm(FlaskForm):
license = QuerySelectField("License", [DataRequired()], allow_blank=True, query_factory=lambda: License.query.order_by(db.asc(License.name)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
media_license = QuerySelectField("Media License", [DataRequired()], allow_blank=True, query_factory=lambda: License.query.order_by(db.asc(License.name)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
provides_str = StringField("Provides (mods included in package)", [Optional()])
- tags = QuerySelectMultipleField('Tags', query_factory=lambda: Tag.query.order_by(db.asc(Tag.name)), get_pk=lambda a: a.id, get_label=lambda a: a.title)
- content_warnings = QuerySelectMultipleField('Content Warnings', query_factory=lambda: ContentWarning.query.order_by(db.asc(ContentWarning.name)), get_pk=lambda a: a.id, get_label=lambda a: a.title)
+ tags = QuerySelectMultipleField('Tags', query_factory=lambda: Tag.query.order_by(db.asc(Tag.name)), get_pk=lambda a: a.id, get_label=makeLabel)
+ content_warnings = QuerySelectMultipleField('Content Warnings', query_factory=lambda: ContentWarning.query.order_by(db.asc(ContentWarning.name)), get_pk=lambda a: a.id, get_label=makeLabel)
harddep_str = StringField("Hard Dependencies", [Optional()])
softdep_str = StringField("Soft Dependencies", [Optional()])
repo = StringField("VCS Repository URL", [Optional(), URL()], filters = [lambda x: x or None])
diff --git a/app/models.py b/app/models.py
index b2dbcc04..6b7d0672 100644
--- a/app/models.py
+++ b/app/models.py
@@ -840,11 +840,11 @@ class ContentWarning(db.Model):
self.name = regex.sub("", self.title.lower().replace(" ", "_"))
-
class Tag(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), unique=True, nullable=False)
title = db.Column(db.String(100), nullable=False)
+ description = db.Column(db.String(500), nullable=True, default=None)
backgroundColor = db.Column(db.String(6), nullable=False)
textColor = db.Column(db.String(6), nullable=False)
views = db.Column(db.Integer, nullable=False, default=0)
diff --git a/app/public/static/tagselector.js b/app/public/static/tagselector.js
index f0994151..566f88a6 100644
--- a/app/public/static/tagselector.js
+++ b/app/public/static/tagselector.js
@@ -30,6 +30,11 @@
});
function addTag(id, text) {
+ const idx = text.indexOf(':');
+ if (idx > 0) {
+ text = text.substr(0, idx);
+ }
+
$('')
.text(text + ' ')
.data("id", id)
diff --git a/app/templates/admin/tags/edit.html b/app/templates/admin/tags/edit.html
index f25312e5..bb8d4625 100644
--- a/app/templates/admin/tags/edit.html
+++ b/app/templates/admin/tags/edit.html
@@ -17,6 +17,7 @@
{{ form.hidden_tag() }}
{{ render_field(form.title) }}
+ {{ render_field(form.description) }}
{% if tag %}
{{ render_field(form.name) }}
{% endif %}
diff --git a/app/templates/admin/tags/list.html b/app/templates/admin/tags/list.html
index 8db66ca8..14baf02e 100644
--- a/app/templates/admin/tags/list.html
+++ b/app/templates/admin/tags/list.html
@@ -14,13 +14,16 @@
-
-
+
{{ _("Name") }}
+
+ {{ _("Description") }}
+
+
{{ _("Views") }}
@@ -35,10 +38,14 @@
-
+
{{ t.title }}
+
+ {{ t.description or "" }}
+
+
{{ t.views }}
diff --git a/app/templates/macros/forms.html b/app/templates/macros/forms.html
index 9c56a484..02c366b2 100644
--- a/app/templates/macros/forms.html
+++ b/app/templates/macros/forms.html
@@ -16,7 +16,7 @@
{% macro form_scripts() -%}
-
+
{% endmacro %}
{% macro package_lists() -%}
diff --git a/migrations/versions/3a24fc02365e_.py b/migrations/versions/3a24fc02365e_.py
new file mode 100644
index 00000000..4e85f9b4
--- /dev/null
+++ b/migrations/versions/3a24fc02365e_.py
@@ -0,0 +1,28 @@
+"""empty message
+
+Revision ID: 3a24fc02365e
+Revises: b370c3eb4227
+Create Date: 2020-07-17 20:58:31.130449
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '3a24fc02365e'
+down_revision = 'b370c3eb4227'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column('tag', sa.Column('description', sa.String(length=500), nullable=True, server_default=None))
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_column('tag', 'description')
+ # ### end Alembic commands ###