mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-21 05:21:28 +01:00
Add EditRequest view page
This commit is contained in:
parent
dcfd2b0003
commit
a5042a986a
@ -107,15 +107,15 @@ class PackageType(enum.Enum):
|
|||||||
|
|
||||||
|
|
||||||
class PackagePropertyKey(enum.Enum):
|
class PackagePropertyKey(enum.Enum):
|
||||||
name = "name"
|
name = "Name"
|
||||||
title = "title"
|
title = "Title"
|
||||||
shortDesc = "shortDesc"
|
shortDesc = "Short Description"
|
||||||
desc = "desc"
|
desc = "Description"
|
||||||
type = "type"
|
type = "Type"
|
||||||
repo = "repo"
|
repo = "Repository"
|
||||||
website = "website"
|
website = "Website"
|
||||||
issueTracker = "issueTracker"
|
issueTracker = "Issue Tracker"
|
||||||
forums = "forums"
|
forums = "Forum Topic ID"
|
||||||
|
|
||||||
|
|
||||||
class Package(db.Model):
|
class Package(db.Model):
|
||||||
@ -255,10 +255,19 @@ class EditRequest(db.Model):
|
|||||||
changes = db.relationship("EditRequestChange", backref="request",
|
changes = db.relationship("EditRequestChange", backref="request",
|
||||||
lazy="dynamic")
|
lazy="dynamic")
|
||||||
|
|
||||||
|
def getURL(self):
|
||||||
|
return url_for("view_editrequest_page",
|
||||||
|
ptype=self.package.type.toName(),
|
||||||
|
author=self.package.author.username,
|
||||||
|
name=self.package.name,
|
||||||
|
id=self.id)
|
||||||
|
|
||||||
def applyAll(self, package):
|
def applyAll(self, package):
|
||||||
for change in self.changes:
|
for change in self.changes:
|
||||||
change.apply(package)
|
change.apply(package)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class EditRequestChange(db.Model):
|
class EditRequestChange(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
|
||||||
|
34
app/templates/packages/editrequest_view.html
Normal file
34
app/templates/packages/editrequest_view.html
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{ request.title }} - {{ package.title }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>{{ request.title }} by {{ request.author.display_name }}</h1>
|
||||||
|
<p>
|
||||||
|
Package: <a href="{{ package.getDetailsURL() }}">{{ package.title }}</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{% if request.desc %}
|
||||||
|
{{ request.desc }}
|
||||||
|
{% else %}
|
||||||
|
<i>No description given</i>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Property</th>
|
||||||
|
<th>Old</th>
|
||||||
|
<th>New</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% for change in request.changes %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ change.key.value }}</td>
|
||||||
|
<td>{{ change.oldValue }}</td>
|
||||||
|
<td>{{ change.newValue }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
@ -86,4 +86,20 @@
|
|||||||
<li>No releases available.</li>
|
<li>No releases available.</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
{% if current_user.is_authenticated or package.requests %}
|
||||||
|
<h3>Edit Requests</h3>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{% for r in package.requests %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ r.getURL() }}">{{ r.title }}</a>
|
||||||
|
by
|
||||||
|
<a href="{{ url_for('user_profile_page', username=r.author.username) }}">{{ r.author.display_name }}</a>
|
||||||
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li>No edit requests have been made.</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -198,7 +198,7 @@ class UnresolvedPackage(Package):
|
|||||||
|
|
||||||
@app.route("/<ptype>s/<author>/<name>/requests/new/", methods=["GET","POST"])
|
@app.route("/<ptype>s/<author>/<name>/requests/new/", methods=["GET","POST"])
|
||||||
@login_required
|
@login_required
|
||||||
def create_editrequest_page(ptype=None, author=None, name=None):
|
def create_editrequest_page(ptype, author, name):
|
||||||
package = getPageByInfo(ptype, author, name)
|
package = getPageByInfo(ptype, author, name)
|
||||||
|
|
||||||
form = EditRequestForm(request.form, obj=package)
|
form = EditRequestForm(request.form, obj=package)
|
||||||
@ -243,7 +243,18 @@ def create_editrequest_page(ptype=None, author=None, name=None):
|
|||||||
else:
|
else:
|
||||||
flash("No changes detected", "warning")
|
flash("No changes detected", "warning")
|
||||||
|
|
||||||
return render_template("packages/create_editrequest.html", package=package, form=form)
|
return render_template("packages/editrequest_create.html", package=package, form=form)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/<ptype>s/<author>/<name>/requests/<id>/")
|
||||||
|
def view_editrequest_page(ptype, author, name, id):
|
||||||
|
package = getPageByInfo(ptype, author, name)
|
||||||
|
|
||||||
|
erequest = EditRequest.query.filter_by(id=id).first()
|
||||||
|
if erequest is None:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
return render_template("packages/editrequest_view.html", package=package, request=erequest)
|
||||||
|
|
||||||
|
|
||||||
class CreatePackageReleaseForm(FlaskForm):
|
class CreatePackageReleaseForm(FlaskForm):
|
||||||
|
Loading…
Reference in New Issue
Block a user