def edit(self, name=None, **kwargs):
"""Remove a tag from a single recipe."""
name,recipe,action = self._normalize_edit_params(name, **kwargs)
- if action.startswith('edit'):
+ if action == 'remove':
+ recipe = self.cookbook.index[name]
+ os.remove(recipe.path)
+ self.cookbook.remove(recipe)
+ self.cookbook.make_index()
+ raise cherrypy.HTTPRedirect(u'.', status=302)
+ elif action.startswith('edit'):
self._update_recipe(name, recipe)
if action == 'edit and redirect': # done editing this recipe
raise cherrypy.HTTPRedirect(
<p id="recipe-details">
{% if recipe.yield_ %}
<span class="detail-field-header">Yield:</span>
- <span class="detail-field-contents">{{ recipe.yield_ }}</span><br />
+ <span class="detail-field-contents">{{ recipe.yield_ }}</span><br/>
{% endif %}
{% if recipe.author %}
<span class="detail-field-header">Author:</span>
- <span class="detail-field-contents">{{ recipe.author }}</span><br />
+ <span class="detail-field-contents">{{ recipe.author }}</span><br/>
{% endif %}
{% if recipe.source %}
<span class="detail-field-header">Source:</span>
- <span class="detail-field-contents">{{ recipe.source }}</span><br />
+ <span class="detail-field-contents">{{ recipe.source }}</span><br/>
{% endif %}
{% if recipe.tags %}
<span class="detail-field-header">Tags:</span>
<span class="detail-field-contents">{{ ', '.join(recipe.tags) }}
- </span><br />
+ </span><br/>
{% endif %}
</p>
<form action="add_tag" method="get">
{% endfor %}
</select>
<input type="text" name="tag" value=""/>
- <input type="submit" value="Add tag" />
+ <input type="submit" value="Add tag"/>
</form>
{% if recipe.tags %}
<form action="remove_tag" method="get">
<option value="{{ tag }}">{{ tag }}</option>
{% endfor %}
</select>
- <input type="submit" value="Remove tag" />
+ <input type="submit" value="Remove tag"/>
</form>
{% endif %}
</div>
{% endif %}
- <p><a href="edit?name={{ recipe.clean_name(ascii=True) }}">
- edit receipe</a></p>
+ <ul>
+ <li><a href="edit?name={{ recipe.clean_name(ascii=True) }}">
+ edit receipe</a></li>
+ <li><a href="edit?action=remove&name={{ recipe.clean_name(ascii=True) }}">
+ remove receipe</a></li>
+ </ul>
{% endblock %}
{% for tag in cookbook.tags() %}
<option value="{{ tag }}">{{ tag }}</option>
{% endfor %}
- </select><br />
- <input type="submit" value="Show only selected tags" />
+ </select><br/>
+ <input type="submit" value="Show only selected tags"/>
</form>
<ul id="recipe-list">
- {% for recipe in recipes %}
- <li><a href="recipe?name={{ recipe.clean_name(ascii=True) }}">
- {{ recipe.name }}</li>
- {% endfor %}
+ {% for recipe in recipes %}
+ <li><a href="recipe?name={{ recipe.clean_name(ascii=True) }}">
+ {{ recipe.name }}</li>
+ {% endfor %}
</ul>
<p><a href="edit">add new receipe</a></p>