Permalink
Browse files

5.13.12

  • Loading branch information...
1 parent 7a395ef commit 628b8e4ba3e0fd6a4a995b2491180608fb130ad2 unknown committed May 14, 2012
@@ -1,25 +1,79 @@
<!doctype html>
<html>
- <h2>todo</h2>
+ <head>
+ <title>Todo List</title>
+ </head>
+ <h2 align="CENTER">
+ <font color="#999999">
+ <u>
+ &nbsp;| Todo List |&nbsp;
+ </u>
+ </font>
+ <hr color="#EEEEEE" style="width:70%" /></h2>
<body>
- <b>
- hello world
- </b>
+
{% for x in items %}
- <form method="post" action=""><!--{% csrf_token %}-->
- {% if x.completed %}
- <p><strike>{{ x.name }} - {{ x.created|date:"D d M Y H m"| }}</strike></p>
- <p><strike>{{ x.description }}</strike></p>
- <input type="checkbox" name="completed" checked="checked" /> Completed ?<br />
- {% else %}
- <p>{{ x.name }} - {{ x.created|date:"D d M Y" }}</p>
- <p>{{ x.description }}</p>
- <input type="checkbox" name="completed"> Completed ?<br />
- {% endif %}
- <input type="hidden" name="listid" value="{{item.id}}" />
- <input type="submit" value="submit" />
+
+ <form method="post" action="."><!--{% csrf_token %}-->
+
+ {% if x.completed %}
+
+ <p align="right">
+ <strike>
+ {{ x.created|date:"D M d Y h:iA"|lower }}: {{ x.name }}
+ </strike>
+ <br />
+ <strike>
+ {{ x.description }}
+ </strike>
+ <br />
+ <input type="checkbox" name="completed" checked="checked" /> Done
+ <input type="hidden" name="listid" value="{{x.id}}" />
+ <input type="checkbox" name="del" /> Delete
+ <input type="hidden" name="listid" value="{{x.id}}" />
+ <input type="submit" value="Submit" />
+ </p>
+
+ {% else %}
+
+ <p align="center">
+ <u>
+ &nbsp;| {{ x.created|date:"D M d Y h:iA" }}:</u>&nbsp;
+ {{ x.name }}
+ <br />
+ {{ x.description }}
+ <br />
+ <input type="checkbox" name="completed" />Done
+ <input type="hidden" name="listid" value="{{x.id}}" />
+ <input type="submit" value="Submit" />
+ </p>
+
+ {% endif %}
+
</form>
- <hr />
+
+ <hr color="#EEEEEE" style="width:70%" />
{% endfor %}
+
+ <form name="item_form" method="post" action=".">
+ <!--fieldset style="width: 85%"-->
+ <fieldset>
+ <legend>{% if name_id %}Edit{% else %}New{% endif %} Item</legend>
+ <p align="center">
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Title&nbsp;
+ <input type="text" name="name" style="text-align: center" />
+ <label for="id_desc"><br />
+ Description
+ </label>
+ <!--span{% if form.description.errors %} class="error"{% endif %}
+ title="{{ form.description.errors|join:"," }}">
+ {{ form.description }}</span><br/-->
+ <!--Description:&nbsp;-->
+ <textarea type="textarea" name="description" style="text-align: center" rows="1" cols="16" ></textarea>
+ <br />
+ <input id="submit" type="submit" value="{% if name_id %}Update{% else %}Create{% endif %}" />
+ </p>
+ </fieldset>
+ </form>
</body>
</html>
@@ -1,3 +1,3 @@
from django.contrib import admin #Import the admin
-from models import TodoList #Import our todo Model.
-admin.site.register(TodoList) #Register the model with the admin
+from models import TodoItem #Import our todo Model.
+admin.site.register(TodoItem) #Register the model with the admin
Binary file not shown.
@@ -1,13 +1,16 @@
from django.db import models
+import datetime
# Create your models here.
-class TodoList(models.Model): #Table name, has to wrap models.Model to get the functionality of Django.
+class TodoItem(models.Model): #Table name, has to wrap models.Model to get the functionality of Django.
name = models.CharField(max_length=100, unique=True) #Like a VARCHAR field
description = models.TextField() #Like a TEXT field
- created = models.DateTimeField() #Like a DATETIME field
- completed = models.BooleanField()
+ created = models.DateTimeField(auto_now_add=True) #Like a DATETIME field
+ completed = models.BooleanField(blank=True)
def __unicode__(self): #Tell it to return as a unicode string (The name of the to-do item) rather than just Object.
return self.name
- #def __str__(self):
- # return self.name
+ def __str__(self):
+ return self.name
+# if self.completed:
+# stats.append('completed')
class Admin:
pass
Binary file not shown.
@@ -1,18 +1,25 @@
# Create your views here.
-from django.http import HttpResponse
-from django.template import Context, loader
+#from django.http import HttpResponse
+#from django.template import Context, loader
from django.shortcuts import render_to_response
#from Fproject.todo.models import TodoList
-from models import TodoList
+from models import TodoItem
def TodoPage(request):
- items = TodoList.objects.all()
+ items = TodoItem.objects.all()
if request.method == "POST":
+ #if action == "edit":
+ try:
+ litem = TodoItem.objects.get(id = request.POST['listid'])
+ litem.completed = not litem.completed
+ litem.save()
+ except TodoItem.DoesNotExist:
+ pass
+ if request.method == "CREATE":
try:
- litem = TodoList.objects.get(id = request.POST['listid'])
- litem.completed = not litem.completed
+ litem = items(name=request.POST['name'], description=request.POST['description'])
litem.save()
- except TodoList.DoesNotExist:
+ except TodoItem.Exists:
pass
#t = loader.get_template('todo/todo.html')
#d = {"greeting":"hello"}
Binary file not shown.
Binary file not shown.

0 comments on commit 628b8e4

Please sign in to comment.