Пример #1
0
def pages():
    if request.method == "POST":
        shreds = set(request.form.getlist("shreds"))
        page_name = request.form.get("page_name")
        page_id = request.form.get("page_id")

        if page_id:
            page = Pages.objects.get(pk=page_id)
        else:
            page, _ = Pages.objects.get_or_create(
                created_by=g.user.id, name=page_name)

        page.update(add_to_set__shreds=shreds)

        for shred in Cluster.objects(id__in=shreds):
            tags = shred.get_user_tags(g.user)
            if tags is not None:
                tags.pages = list(set(tags.pages + [page]))
            # TODO: else 404?

            shred.save()

    pages = Pages.objects(created_by=g.user.id)

    return render_template(
        "_pages.html",
        pages=pages)
Пример #2
0
def review():
    page = int(request.args.get('page', 1))

    items = (Cluster
             .objects(users_processed=g.user.id)
             .paginate(page=page, per_page=20))

    pages = Pages.objects(created_by=g.user.id)
    return render_template("review.html", items=items, pages=pages)
Пример #3
0
def review():
    page = int(request.args.get('page', 1))

    shreds = (Shreds
              .objects(users_processed=g.user.id)
              .exclude("features", "contour")  # 10x speedup
              .paginate(page=page, per_page=20))

    pages = Pages.objects(created_by=g.user.id)
    return render_template("review.html", shreds=shreds, pages=pages)