-<html>
- <head>
- <title>Every Ma'ayanwich Ever!</title></head>
- <body>
- <h1>All Ma'ayanwiches</h1>
- {% for s in sandwiches %}
- <h3>{{ s.adjective }}</h3>
- <p>Made on {{ s.date_made }} and added by {{ s.user.username }}.</p>
- <img src="{{ s.picture.url }}">
- <h5>Ingredients</h5>
- <ul>
+{% extends "base.html" %}
+
+{% block content %}
+ <h1 class="pagetitle">All Ma'ayanwiches</h1>
+ {% for s in allsandwiches %}
+ <h3 class="sandwichtitle">{{ s.adjective }}</h3>
+ <p class="metadata">Made on {{ s.date_made }} and added by {{ s.user.username }}.</p>
+ <img class="sandwichimg" src="{{ s.picture.url }}">
+ <h4 class="sandwichsub">Ingredients</h4>
+ <ul class="ingredients">
{% for i in s.ingredients.all %}
<li>{{ i.name }}
{% endfor %}
</ul>
- <h5>Notes</h5>
- <p> {{ s.notes }}</p>
+ <h4 class="sandwichsub">Notes</h5>
+ <p class="sandnotes"> {{ s.notes }}</p>
{% endfor %}
- </body>
-</html>
\ No newline at end of file
+{% endblock %}
\ No newline at end of file
--- /dev/null
+<html>
+ <head>
+ <link rel="stylesheet" href="http://127.0.0.1:8000/sandwiches/style.css" type="text/css">
+ <title>{% block title %}Ma'ayanwich Tracker{% endblock %}</title>
+ </head>
+ <body>
+ <div id="wrapper">
+ <div id="header">
+ <h1 class="header">Ma'ayanwich Tracker</h1>
+ </div>
+ <div id="sidebar">
+ <h3 class="navtitle">NAVIGATION</h3>
+ <ul class="nav">
+ <li><a href="http://127.0.0.1:8000/sandwich/all/" class="navlink">All sandwiches</a></li>
+ <li><a href="http://127.0.0.1:8000/sandwich/add/" class="navlink">Add sandwich</a></li>
+ <li><a href="http://127.0.0.1:8000/login/" class="navlink">Login</a></li>
+ <li><a href="http://127.0.0.1:8000/signup/" class="navlink">Signup</a></li>
+ <li>Monthly Links (TODO)</li>
+ <li>Logout (TODO)</li>
+ </ul>
+ <h3 class="navtitle">NEWEST</h3>
+ <ul class="newest">
+ {% for s in sandwiches %}
+ <li>{{ s.adjective }}</li>
+ {% endfor %}
+ </ul>
+ </div>
+ <div id="content">
+ {% block content %}
+ {% endblock %}
+ </div>
+ </div>
+ <body>
+</html>
\ No newline at end of file
-<html>
- <head>
- <title>Add an ingredient!</title></head>
- <body>
- <h1>Add a new ingredient</h1>
- <form enctype="multipart/form-data" action="/addingredient/" method="post">
- {{ iform.as_p }}
- <input type="submit" value="Submit" />
- </form>
- </body>
-</html>
\ No newline at end of file
+{% extends "base.html" %}
+
+{% block title %}Add an ingredient{% endblock %}
+{% block content %}
+ <h1 class="pagetitle">Add a new ingredient</h1>
+ <form enctype="multipart/form-data" action="/addingredient/" method="post">
+ {{ iform.as_p }}
+ <input type="submit" value="Submit" />
+ </form>
+{% endblock %}
\ No newline at end of file
-<html>
- <head>
- <title>Login</title></head>
- <body>
- <h1>Login</h1>
- <form enctype="multipart/form-data" action="/login/" method="post">
- {{ aform.as_p }}
- <input type="submit" value="Submit" />
- </form>
- </body>
-</html>
\ No newline at end of file
+{% extends "base.html" %}
+
+{% block content %}
+ <h1 class="pagetitle">Login</h1>
+ <form enctype="multipart/form-data" action="/login/" method="post">
+ {{ aform.as_p }}
+ <input type="submit" value="Submit" />
+ </form>
+{% endblock %}
\ No newline at end of file
-<html>
- <head>
- <title>Create account</title></head>
- <body>
- <h1>Create account</h1>
- <form enctype="multipart/form-data" action="/newuser/" method="post">
- {{ cform.as_p }}
- <input type="submit" value="Submit" />
- </form>
- </body>
-</html>
\ No newline at end of file
+{% extends "base.html" %}
+
+{% block content %}
+ <h1 class="pagetitle">Create account</h1>
+ <form enctype="multipart/form-data" action="/newuser/" method="post">
+ {{ cform.as_p }}
+ <input type="submit" value="Submit" />
+ </form>
+{% endblock %}
\ No newline at end of file
-<html>
- <head>
- <title>Every Ma'ayanwich Ever!</title></head>
- <body>
- <h3>{{ s.adjective }}</h3>
- <p>Made on {{ s.date_made }} and added by {{ s.user.username }}.</p>
- <img src="{{ s.picture.url }}">
- <h5>Ingredients</h5>
- <ul>
- {% for i in s.ingredients.all %}
- <li>{{ i.name }}
- {% endfor %}
- </ul>
- <h5>Notes</h5>
- <p> {{ s.notes }}</p>
- </body>
-</html>
\ No newline at end of file
+{% extends "base.html" %}
+
+{% block title %} The {{ s.adjective }} Ma'ayanwich {% endblock %}
+
+{% block content %}
+ <h3 class="sandwichtitle">{{ s.adjective }}</h3>
+ <p class="metadata">Made on {{ s.date_made }} and added by {{ s.user.username }}.</p>
+ <img class="sandwichimg" src="{{ s.picture.url }}">
+ <h4 class="sandwichsub">Ingredients</h4>
+ <ul class="ingredients">
+ {% for i in s.ingredients.all %}
+ <li>{{ i.name }}
+ {% endfor %}
+ </ul>
+ <h4 class="sandwichsub">Notes</h5>
+ <p class="sandnotes"> {{ s.notes }}</p>
+{% endblock %}
\ No newline at end of file
-<html>
- <head>
- <title>Add a sandwich!</title></head>
- <body>
- <h1>Add a new sandwich</h1>
- <form enctype="multipart/form-data" action="/addsandwich/" method="post">
- {{ sform.as_p }}
- <input type="submit" value="Submit" />
- </form>
- </body>
-</html>
\ No newline at end of file
+{% extends "base.html" %}
+
+{% block title %}Add a sandwich{% endblock %}
+{% block content %}
+ <h1 class="pagetitle">Add a new sandwich</h1>
+ <form enctype="multipart/form-data" action="/addsandwich/" method="post">
+ {{ sform.as_p }}
+ <input type="submit" value="Submit" />
+ </form>
+{% endblock %}
\ No newline at end of file
--- /dev/null
+{% extends "base.html" %}
+
+<ul class="newest">
+ {% for s in sandwiches %}
+ <li>{{ s.adjective }}</li>
+ {% endfor %}
+</ul>
\ No newline at end of file
from django.shortcuts import render_to_response
urlpatterns = patterns('',
- (r'^sandwiches/add/$', views.add_sandwich),
+ (r'^sandwich/add/$', views.add_sandwich),
+ (r'^sandwich/addingredient/$', views.add_ingredient),
+ (r'^sandwich/all/$', views.all_sandwich),
+ (r'^sandwich/(?P<slug>[-\w]+)/$', views.specific_sandwich),
+ (r'^sandwich/(?P<year>[-\w]+)/(?P<month>[-\w]+)/$', views.sandwich_month),
(r'^login/$', views.login_view),
- (r'^newuser/$', views.create_user),
- (r'^sandwiches/addingredient/$', views.add_ingredient),
- (r'^sandwiches/all/$', views.all_sandwich),
- (r'^sandwiches/new/$', views.newsandwiches),
- (r'^sandwiches/(?P<slug>[-\w]+)/$', views.specific_sandwich),
- (r'^sandwiches/(?P<year>[-\w]+)/(?P<month>[-\w]+)/$', views.sandwich_month),
+ (r'^signup/$', views.create_user),
+ (r'', views.baseview),
)
def add_sandwich(request):
+ if Sandwich.objects.count() > 5:
+ sandwiches = Sandwich.objects.order_by('date_made')[:5]
+ else:
+ sandwiches = Sandwich.objects.order_by('date_made')
if request.method == 'POST': # If the form has been submitted...
form = SandwichForm(request.POST, request.FILES) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
else:
form = SandwichForm() # An unbound form
- return render_to_response('sandwich.html', {'sform': form,})
+ return render_to_response('sandwich.html', {'sform': form, 'sandwiches': sandwiches,})
def add_ingredient(request):
+ if Sandwich.objects.count() > 5:
+ sandwiches = Sandwich.objects.order_by('date_made')[:5]
+ else:
+ sandwiches = Sandwich.objects.order_by('date_made')
if request.method == 'POST': # If the form has been submitted...
form = IngredientForm(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
else:
form = IngredientForm() # An unbound form
- return render_to_response('ingredient.html', {'iform': form,})
+ return render_to_response('ingredient.html', {'iform': form, 'sandwiches': sandwiches})
def all_sandwich(request):
try:
- sandwiches = Sandwich.objects.all()
+ allsandwiches = Sandwich.objects.all()
+ if Sandwich.objects.count() > 5:
+ sandwiches = Sandwich.objects.order_by('date_made')[:5]
+ else:
+ sandwiches = Sandwich.objects.order_by('date_made')
except Sandwich.DoesNotExist:
raise Http404
- return render_to_response('allsandwiches.html', {'sandwiches': sandwiches,})
+ return render_to_response('allsandwiches.html', {'allsandwiches': allsandwiches, 'sandwiches': sandwiches})
-def newsandwiches(request):
+def baseview(request):
try:
if Sandwich.objects.count() > 5:
sandwiches = Sandwich.objects.order_by('date_made')[:5]
+ allsandwiches = Sandwich.objects.all()
else:
sandwiches = Sandwich.objects.order_by('date_made')
+ allsandwiches = Sandwich.objects.all()
except Sandwich.DoesNotExist:
raise Http404
- return render_to_response('allsandwiches.html', {'sandwiches': sandwiches,})
+ return render_to_response('base.html', {'sandwiches': sandwiches, 'all': allsandwiches,})
def sandwich_month(request, year, month):
def specific_sandwich(request, slug):
try:
- sandwiches = Sandwich.objects.get(slug=slug)
+ s = Sandwich.objects.get(slug=slug)
+ if Sandwich.objects.count() > 5:
+ sandwiches = Sandwich.objects.order_by('date_made')[:5]
+ else:
+ sandwiches = Sandwich.objects.order_by('date_made')
except Sandwich.DoesNotExist:
raise Http404
- return render_to_response('onesandwich.html', {'s': sandwiches,})
+ return render_to_response('onesandwich.html', {'s': s, 'sandwiches': sandwiches,})
def login_view(request):
+ if Sandwich.objects.count() > 5:
+ sandwiches = Sandwich.objects.order_by('date_made')[:5]
+ else:
+ sandwiches = Sandwich.objects.order_by('date_made')
try:
username = request.POST['username']
password = request.POST['password']
return HttpResponse(thankshtml)
except KeyError:
aform = AuthenticationForm()
- return render_to_response('login.html', {'aform': aform,})
+ return render_to_response('login.html', {'aform': aform, 'sandwiches': sandwiches,})
def create_user(request):
+ if Sandwich.objects.count() > 5:
+ sandwiches = Sandwich.objects.order_by('date_made')[:5]
+ else:
+ sandwiches = Sandwich.objects.order_by('date_made')
if request.user.is_authenticated():
thankshtml = "<p class=\"formthanks\">You are already logged in!</p>"
return HttpResponse(thankshtml)
return HttpResponse(thankshtml) # Redirect after POST
else:
form = NewUserForm() # An unbound form
- return render_to_response('newuser.html', {'cform': form,})
\ No newline at end of file
+ return render_to_response('newuser.html', {'cform': form, 'sandwiches': sandwiches,})
\ No newline at end of file