diff --git a/app/models.py b/app/models.py index 2f85337..c97bdd9 100644 --- a/app/models.py +++ b/app/models.py @@ -107,15 +107,15 @@ class PackageType(enum.Enum): class PackagePropertyKey(enum.Enum): - name = "name" - title = "title" - shortDesc = "shortDesc" - desc = "desc" - type = "type" - repo = "repo" - website = "website" - issueTracker = "issueTracker" - forums = "forums" + name = "Name" + title = "Title" + shortDesc = "Short Description" + desc = "Description" + type = "Type" + repo = "Repository" + website = "Website" + issueTracker = "Issue Tracker" + forums = "Forum Topic ID" class Package(db.Model): @@ -248,17 +248,26 @@ class EditRequest(db.Model): package_id = db.Column(db.Integer, db.ForeignKey("package.id")) author_id = db.Column(db.Integer, db.ForeignKey("user.id")) - title = db.Column(db.String(100), nullable=False) + title = db.Column(db.String(100), nullable=False) desc = db.Column(db.String(1000), nullable=True) changes = db.relationship("EditRequestChange", backref="request", 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): for change in self.changes: change.apply(package) + + class EditRequestChange(db.Model): id = db.Column(db.Integer, primary_key=True) diff --git a/app/templates/packages/create_editrequest.html b/app/templates/packages/editrequest_create.html similarity index 100% rename from app/templates/packages/create_editrequest.html rename to app/templates/packages/editrequest_create.html diff --git a/app/templates/packages/editrequest_view.html b/app/templates/packages/editrequest_view.html new file mode 100644 index 0000000..b7abbbe --- /dev/null +++ b/app/templates/packages/editrequest_view.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} + +{% block title %} + {{ request.title }} - {{ package.title }} +{% endblock %} + +{% block content %} +

{{ request.title }} by {{ request.author.display_name }}

+

+ Package: {{ package.title }} +

+

+ {% if request.desc %} + {{ request.desc }} + {% else %} + No description given + {% endif %} +

+ + + + + + + + + {% for change in request.changes %} + + + + + + {% endfor %} +{% endblock %} diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html index 4ccb4d7..9ed7def 100644 --- a/app/templates/packages/view.html +++ b/app/templates/packages/view.html @@ -86,4 +86,20 @@
  • No releases available.
  • {% endfor %} + + {% if current_user.is_authenticated or package.requests %} +

    Edit Requests

    + + + {% endif %} {% endblock %} diff --git a/app/views/packages.py b/app/views/packages.py index a314d79..6261606 100644 --- a/app/views/packages.py +++ b/app/views/packages.py @@ -198,7 +198,7 @@ class UnresolvedPackage(Package): @app.route("/s///requests/new/", methods=["GET","POST"]) @login_required -def create_editrequest_page(ptype=None, author=None, name=None): +def create_editrequest_page(ptype, author, name): package = getPageByInfo(ptype, author, name) form = EditRequestForm(request.form, obj=package) @@ -243,7 +243,18 @@ def create_editrequest_page(ptype=None, author=None, name=None): else: 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("/s///requests//") +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):
    PropertyOldNew
    {{ change.key.value }}{{ change.oldValue }}{{ change.newValue }}