Skip to content

Commit

Permalink
Ability to delete recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
z3ugma committed Jan 6, 2015
1 parent 649b94b commit 1affa35
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
14 changes: 14 additions & 0 deletions colorpicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,20 @@ def edit(query):

return redirect(url_for('recipe', query=slug))

@app.route('/<query>/delete', methods = ['GET'])
def delete(query):
recipe = list(r.table('recipes').filter({'slug': query}).run(g.rdb_conn))

if recipe:
recipe = recipe[0]
else:
abort(404)

id = recipe['id']

r.table('recipes').get(id).delete().run(g.rdb_conn)
return redirect(url_for('index'))


if __name__ == '__main__':
app.run(debug = True, host='0.0.0.0')
36 changes: 31 additions & 5 deletions templates/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,32 @@
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu">

<style>
body {
font-family: 'Ubuntu', serif;
body {
font-family: 'Ubuntu', serif;
background-color: #A66FA6;

}

.panel-primary{
border-color: #609732;
font-size:150%;

}

.panel-primary > .panel-heading {
background-color: #609732;
border-color: #609732;

}

a {
color: #370037;
}

a:focus, a:hover {
color: #370037;
}

}
textarea {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
Expand All @@ -31,13 +53,17 @@
<body>
<div class="container">


<form action="" role="form" method="POST" name="add_task">
{{form.hidden_tag()}}

<div class="row">
<div class="col-md-12">
<h1>Add a Recipe</h1>
<div class="header" style="background-color: #370037; color: #A66FA6; margin-bottom: 20px; padding: 20px 10px;">
<h1>Add a Recipe

<a href="/" class="btn btn-default btn-lg pull-right" role="button">Home</a>

</h1></div>

<div class="panel panel-primary">
<div class="panel-heading">
Expand Down
1 change: 1 addition & 0 deletions templates/recipes.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ <h3 class="panel-title"></h3> Directions </h3>
<div class="img-wrapper"> <img src="{{i}}" /></div>
{% endfor%}
</div>
<a href="{{url_for('delete' , query=query) }}" style="margin-left: 15px;" class="btn btn-default btn-lg pull-right" role="button">Delete</a>
</div>
</body>
</html>

0 comments on commit 1affa35

Please sign in to comment.