diff --git a/app/blueprints/admin/admin.py b/app/blueprints/admin/admin.py index 29a8402..d844d90 100644 --- a/app/blueprints/admin/admin.py +++ b/app/blueprints/admin/admin.py @@ -56,7 +56,7 @@ def admin_page(): import time time.sleep(0.1) - return redirect(url_for("todo.view")) + return redirect(url_for("todo.view_editor")) elif action == "reimportpackages": tasks = [] @@ -72,7 +72,7 @@ def admin_page(): import time time.sleep(0.1) - return redirect(url_for("todo.view")) + return redirect(url_for("todo.view_editor")) elif action == "importforeign": releases = PackageRelease.query.filter(PackageRelease.url.like("http%")).all() @@ -87,7 +87,7 @@ def admin_page(): import time time.sleep(0.1) - return redirect(url_for("todo.view")) + return redirect(url_for("todo.view_editor")) elif action == "importmodlist": task = importTopicList.delay() diff --git a/app/blueprints/todo/__init__.py b/app/blueprints/todo/__init__.py index fe7d2af..095a864 100644 --- a/app/blueprints/todo/__init__.py +++ b/app/blueprints/todo/__init__.py @@ -26,7 +26,7 @@ bp = Blueprint("todo", __name__) @bp.route("/todo/", methods=["GET", "POST"]) @login_required -def view(): +def view_editor(): canApproveNew = Permission.APPROVE_NEW.check(current_user) canApproveRel = Permission.APPROVE_RELEASE.check(current_user) canApproveScn = Permission.APPROVE_SCREENSHOT.check(current_user) @@ -57,17 +57,13 @@ def view(): PackageScreenshot.query.update({ "approved": True }) db.session.commit() - return redirect(url_for("todo.view")) + return redirect(url_for("todo.view_editor")) else: abort(400) topic_query = ForumTopic.query \ .filter_by(discarded=False) - total_topics = topic_query.count() - topics_to_add = topic_query \ - .filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \ - .count() total_packages = Package.query.filter_by(state=PackageState.APPROVED).count() total_to_tag = Package.query.filter_by(state=PackageState.APPROVED, tags=None).count() @@ -77,12 +73,15 @@ def view(): .filter(MetaPackage.dependencies.any(optional=False)) \ .order_by(db.asc(MetaPackage.name)).count() - return render_template("todo/list.html", title="Reports and Work Queue", - packages=packages, wip_packages=wip_packages, releases=releases, screenshots=screenshots, - canApproveNew=canApproveNew, canApproveRel=canApproveRel, canApproveScn=canApproveScn, - topics_to_add=topics_to_add, total_topics=total_topics, + outdated_packages = Package.query \ + .filter(Package.state == PackageState.APPROVED, + Package.update_config.has(outdated=True)).count() + + return render_template("todo/editor.html", current_tab="editor", + packages=packages, wip_packages=wip_packages, releases=releases, screenshots=screenshots, + canApproveNew=canApproveNew, canApproveRel=canApproveRel, canApproveScn=canApproveScn, total_packages=total_packages, total_to_tag=total_to_tag, - unfulfilled_meta_packages=unfulfilled_meta_packages) + unfulfilled_meta_packages=unfulfilled_meta_packages, outdated_packages=outdated_packages) @bp.route("/todo/topics/") @@ -111,7 +110,7 @@ def topics(): show_discarded=qb.show_discarded, n=num, sort=qb.order_by) \ if query.has_prev else None - return render_template("todo/topics.html", topics=query.items, total=total, + return render_template("todo/topics.html", current_tab="topics", topics=query.items, total=total, topic_count=topic_count, query=qb.search, show_discarded=qb.show_discarded, next_url=next_url, prev_url=prev_url, page=page, page_max=query.pages, n=num, sort_by=qb.order_by) @@ -143,3 +142,44 @@ def metapackages(): .order_by(db.asc(MetaPackage.name)).all() return render_template("todo/metapackages.html", mpackages=mpackages) + + +@bp.route("/users//todo/") +@login_required +def view_user(username): + user : User = User.query.filter_by(username=username).first() + if not user: + abort(404) + + if current_user != user and not current_user.rank.atLeast(UserRank.EDITOR): + abort(403) + + unapproved_packages = user.packages \ + .filter(or_(Package.state == PackageState.WIP, + Package.state == PackageState.CHANGES_NEEDED)) \ + .order_by(db.asc(Package.created_at)).all() + + outdated_packages = user.maintained_packages \ + .filter(Package.state != PackageState.DELETED, + Package.update_config.has(outdated=True)) \ + .order_by(db.asc(Package.title)).all() + + topics_to_add = ForumTopic.query \ + .filter_by(author_id=user.id) \ + .filter(~ db.exists().where(Package.forums == ForumTopic.topic_id)) \ + .order_by(db.asc(ForumTopic.name), db.asc(ForumTopic.title)) \ + .all() + + return render_template("todo/user.html", current_tab="user", user=user, + unapproved_packages=unapproved_packages, outdated_packages=outdated_packages, + topics_to_add=topics_to_add) + + +@bp.route("/todo/outdated/") +@login_required +def outdated(): + outdated_packages = Package.query \ + .filter(Package.state == PackageState.APPROVED, + Package.update_config.has(outdated=True)).all() + + return render_template("todo/outdated.html", current_tab="outdated", outdated_packages=outdated_packages) diff --git a/app/blueprints/users/profile.py b/app/blueprints/users/profile.py index e4d274a..782945a 100644 --- a/app/blueprints/users/profile.py +++ b/app/blueprints/users/profile.py @@ -54,17 +54,8 @@ def profile(username): packages = packages.filter_by(state=PackageState.APPROVED) packages = packages.order_by(db.asc(Package.title)) - topics_to_add = None - if current_user == user or user.checkPerm(current_user, Permission.CHANGE_AUTHOR): - topics_to_add = ForumTopic.query \ - .filter_by(author_id=user.id) \ - .filter(~ db.exists().where(Package.forums == ForumTopic.topic_id)) \ - .order_by(db.asc(ForumTopic.name), db.asc(ForumTopic.title)) \ - .all() - # Process GET or invalid POST - return render_template("users/profile.html", - user=user, packages=packages, topics_to_add=topics_to_add) + return render_template("users/profile.html", user=user, packages=packages) @bp.route("/users//check/", methods=["POST"]) diff --git a/app/models/users.py b/app/models/users.py index a199715..17df6cb 100644 --- a/app/models/users.py +++ b/app/models/users.py @@ -167,6 +167,8 @@ class User(db.Model, UserMixin): audit_log_entries = db.relationship("AuditLogEntry", foreign_keys="AuditLogEntry.causer_id", back_populates="causer", order_by=desc("audit_log_entry_created_at"), lazy="dynamic") + maintained_packages = db.relationship("Package", lazy="dynamic", secondary="maintainers") + packages = db.relationship("Package", back_populates="author", lazy="dynamic") reviews = db.relationship("PackageReview", back_populates="author", order_by=db.desc("package_review_created_at"), cascade="all, delete, delete-orphan") tokens = db.relationship("APIToken", back_populates="owner", lazy="dynamic", cascade="all, delete, delete-orphan") diff --git a/app/scss/components.scss b/app/scss/components.scss index 8d81eec..63a2d93 100644 --- a/app/scss/components.scss +++ b/app/scss/components.scss @@ -139,3 +139,12 @@ blockquote { margin-bottom: 0; } } + +.tabs-container { + background: #1c1c1c; + border-bottom: 1px solid #444; + + .nav { + border-bottom: none; + } +} diff --git a/app/templates/base.html b/app/templates/base.html index 4d7d1b1..5ed5e4b 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -63,7 +63,7 @@ {% if todo_list_count is not none %} + {% else %} + {% endif %} + {% if current_user.rank.atLeast(current_user.rank.MODERATOR) %} - {% endif %} - {% if current_user.rank == current_user.rank.ADMIN %} - - {% else %} - {% if check_global_perm(current_user, "EDIT_TAGS") %} - - {% elif check_global_perm(current_user, "CREATE_TAG") %} - - {% endif %} - {% if current_user.rank == current_user.rank.MODERATOR %} - + {% if current_user.rank == current_user.rank.ADMIN %} + + {% else %} + {% if check_global_perm(current_user, "EDIT_TAGS") %} + + {% elif check_global_perm(current_user, "CREATE_TAG") %} + + {% endif %} + {% if current_user.rank == current_user.rank.MODERATOR %} + + {% endif %} {% endif %} {% endif %} diff --git a/app/templates/macros/todo.html b/app/templates/macros/todo.html new file mode 100644 index 0000000..8e432bd --- /dev/null +++ b/app/templates/macros/todo.html @@ -0,0 +1,45 @@ +{% macro render_outdated_packages(outdated_packages) -%} + +{% endmacro %} diff --git a/app/templates/macros/topics.html b/app/templates/macros/topics.html index 42fb519..d75f9d9 100644 --- a/app/templates/macros/topics.html +++ b/app/templates/macros/topics.html @@ -1,5 +1,5 @@ -{% macro render_topics_table(topics, show_author=True, show_discard=False, current_user=current_user) -%} - +{% macro render_topics_table(topics, show_author=True, show_discard=False, current_user=current_user, class_=None) -%} +
diff --git a/app/templates/todo/list.html b/app/templates/todo/editor.html similarity index 72% rename from app/templates/todo/list.html rename to app/templates/todo/editor.html index 5c545e9..1887280 100644 --- a/app/templates/todo/list.html +++ b/app/templates/todo/editor.html @@ -1,7 +1,7 @@ -{% extends "base.html" %} +{% extends "todo/todo_base.html" %} {% block title %} -{{ title }} + {{ _("Editor Work Queue") }} {% endblock %} {% block content %} @@ -9,7 +9,7 @@ {% if canApproveScn and screenshots %}

Screenshots -
+ @@ -68,31 +68,6 @@ {% endfor %}

- - {% endif %} @@ -157,24 +132,46 @@ {% endif %} -

Unadded Topic List

+

{{ _("Outdated packages") }}

- {% if total_topics > 0 %} + {% if outdated_packages > 0 %}

- {{ total_topics - topics_to_add }} / {{ total_topics }} packages have been been added to cdb, - based on cdb's forum parser. {{ topics_to_add }} remaining. + {{ _("There are %(count)s potentially outdated packages packages", count=outdated_packages) }}

- -
- {% set perc = 100 * (total_topics - topics_to_add) / total_topics %} -
-
- - View Unadded Topic List + {{ _("View Outdated") }} {% else %}

- The forum topic crawler needs to run at least once for this section to work. + {{ _("No outdated packages") }}

{% endif %} + + +

WIP

+ + {% if canApproveNew and (packages or wip_packages) %} + + {% endif %} {% endblock %} diff --git a/app/templates/todo/outdated.html b/app/templates/todo/outdated.html new file mode 100644 index 0000000..2dbd98a --- /dev/null +++ b/app/templates/todo/outdated.html @@ -0,0 +1,12 @@ +{% extends "todo/todo_base.html" %} + +{% block title %} + {{ _("Outdated packages") }} +{% endblock %} + +{% block content %} +

{{ self.title() }}

+ + {% from "macros/todo.html" import render_outdated_packages %} + {{ render_outdated_packages(outdated_packages) }} +{% endblock %} diff --git a/app/templates/todo/todo_base.html b/app/templates/todo/todo_base.html new file mode 100644 index 0000000..d06d41d --- /dev/null +++ b/app/templates/todo/todo_base.html @@ -0,0 +1,44 @@ +{% extends "base.html" %} + +{% block container %} + {% if current_user.rank.atLeast(current_user.rank.EDITOR) %} + + {% endif %} + +
+ {% if not current_user.rank.atLeast(current_user.rank.EDITOR) %} +

{{ self.title() }}

+ {% endif %} + + {{ self.content() }} +
+{% endblock %} diff --git a/app/templates/todo/topics.html b/app/templates/todo/topics.html index e4be948..b444368 100644 --- a/app/templates/todo/topics.html +++ b/app/templates/todo/topics.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "todo/todo_base.html" %} {% block title %} Topics to be Added diff --git a/app/templates/todo/user.html b/app/templates/todo/user.html new file mode 100644 index 0000000..2592128 --- /dev/null +++ b/app/templates/todo/user.html @@ -0,0 +1,64 @@ +{% extends "todo/todo_base.html" %} + +{% block title %} + {{ _("%(username)s's to do list", username=user.display_name) }} +{% endblock %} + +{% block content %} +

