Admin interface for snippets

This commit is contained in:
Armin Ronacher 2010-05-15 23:19:13 +02:00
parent 45df60cfc6
commit 53ce827b17
15 changed files with 214 additions and 83 deletions

View file

@ -18,9 +18,10 @@
site. Choose wisely because you cannot change this value later:
<dl>
<dt>Name:
<dd><input type=text name=name size=30>
<dd><input type=text name=name value="{{ request.values.name }}" size=30>
</dl>
<p>
<input type=hidden name=next value="{{ next }}">
<input type=submit value=Continue>
<input type=submit name=cancel value=Cancel>
</form>

View file

@ -16,7 +16,7 @@
<p>
OpenID URL:
<input type=text name=openid class=openid size=30>
<input type=hidden name=next value="{{ request.values.next or request.referrer or url_for('general.index') }}">
<input type=hidden name=next value="{{ next }}">
<input type=submit value=Login>
</form>
{% endblock %}

View file

@ -0,0 +1,20 @@
{% extends "snippets/layout.html" %}
{% block title %}Snippets Archive{% endblock %}
{% block body %}
<h2>Delete Category “{{ category.name }}”</h2>
<p>
Do you want to delete this category? And if yes, what should
happen with the snippets in the category?
<form action="" method=post>
<p>
<select name=move_to>
<option value="">Delete Snippets</option>
{%- for category in other_categories %}
<option value={{ category.id }}>Move to “{{ category.name }}”</option>
{%- endfor %}
</select>
<p>
<input type=submit value=Delete>
<input type=submit name=cancel value=Cancel>
</form>
{% endblock %}

View file

@ -17,13 +17,17 @@
{% endif %}
<p>
Want to share something? Then add a
<a href="{{ url_for('snippets.new') }}">new snippet</a>.
<a href="{{ url_for('new') }}">new snippet</a>.
<h2>Snippets by Category</h2>
<ul>
{% for category in categories %}
<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>

View file

@ -0,0 +1,30 @@
{% extends "snippets/layout.html" %}
{% block title %}Snippets Archive{% endblock %}
{% block body %}
<h2>Manage Categories</h2>
{% if categories %}
<form action="" method=post>
<table>
<tr>
<th>Name
<th>Slug
<th>#
<th>?
{% for category in categories %}
<tr>
<td><input type=text name=name.{{ category.id }} value="{{ category.name }}" size=24>
<td><input type=text name=slug.{{ category.id }} value="{{ category.slug }}" size=17>
<td>{{ category.snippets.count() }}
<td><a href="{{ url_for('delete_category', id=category.id) }}">delete</a>
{% endfor %}
</table>
<p class=actions>
<input type=submit value="Update categories">
</form>
{% endif %}
<form action="{{ url_for('new_category') }}" method=post>
<p>Or create a new category:
<input type=text name=name size=30>
<input type=submit value=Create>
</form>
{% endblock %}

View file

@ -8,7 +8,7 @@
<h2>{{ snippet.title }}</h2>
<p class=snippet-author>By {{ snippet.author.name }}
filed in <a href="{{ snippet.category.url }}">{{ snippet.category.name }}</a>
{% if snippet.author == g.user %}
{% if snippet.author == g.user or g.user.is_admin %}
(<a href="{{ url_for('snippets.edit', id=snippet.id) }}">edit</a>)
{% endif %}
{{ snippet.rendered_body }}