Added recipe removal link and replaced ' />' -> '/>'
authorW. Trevor King <wking@drexel.edu>
Thu, 22 Jul 2010 16:10:57 +0000 (12:10 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 22 Jul 2010 16:10:57 +0000 (12:10 -0400)
cookbook/server.py
cookbook/template/recipe.html
cookbook/template/recipes.html

index 76dded630ff4d3dafd4c90b9fdc9c66fbf63d51a..19b3d588099f1ab694979b688b018548d2e8f39d 100644 (file)
@@ -132,7 +132,13 @@ class Server (object):
     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(
index cd20d128bf17952144276cefc4669170c04e6e28..d5c0f03ef3ce369cd730ac494370d4278dd5b6db 100644 (file)
     <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">
@@ -37,7 +37,7 @@
        {% 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">
@@ -47,7 +47,7 @@
        <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 %}
index d0b5b36c650c80c348efc7f974e032b385be54b2..06e320e8c93bec9c3eedca0c235be034e5cec89d 100644 (file)
        {% 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>