Add thread list to package view

This commit is contained in:
rubenwardy 2018-07-28 15:08:08 +01:00
parent 8c3b1c8c95
commit df8d05f09d
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
2 changed files with 26 additions and 7 deletions

View File

@ -57,11 +57,13 @@
{% if package.author == current_user or package.checkPerm(current_user, "APPROVE_NEW") %}
{% if review_thread %}
<h2>&#x1f512; {{ review_thread.title }}</h2>
<p><i>
This thread is only visible to the package owner and users of
Editor rank or above.
</i></p>
<h2>{% if review_thread.private %}&#x1f512;{% endif %} {{ review_thread.title }}</h2>
{% if review_thread.private %}
<p><i>
This thread is only visible to the package owner and users of
Editor rank or above.
</i></p>
{% endif %}
{% from "macros/threads.html" import render_thread %}
{{ render_thread(review_thread, current_user) }}
@ -313,4 +315,11 @@
{% endfor %}
</ul>
{% endif %}
{% if threads %}
<h3>Threads</h3>
{% from "macros/threads.html" import render_threadlist %}
{{ render_threadlist(threads) }}
{% endif %}
{% endblock %}

View File

@ -29,6 +29,7 @@ from flask_wtf import FlaskForm
from wtforms import *
from wtforms.validators import *
from wtforms.ext.sqlalchemy.fields import QuerySelectField, QuerySelectMultipleField
from sqlalchemy import or_
def build_packages_query():
type_name = request.args.get("type")
@ -112,7 +113,7 @@ def package_page(package):
releases = getReleases(package)
requests = [r for r in package.requests if r.status == 0]
review_thread = Thread.query.filter_by(package_id=package.id, private=True).first()
review_thread = package.review_thread
if review_thread is not None and not review_thread.checkPerm(current_user, Permission.SEE_THREAD):
review_thread = None
@ -137,10 +138,19 @@ def package_page(package):
topic_error = "<br />".join(errors)
threads = Thread.query.filter_by(package_id=package.id)
if not current_user.is_authenticated:
threads = threads.filter_by(private=False)
elif not current_user.rank.atLeast(UserRank.EDITOR) and not current_user == package.author:
threads = threads.filter(or_(Thread.private == False, Thread.author == current_user))
return render_template("packages/view.html", \
package=package, releases=releases, requests=requests, \
alternatives=alternatives, similar_topics=similar_topics, \
review_thread=review_thread, topic_error=topic_error, topic_error_lvl=topic_error_lvl)
review_thread=review_thread, topic_error=topic_error, topic_error_lvl=topic_error_lvl, \
threads=threads.all())
@app.route("/packages/<author>/<name>/download/")