From 71308d25d593223037c4d8b1e0b150a8b06f9311 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Fri, 25 May 2018 17:12:34 +0100 Subject: [PATCH] Fix bugs with edit EditRequests Fixes #63 --- app/models.py | 13 +++++++++++++ app/templates/packages/view.html | 2 +- app/views/packages.py | 7 +++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/models.py b/app/models.py index eac8d8f4..cafdf5d0 100644 --- a/app/models.py +++ b/app/models.py @@ -215,6 +215,8 @@ class PackagePropertyKey(enum.Enum): type = "Type" license = "License" tags = "Tags" + harddeps = "Hard Dependencies" + softdeps = "Soft Dependencies" repo = "Repository" website = "Website" issueTracker = "Issue Tracker" @@ -287,6 +289,17 @@ class Package(db.Model): requests = db.relationship("EditRequest", backref="package", lazy="dynamic") + def __init__(self, package=None): + if package is None: + return + + self.author_id = package.author_id + self.created_at = package.created_at + self.approved = package.approved + + for e in PackagePropertyKey: + setattr(self, e.name, getattr(package, e.name)) + def getAsDictionary(self, base_url): return { "name": self.name, diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html index 59a1501f..c3dbb34b 100644 --- a/app/templates/packages/view.html +++ b/app/templates/packages/view.html @@ -86,7 +86,7 @@
  • Add screenshot
  • {% endif %} {% if current_user.is_authenticated %} - +
  • Suggest Changes
  • {% endif %} {% if package.checkPerm(current_user, "MAKE_RELEASE") %}
  • Create Release
  • diff --git a/app/views/packages.py b/app/views/packages.py index 460864c6..308b3b46 100644 --- a/app/views/packages.py +++ b/app/views/packages.py @@ -266,10 +266,6 @@ def create_edit_editrequest_page(package, id=None): if erequest.package != package: abort(404) - from copy import copy - edited_package = copy(package) - erequest.applyAll(edited_package) - if not erequest.checkPerm(current_user, Permission.EDIT_EDITREQUEST): abort(403) @@ -277,6 +273,9 @@ def create_edit_editrequest_page(package, id=None): flash("Can't edit EditRequest, it has already been merged or rejected", "error") return redirect(erequest.getURL()) + edited_package = Package(package) + erequest.applyAll(edited_package) + form = EditRequestForm(request.form, obj=edited_package) if request.method == "POST" and form.validate():