Permalink
Browse files

Model Source added

  • Loading branch information...
=
= committed Jan 16, 2011
1 parent c47862c commit 523e6c14a02aea35304bdc84f6060db16b5d82ea
@@ -2,7 +2,6 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <link rel="stylesheet" href="/style.css" />
<title>{% block title %}Passwords{% endblock %}</title>
</head>
<body>
View
@@ -1,4 +1,5 @@
-from web.models import Password
+from web.models import *
from django.contrib import admin
-admin.site.register(Password)
+admin.site.register(Source)
+admin.site.register(Password)
View
Binary file not shown.
View
@@ -1,6 +1,12 @@
from django.db import models
+class Source(models.Model):
+ name = models.CharField(max_length = 255)
+ def __unicode__(self):
+ return self.name
+
class Password(models.Model):
- password = models.CharField(max_length = 255)
+ password = models.CharField(max_length = 1000)
+ Source = models.ForeignKey(Source)
def __unicode__(self):
- return self.password
+ return self.password + " from " + self.Source.name
View
Binary file not shown.
View
@@ -6,21 +6,18 @@
def index(request):
- # I don't really like .reverse()[:5] part but it will have to do for now
- pass_count = Password.objects.all().count()
- return render_to_response('web/index.html', {'pass_count': pass_count},
+ return render_to_response('web/index.html', {'pass_count': Password.objects.all().count()},
context_instance=RequestContext(request))
def add(request):
# This here is some really primitive error handling:
- # I would use trim() but there is probably someone out there with a password containing only spaces :)
-
+ # I would use trim() but there is probably someone out there with a password containing only spaces :)
if(request.method != "POST" or len(request.POST['pw_pass']) == 0):
return HttpResponseBadRequest("You have made a nono, <a href=\"/\">go back</a>.")
- #if(request.POST["cb_add"] == "on"):
- p = Password(password=request.POST["pw_pass"])
+ # Source_id should not be hardcoded but it's late:
+ p = Password(password=request.POST["pw_pass"], Source_id=1)
p.save()
return HttpResponseRedirect('/id/' + str(p.id))
View
Binary file not shown.

0 comments on commit 523e6c1

Please sign in to comment.