{{ _("Unapproved Packages Needing Action") }}

+
+ {% for package in unapproved_packages %} + +
+ {% if package %} +
+ + + + {{ package.title }} + +
+ {% endif %} + +
+ State: {{ package.state.value }} +
+
+
+ {% else %} +

No outdated packages.

+ {% endfor %} +
+ + +

{{ _("Outdated Packages") }}

+ {% from "macros/todo.html" import render_outdated_packages %} + {{ render_outdated_packages(outdated_packages) }} + + +

{{ _("Unadded Topics") }}

+ {% if topics_to_add %} +

+ List of your forum topics which do not have a matching package. + Topics with a strikethrough have been marked as discarded. +

+ +
+ {% from "macros/topics.html" import render_topics_table %} + {{ render_topics_table(topics_to_add, show_author=False, show_discard=True, current_user=current_user) }} +
+ {% else %} +

Congrats! You don't have any topics which aren't on CDB.

+ {% endif %} +{% endblock %} + + +{% block scriptextra %} + + +{% endblock %} diff --git a/app/templates/users/profile.html b/app/templates/users/profile.html index 03a4b96..99b3df0 100644 --- a/app/templates/users/profile.html +++ b/app/templates/users/profile.html @@ -15,6 +15,10 @@ {{ _("Edit Profile") }} + + + {{ _("To Do List") }} + {% endif %} {% if current_user.is_authenticated and current_user.rank.atLeast(current_user.rank.MODERATOR) and user.email %} @@ -128,32 +132,4 @@ {% from "macros/reviews.html" import render_reviews %} {{ render_reviews(user.reviews, current_user, True) }} - -{% if current_user == user or (current_user.is_authenticated and current_user.rank.atLeast(current_user.rank.EDITOR)) %} -
- -

Unadded topics

- - {% if topics_to_add %} -

- List of your forum topics which do not have a matching package. - Topics with a strikethrough have been marked as discarded. -

- - {% from "macros/topics.html" import render_topics_table %} - {{ render_topics_table(topics_to_add, show_author=False, show_discard=True, current_user=current_user) }} - {% else %} -

Congrats! You don't have any topics which aren't on CDB.

- {% endif %} -
-{% endif %} - -{% endblock %} - - -{% block scriptextra %} - - {% endblock %}
Title