diff --git a/app/templates/admin/licenses/edit.html b/app/templates/admin/licenses/edit.html
new file mode 100644
index 00000000..c68b17f1
--- /dev/null
+++ b/app/templates/admin/licenses/edit.html
@@ -0,0 +1,25 @@
+{% extends "base.html" %}
+
+{% block title %}
+ {% if license %}
+ Edit {{ license.name }}
+ {% else %}
+ New license
+ {% endif %}
+{% endblock %}
+
+{% block content %}
+
+ Back to list |
+ New License
+
+
+ {% from "macros/forms.html" import render_field, render_submit_field %}
+
+{% endblock %}
diff --git a/app/templates/admin/licenses/list.html b/app/templates/admin/licenses/list.html
new file mode 100644
index 00000000..43856f55
--- /dev/null
+++ b/app/templates/admin/licenses/list.html
@@ -0,0 +1,16 @@
+{% extends "base.html" %}
+
+{% block title %}
+Licenses
+{% endblock %}
+
+{% block content %}
+
+ New Tag
+
+
+ {% for l in licenses %}
+ - {{ l.name }} [{{ l.is_foss and "Free" or "Non-free"}}]
+ {% endfor %}
+
+{% endblock %}
diff --git a/app/templates/admin/list.html b/app/templates/admin/list.html
index 4763bdc1..a2ac6d53 100644
--- a/app/templates/admin/list.html
+++ b/app/templates/admin/list.html
@@ -8,6 +8,7 @@
@@ -17,12 +18,12 @@
diff --git a/app/templates/tags/edit.html b/app/templates/admin/tags/edit.html
similarity index 100%
rename from app/templates/tags/edit.html
rename to app/templates/admin/tags/edit.html
diff --git a/app/templates/tags/list.html b/app/templates/admin/tags/list.html
similarity index 100%
rename from app/templates/tags/list.html
rename to app/templates/admin/tags/list.html
diff --git a/app/templates/base.html b/app/templates/base.html
index 126f56fd..35a2ac6a 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -65,6 +65,7 @@
{% endif %}
{% if current_user.rank == current_user.rank.MODERATOR %}
Tag Editor
+ License Editor
{% endif %}
Sign out
diff --git a/app/views/__init__.py b/app/views/__init__.py
index 8695a4ed..412c236e 100644
--- a/app/views/__init__.py
+++ b/app/views/__init__.py
@@ -53,7 +53,8 @@ def home_page():
return render_template("index.html", new=new, popular=popular, count=count)
from . import users, githublogin, packages, meta, threads, api
-from . import sass, tasks, admin, notifications, tagseditor, thumbnails
+from . import tasks, admin, notifications, tagseditor, licenseseditor
+from . import sass, thumbnails
@menu.register_menu(app, ".help", "Help", order=19, endpoint_arguments_constructor=lambda: { 'path': 'help' })
@app.route('//')
diff --git a/app/views/licenseseditor.py b/app/views/licenseseditor.py
new file mode 100644
index 00000000..9f1a0ce4
--- /dev/null
+++ b/app/views/licenseseditor.py
@@ -0,0 +1,62 @@
+# 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("/licenses/")
+@rank_required(UserRank.MODERATOR)
+def license_list_page():
+ return render_template("admin/licenses/list.html", licenses=License.query.order_by(db.asc(License.name)).all())
+
+class LicenseForm(FlaskForm):
+ name = StringField("Name", [InputRequired(), Length(3,100)])
+ is_foss = BooleanField("Is FOSS")
+ submit = SubmitField("Save")
+
+@app.route("/licenses/new/", methods=["GET", "POST"])
+@app.route("/licenses//edit/", methods=["GET", "POST"])
+@rank_required(UserRank.MODERATOR)
+def createedit_license_page(name=None):
+ license = None
+ if name is not None:
+ license = License.query.filter_by(name=name).first()
+ if license is None:
+ abort(404)
+
+ form = LicenseForm(formdata=request.form, obj=license)
+ if request.method == "GET":
+ form.is_foss.data = True
+ elif request.method == "POST" and form.validate():
+ if license is None:
+ license = License(form.name.data)
+ db.session.add(license)
+ flash("Created license " + form.name.data, "success")
+ else:
+ flash("Updated license " + form.name.data, "success")
+
+ form.populate_obj(license)
+ db.session.commit()
+ return redirect(url_for("createedit_license_page", name=license.name))
+
+ return render_template("admin/licenses/edit.html", license=license, form=form)
diff --git a/app/views/packages/__init__.py b/app/views/packages/__init__.py
index 4d9f791a..8e0410f0 100644
--- a/app/views/packages/__init__.py
+++ b/app/views/packages/__init__.py
@@ -175,8 +175,8 @@ class PackageForm(FlaskForm):
shortDesc = StringField("Short Description (Plaintext)", [InputRequired(), Length(1,200)])
desc = TextAreaField("Long Description (Markdown)", [Optional(), Length(0,10000)])
type = SelectField("Type", [InputRequired()], choices=PackageType.choices(), coerce=PackageType.coerce, default=PackageType.MOD)
- license = QuerySelectField("License", [InputRequired()], query_factory=lambda: License.query, get_pk=lambda a: a.id, get_label=lambda a: a.name)
- media_license = QuerySelectField("Media License", [InputRequired()], query_factory=lambda: License.query, get_pk=lambda a: a.id, get_label=lambda a: a.name)
+ license = QuerySelectField("License", [InputRequired()], 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", [InputRequired()], 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(), Length(0,1000)])
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)
harddep_str = StringField("Hard Dependencies", [Optional(), Length(0,1000)])
diff --git a/app/views/tagseditor.py b/app/views/tagseditor.py
index 5181c0b8..adcbec89 100644
--- a/app/views/tagseditor.py
+++ b/app/views/tagseditor.py
@@ -27,7 +27,7 @@ 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.order_by(db.asc(Tag.title)).all())
+ return render_template("admin/tagslist.html", tags=Tag.query.order_by(db.asc(Tag.title)).all())
class TagForm(FlaskForm):
title = StringField("Title", [InputRequired(), Length(3,100)])
@@ -54,4 +54,4 @@ def createedit_tag_page(name=None):
db.session.commit()
return redirect(url_for("createedit_tag_page", name=tag.name))
- return render_template("tags/edit.html", tag=tag, form=form)
+ return render_template("admin/tags/edit.html", tag=tag, form=form)
diff --git a/setup.py b/setup.py
index e106aa2e..df576985 100644
--- a/setup.py
+++ b/setup.py
@@ -362,12 +362,12 @@ for tag in ["Inventory", "Mapgen", "Building", \
licenses = {}
for license in ["GPLv2.1", "GPLv3", "LGPLv2.1", "LGPLv3", "AGPLv2.1", "AGPLv3",
"Apache", "BSD 3-Clause", "BSD 2-Clause", "CC0", "CC-BY-SA",
- "CC-BY", "MIT", "ZLib"]:
+ "CC-BY", "MIT", "ZLib", "Other (Free)"]:
row = License(license)
licenses[row.name] = row
db.session.add(row)
-for license in ["CC-BY-NC-SA"]:
+for license in ["CC-BY-NC-SA", "Other (Non-free)"]:
row = License(license, False)
licenses[row.name] = row
db.session.add(row)