Add package audit page
This commit is contained in:
parent
7ff92bc7c1
commit
c37f589765
|
@ -527,3 +527,19 @@ def update_from_release(package):
|
|||
checkZipRelease.apply_async((release.id, zippath), task_id=task_id)
|
||||
|
||||
return redirect(url_for("tasks.check", id=task_id, r=package.getEditURL()))
|
||||
|
||||
|
||||
@bp.route("/packages/<author>/<name>/audit/")
|
||||
@login_required
|
||||
@is_package_page
|
||||
def audit(package):
|
||||
if not package.checkPerm(current_user, Permission.EDIT_PACKAGE):
|
||||
abort(403)
|
||||
|
||||
page = get_int_or_abort(request.args.get("page"), 1)
|
||||
num = min(40, get_int_or_abort(request.args.get("n"), 100))
|
||||
|
||||
query = package.audit_log_entries.order_by(db.desc(AuditLogEntry.created_at))
|
||||
|
||||
pagination = query.paginate(page, num, True)
|
||||
return render_template("admin/audit.html", log=pagination.items, pagination=pagination)
|
||||
|
|
|
@ -325,8 +325,8 @@ class Package(db.Model):
|
|||
reviews = db.relationship("PackageReview", back_populates="package", order_by=db.desc("package_review_created_at"),
|
||||
cascade="all, delete, delete-orphan")
|
||||
|
||||
audit_log_entries = db.relationship("AuditLogEntry", foreign_keys="AuditLogEntry.package_id", back_populates="package",
|
||||
order_by=db.desc("audit_log_entry_created_at"))
|
||||
audit_log_entries = db.relationship("AuditLogEntry", foreign_keys="AuditLogEntry.package_id",
|
||||
lazy="dynamic", back_populates="package", order_by=db.desc("audit_log_entry_created_at"))
|
||||
|
||||
notifications = db.relationship("Notification", foreign_keys="Notification.package_id",
|
||||
back_populates="package", cascade="all, delete, delete-orphan")
|
||||
|
@ -530,6 +530,10 @@ class Package(db.Model):
|
|||
return url_for('packages.review',
|
||||
author=self.author.username, name=self.name)
|
||||
|
||||
def getAuditLogURL(self):
|
||||
return url_for('packages.audit',
|
||||
author=self.author.username, name=self.name)
|
||||
|
||||
def getDownloadRelease(self, version=None):
|
||||
for rel in self.releases:
|
||||
if rel.approved and (version is None or
|
||||
|
|
|
@ -322,7 +322,7 @@
|
|||
href="{{ url_for('metapackages.view', name=dep.meta_package.name) }}">
|
||||
{{ dep.meta_package.name }}
|
||||
{% else %}
|
||||
{{ "Excepted package or meta_package in dep!" | throw }}
|
||||
{{ "Expected package or meta_package in dep!" | throw }}
|
||||
{% endif %}</a>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
@ -410,12 +410,17 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
{% if package.approved and package.checkPerm(current_user, "CREATE_THREAD") and current_user != package.author and not current_user.rank.atLeast(current_user.rank.EDITOR) %}
|
||||
{% if package.approved and current_user != package.author %}
|
||||
<a class="float-right"
|
||||
href="{{ url_for('threads.new', pid=package.id) }}">
|
||||
Report a problem with this listing
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
|
||||
<a class="float-right" href="{{ package.getAuditLogURL() }}">
|
||||
See audit log
|
||||
</a>
|
||||
{% endif %}
|
||||
</aside>
|
||||
|
||||
{% if package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
|
||||
|
|
|
@ -59,6 +59,7 @@ def url_set_query(**kwargs):
|
|||
|
||||
|
||||
dargs = dict(args.lists())
|
||||
dargs.update(request.view_args)
|
||||
|
||||
return url_for(request.endpoint, **dargs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue