Added snippet admin and profile editing

This commit is contained in:
Armin Ronacher 2010-05-16 13:51:12 +02:00
parent aa79c72ae0
commit d87cbff134
14 changed files with 228 additions and 40 deletions

View file

@ -0,0 +1,22 @@
{% extends "snippets/layout.html" %}
{% block title %}Edit Comment {{ comment.title }}{% endblock %}
{% block body %}
<h2>Edit Comment</h2>
<script type=text/javascript>
$(function() {
$('input[name="delete"]').click(function() {
if (!confirm("Do you really want to delete this comment?\n\n" +
"THIS CANNOT BE UNDONE!"))
return false;
});
});
</script>
<form action="" method=post>
<p>Title: <input type=text name=title value="{{ form.title }}" size=30>
<p><textarea name=text cols=40 rows=8>{{ form.text }}</textarea>
<p>
<input type=submit value="Update Comment">
<input type=submit name=delete value="Delete">
<input type=submit name=cancel value="Cancel">
</form>
{% endblock %}

View file

@ -8,7 +8,9 @@
<p>
You're signed in as “<span title="{{ g.user.openid }}">{{ g.user.name
}}</span>”. You can <a href="{{ url_for('general.logout')
}}">sign out</a> here after you're done if you want.
}}">sign out</a> here after you're done if you want. If you want to
change your OpenID login or display name, head over to the
<a href="{{ url_for('general.profile') }}">profile</a>.
{% else %}
<p>
In order to add snippets to this page or to add comments, all you need
@ -24,10 +26,6 @@
<li><a href="{{ category.url }}">{{ category.name }}</a> ({{ category.count }})
{% endfor %}
</ul>
{% if g.user.is_admin %}
<p>
<a href="{{ url_for('manage_categories') }}">manage categories</a>
{% endif %}
{% if recent %}
<h2>Recently Added</h2>
<ul>
@ -37,4 +35,10 @@
{% endfor %}
</ul>
{% endif %}
{% if g.user.is_admin %}
<h2>Admin Tools</h2>
<ul>
<li><a href="{{ url_for('manage_categories') }}">Manage categories</a>
</ul>
{% endif %}
{% endblock %}

View file

@ -17,7 +17,7 @@
with <code>#!python</code>, <code>#!html+jinja</code> or any other
<a href="http://pygments.org/docs/lexers">Pygments lexer name</a>.
<form action="" method=post>
<dl>
<dl class=formlist>
<dt>Title:
<dd><input type=text name=title value="{{ request.form.title }}" size=40>
<dt>Category:

View file

@ -9,7 +9,7 @@
<p class=snippet-author>By {{ snippet.author.name }}
filed in <a href="{{ snippet.category.url }}">{{ snippet.category.name }}</a>
{% if snippet.author == g.user or g.user.is_admin %}
(<a href="{{ url_for('snippets.edit', id=snippet.id) }}">edit</a>)
(<a href="{{ url_for('edit', id=snippet.id) }}">edit</a>)
{% endif %}
{{ snippet.rendered_body }}
{% if snippet.comments or g.user %}
@ -23,14 +23,17 @@
{{ comment.title or "Comment" }}
by {{ comment.author.name }}
on {{ comment.pub_date.strftime('%Y-%m-%d @ %H:%M') }}
{% if g.user.is_admin %}
(<a href="{{ url_for('edit_comment', id=comment.id) }}">edit</a>)
{% endif %}
<div class=body>{{ comment.rendered_text }}</div></li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
{% if g.user %}
<div id=add-comment>
<h2>Add Comment</h2>
<form action=#add-comment method=post>
<form action="" method=post>
<p>Title: <input type=text name=title value="{{ request.form.title }}" size=30>
<p><textarea name=text cols=40 rows=8>{{ request.form.text }}</textarea>
<p><input type=submit value="Add Comment">