diff --git a/app/templates/admin/list.html b/app/templates/admin/list.html
index 373f18b5..3c15fa99 100644
--- a/app/templates/admin/list.html
+++ b/app/templates/admin/list.html
@@ -7,6 +7,7 @@
{% block content %}
diff --git a/app/templates/base.html b/app/templates/base.html
index dc316244..7b9f3617 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -63,6 +63,9 @@
{% if current_user.rank == current_user.rank.ADMIN %}
Admin
{% endif %}
+ {% if current_user.rank == current_user.rank.MODERATOR %}
+ Tag Editor
+ {% endif %}
Sign out
diff --git a/app/templates/tags/edit.html b/app/templates/tags/edit.html
new file mode 100644
index 00000000..ccffa7fd
--- /dev/null
+++ b/app/templates/tags/edit.html
@@ -0,0 +1,27 @@
+{% extends "base.html" %}
+
+{% block title %}
+ {% if tag %}
+ Edit {{ tag.title }}
+ {% else %}
+ New tag
+ {% endif %}
+{% endblock %}
+
+{% block content %}
+
+ Back to list |
+ New Tag
+
+
+ {% from "macros/forms.html" import render_field, render_submit_field %}
+
+{% endblock %}
diff --git a/app/templates/tags/list.html b/app/templates/tags/list.html
new file mode 100644
index 00000000..355f62d6
--- /dev/null
+++ b/app/templates/tags/list.html
@@ -0,0 +1,16 @@
+{% extends "base.html" %}
+
+{% block title %}
+Tags
+{% endblock %}
+
+{% block content %}
+
+ New Tag
+
+
+ {% for t in tags %}
+ - {{ t.title }} [{{ t.packages | count }} packages]
+ {% endfor %}
+
+{% endblock %}
diff --git a/app/views/__init__.py b/app/views/__init__.py
index 8bfb178c..c584bb89 100644
--- a/app/views/__init__.py
+++ b/app/views/__init__.py
@@ -43,7 +43,7 @@ def home_page():
packages = query.order_by(db.desc(Package.created_at)).limit(15).all()
return render_template("index.html", packages=packages, count=count)
-from . import users, githublogin, packages, sass, tasks, admin, notifications
+from . import users, githublogin, packages, sass, tasks, admin, notifications, tagseditor
@menu.register_menu(app, ".help", "Help", order=19, endpoint_arguments_constructor=lambda: { 'path': 'help' })
@app.route('//')
diff --git a/app/views/tagseditor.py b/app/views/tagseditor.py
new file mode 100644
index 00000000..533e5005
--- /dev/null
+++ b/app/views/tagseditor.py
@@ -0,0 +1,57 @@
+# Content DB
+# Copyright (C) 2018 rubenwardy
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+
+from flask import *
+from flask_user import *
+from app import app
+from app.models import *
+from flask_wtf import FlaskForm
+from wtforms import *
+from wtforms.validators import *
+from app.utils import rank_required
+
+@app.route("/tags/")
+@rank_required(UserRank.MODERATOR)
+def tag_list_page():
+ return render_template("tags/list.html", tags=Tag.query.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")
+
+@app.route("/tags/new/", methods=["GET", "POST"])
+@app.route("/tags//edit/", methods=["GET", "POST"])
+@rank_required(UserRank.MODERATOR)
+def createedit_tag_page(name=None):
+ tag = None
+ if name is not None:
+ tag = Tag.query.filter_by(name=name).first()
+ if tag is None:
+ abort(404)
+
+ form = TagForm(formdata=request.form, obj=tag)
+ if request.method == "POST" and form.validate():
+ if tag is None:
+ tag = Tag(form.title.data)
+ db.session.add(tag)
+ else:
+ form.populate_obj(tag)
+ db.session.commit()
+ return redirect(url_for("createedit_tag_page", name=tag.name))
+
+ return render_template("tags/edit.html", tag=tag, form=form)