Admin interface for snippets
This commit is contained in:
parent
45df60cfc6
commit
53ce827b17
15 changed files with 214 additions and 83 deletions
20
flask_website/templates/snippets/delete_category.html
Normal file
20
flask_website/templates/snippets/delete_category.html
Normal 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 %}
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
30
flask_website/templates/snippets/manage_categories.html
Normal file
30
flask_website/templates/snippets/manage_categories.html
Normal 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 %}
|
||||
|
|
@ -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 }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue