mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Add package creation
This commit is contained in:
parent
5cc49f2828
commit
a8edae1da0
@ -118,7 +118,7 @@ class Package(db.Model):
|
|||||||
author=self.author.username, name=self.name)
|
author=self.author.username, name=self.name)
|
||||||
|
|
||||||
def getEditURL(self):
|
def getEditURL(self):
|
||||||
return url_for("edit_package_page",
|
return url_for("create_edit_package_page",
|
||||||
type=self.type.toName(),
|
type=self.type.toName(),
|
||||||
author=self.author.username, name=self.name)
|
author=self.author.username, name=self.name)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ package.title }}
|
{{ package.title or "Create Package" }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
@ -62,29 +62,41 @@ class PackageForm(FlaskForm):
|
|||||||
title = StringField("Title")
|
title = StringField("Title")
|
||||||
shortDesc = StringField("Short Description")
|
shortDesc = StringField("Short Description")
|
||||||
desc = StringField("Long Description")
|
desc = StringField("Long Description")
|
||||||
type = SelectField("Type", choices=PackageType.choices(), coerce=PackageType.coerce)
|
type = SelectField("Type", choices=PackageType.choices(), coerce=PackageType.coerce, default=PackageType.MOD)
|
||||||
repo = StringField("Repo URL")
|
repo = StringField("Repo URL")
|
||||||
website = StringField("Website URL")
|
website = StringField("Website URL")
|
||||||
issueTracker = StringField("Issue Tracker URL")
|
issueTracker = StringField("Issue Tracker URL")
|
||||||
forums = StringField("Forum Topic ID")
|
forums = StringField("Forum Topic ID")
|
||||||
submit = SubmitField('Save')
|
submit = SubmitField('Save')
|
||||||
|
|
||||||
|
@menu.register_menu(app, '.new', 'Create', order=20)
|
||||||
|
@app.route("/new/", methods=['GET', 'POST'])
|
||||||
@app.route("/<type>s/<author>/<name>/edit/", methods=['GET', 'POST'])
|
@app.route("/<type>s/<author>/<name>/edit/", methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def edit_package_page(type, author, name):
|
def create_edit_package_page(type=None, author=None, name=None):
|
||||||
package = getPageByInfo(type, author, name)
|
package = None
|
||||||
if not package.checkPerm(current_user, Permission.EDIT_PACKAGE):
|
form = None
|
||||||
return redirect(package.getDetailsURL())
|
if type is None:
|
||||||
|
form = PackageForm(formdata=request.form)
|
||||||
|
else:
|
||||||
|
package = getPageByInfo(type, author, name)
|
||||||
|
if not package.checkPerm(current_user, Permission.EDIT_PACKAGE):
|
||||||
|
return redirect(package.getDetailsURL())
|
||||||
|
|
||||||
|
form = PackageForm(formdata=request.form, obj=package)
|
||||||
|
|
||||||
# Initial form class from post data and default data
|
# Initial form class from post data and default data
|
||||||
form = PackageForm(formdata=request.form, obj=package)
|
|
||||||
if request.method == "POST" and form.validate():
|
if request.method == "POST" and form.validate():
|
||||||
# Successfully submitted!
|
# Successfully submitted!
|
||||||
|
if not package:
|
||||||
|
package = Package()
|
||||||
|
package.author = current_user
|
||||||
|
|
||||||
form.populate_obj(package) # copy to row
|
form.populate_obj(package) # copy to row
|
||||||
db.session.commit() # save
|
db.session.commit() # save
|
||||||
return redirect(package.getDetailsURL()) # redirect
|
return redirect(package.getDetailsURL()) # redirect
|
||||||
|
|
||||||
return render_template('package_edit.html', package=package, form=form)
|
return render_template('package_create_edit.html', package=package, form=form)
|
||||||
|
|
||||||
|
|
||||||
class CreatePackageReleaseForm(FlaskForm):
|
class CreatePackageReleaseForm(FlaskForm):
|
||||||
|
Loading…
Reference in New Issue
Block a user