Example #1
0
def set_lock(id):
    thread = Thread.query.get(id)
    if thread is None or not thread.checkPerm(current_user,
                                              Permission.LOCK_THREAD):
        abort(404)

    thread.locked = isYes(request.args.get("lock"))
    if thread.locked is None:
        abort(400)

    msg = None
    if thread.locked:
        msg = "Locked thread '{}'".format(thread.title)
        flash("Locked thread", "success")
    else:
        msg = "Unlocked thread '{}'".format(thread.title)
        flash("Unlocked thread", "success")

    addNotification(thread.watchers, current_user, NotificationType.OTHER, msg,
                    thread.getViewURL(), thread.package)
    addAuditLog(AuditSeverity.MODERATION, current_user, NotificationType.OTHER,
                msg, thread.getViewURL(), thread.package)

    db.session.commit()

    return redirect(thread.getViewURL())
Example #2
0
def tags():
    qb = QueryBuilder(request.args)
    qb.setSortIfNone("score", "desc")
    query = qb.buildPackageQuery()

    only_no_tags = isYes(request.args.get("no_tags"))
    if only_no_tags:
        query = query.filter(Package.tags == None)

    tags = Tag.query.order_by(db.asc(Tag.title)).all()

    return render_template("todo/tags.html", current_tab="tags", packages=query.all(), \
      tags=tags, only_no_tags=only_no_tags)
Example #3
0
def outdated():
    is_mtm_only = isYes(request.args.get("mtm"))

    query = db.session.query(Package).select_from(PackageUpdateConfig) \
      .filter(PackageUpdateConfig.outdated_at.isnot(None)) \
      .join(PackageUpdateConfig.package) \
      .filter(Package.state == PackageState.APPROVED)

    if is_mtm_only:
        query = query.filter(Package.repo.ilike("%github.com/minetest-mods/%"))

    sort_by = request.args.get("sort")
    if sort_by == "date":
        query = query.order_by(db.desc(PackageUpdateConfig.outdated_at))
    else:
        sort_by = "score"
        query = query.order_by(db.desc(Package.score))

    return render_template("todo/outdated.html",
                           current_tab="outdated",
                           outdated_packages=query.all(),
                           sort_by=sort_by,
                           is_mtm_only=is_mtm_only)