Beispiel #1
0
    def test_tagged_entry(self):
        entries = Tag.entries(label=TestTag.LABEL1, page=1, limit=100)
        self.assertEqual(len(entries), 2)
        self.assertEqual(entries[0], self.entry2)
        self.assertEqual(entries[1], self.entry1)

        entries = Tag.entries(label=TestTag.LABEL2, page=1, limit=100)
        self.assertEqual(len(entries), 1)
        self.assertEqual(entries[0], self.entry1)
Beispiel #2
0
def tag_editing_page():
    g.active = {'tag': True}

    if request.method == 'POST':
        current_label = request.form.get('current_label', '')
        new_label = request.form.get('new_label', '').strip()

        if Tag.n_entries(current_label):
            Tag.update_label(current_label, new_label)


    g.tag_labels = Tag.fetch_all_labels()
    return render_template('admin/edit_tag_page.html')
Beispiel #3
0
def load_values_for_side():
    g.recent_entries = Entry.fetch_recent_entries(
        max(g.items_for_side, g.entries_per_page))
    g.recent_comments = Comment.fetch_recent_comments(
        max(g.items_for_side, g.entries_per_page))
    g.tag_counts = Tag.fetch_tag_counts()
    g.archives = Entry.fetch_archives()
Beispiel #4
0
def tag_page(label, page = 1):
    if page < 1:
        return redirect(url_for('tag_page', label = label))

    g.label = label
    g.page = page
    g.entries = Entry.fetch_tagged_entries(
        label = label,
        page = page,
        limit = g.entries_per_page)

    if g.entries_per_page * (page - 1) + len(g.entries) < Tag.n_entries(label):
        g.has_older = True
    else:
        g.has_older = False
    g.has_newer = True if page > 1 else False

    return render_template('tag_page.html')
Beispiel #5
0
def admin_top_page():
    g.active = {"top": True}
    g.sqlalchemy_database_uri = app.config["SQLALCHEMY_DATABASE_URI"].replace("sqlite:///", "")
    g.n_total_comments = Comment.n_total_count()
    g.n_total_entries = Entry.n_total_count()
    g.n_total_tags = Tag.n_total_count()
    g.n_total_users = User.n_total_count()
    g.db_updated_at = datetime.fromtimestamp(getmtime(g.sqlalchemy_database_uri))
    g.db_bytes = getsize(g.sqlalchemy_database_uri)

    g.mc_stats = {}
    for server, stats in g.mc.get_stats():
        d = dict(
            cmd_get=int(stats[b"cmd_get"]), get_hits=int(stats[b"get_hits"]), total_items=int(stats[b"total_items"])
        )
        d["hit_ratio"] = "%5.2lf %%" % (d["get_hits"] / d["cmd_get"] * 100)
        g.mc_stats[server.decode("utf-8")] = d

    return render_template("admin/top.html")