Skip to content

Commit

Permalink
Hooked up views, templates, and models
Browse files Browse the repository at this point in the history
  • Loading branch information
Bri Lance authored and Bri Lance committed Feb 25, 2011
1 parent 2cf0025 commit d81d37a
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 32 deletions.
Binary file modified __init__.pyc
Binary file not shown.
Binary file modified philly_leg.sqlite3
Binary file not shown.
Binary file added phillyleg/.DS_Store
Binary file not shown.
Binary file modified phillyleg/__init__.pyc
Binary file not shown.
Binary file modified phillyleg/admin.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion phillyleg/editsubscribe.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<body>
<div class="center">
<h1>Unsubscribe from City Council Legislation Digest</h1>
<form>
<form method="POST" action="../delete/">
<label for="email">Your email address:</label> <input type="email" name="email" id="email"/>
<input type="submit" value="Unsubscribe All" id="unsubscribe"/>
</form>
Expand Down
2 changes: 1 addition & 1 deletion phillyleg/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Create your models here.
class Subscription(models.Model):
user = models.ForeignKey(User, unique=True)
#user = models.ForeignKey(User, unique=True)
email = models.CharField(max_length=100)
def __unicode__(self):
return self.email
Expand Down
Binary file modified phillyleg/models.pyc
Binary file not shown.
10 changes: 7 additions & 3 deletions phillyleg/received.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
<body>
<div class="center">
<h1>Thank you for subscribing.</h1>
<p>We have added {{email address}} to our database for the following keywords and council members:</p>
<p>We have added {{ emailvar }} to our database for the following keywords and council members:</p>
<ul>
<li>{{council member}}</li>
<li>{{keyword}}</li>
{% for member in members %}
<li>{{ member }}</li>
{% endfor %}
{% for word in keylist %}
<li>{{ word }}</li>
{% endfor %}
</ul>
</div>
</body>
Expand Down
38 changes: 19 additions & 19 deletions phillyleg/subscribe.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
<div class="center">
<h1>Subscribe to City Council Legislation Digest</h1>
<p>Subscribe to be sent a daily email digest of City Council legislation.<br/> You can subscribe to legislation by keyword (currently based on the title of the bill), or by council member.</p>
<form>
<form method="POST" action="create/">
<label for="email">Your email address:</label> <input type="email" name="email" id="email"/><br/>
<p>Enter a list of words separated by commas. Your daily email will list all bills that contain any of these words.</p>
<textarea name="keywords" id="keywords" rows="6" cols="30"></textarea>
<p>Select one or more council members whose legislation you want to subscribe to.</p>
<select multiple="multiple">
<option>Blackwell, Jannie</option>
<option>Clarke, Darrell</option>
<option>DiCiccio, Frank</option>
<option>Goode, Jr., W. Wilson</option>
<option>Green, Bill</option>
<option>Greenlee, William K.</option>
<option>Jones, Jr., Curtis</option>
<option>Kelly, Jack</option>
<option>Kenney, James</option>
<option>Krajewski, Joan</option>
<option>Miller, Donna</option>
<option>O'Neill, Brian</option>
<option>Quiñones-Sánchez, Maria D.</option>
<option>Reynolds Brown, Blondell</option>
<option>Rizzo, Jr., Frank</option>
<option>Tasco, Marian</option>
<option>Verna, Anna</option>
<select multiple="multiple" name="council" id="council">
<option value="Blackwell">Blackwell, Jannie</option>
<option value="Clarke">Clarke, Darrell</option>
<option value="DiCiccio">DiCiccio, Frank</option>
<option value="Goode">Goode, Jr., W. Wilson</option>
<option value="Green">Green, Bill</option>
<option value="Greenlee">Greenlee, William K.</option>
<option value="Jones">Jones, Jr., Curtis</option>
<option value="Kelly">Kelly, Jack</option>
<option value="Kenney">Kenney, James</option>
<option value="Krajewski">Krajewski, Joan</option>
<option value="Miller">Miller, Donna</option>
<option value="O'Neill">O'Neill, Brian</option>
<option value="Quiñones-Sánchez">Quiñones-Sánchez, Maria D.</option>
<option value="Reynolds Brown">Reynolds Brown, Blondell</option>
<option value="Rizzo">Rizzo, Jr., Frank</option>
<option value="Tasco">Tasco, Marian</option>
<option value="Verna">Verna, Anna</option>
</select><br/>
<input type="submit" value="Subscribe" id="subscribe"/>
</form>
Expand Down
2 changes: 1 addition & 1 deletion phillyleg/unsubscribed.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<body>
<div class="center">
<h1>You have been unsubscribed.</h1>
<p>The email address {{email address}} has been removed from our database.</p>
<p>The email address {{ email }} has been removed from our database.</p>
</div>
</body>
</html>
42 changes: 37 additions & 5 deletions phillyleg/views.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
# Create your views here.
from django.http import HttpResponse
from phillyleg.models import Subscription,Keyword
from django.template import Context, loader

def index(request):
return HttpResponse("this is the index")
t = loader.get_template('subscribe.html')
c = Context()
return HttpResponse(t.render(c))

def create(request):
return HttpResponse("this is the create page")
emailvar = request.POST['email']
s = Subscription(email = emailvar)
s.save()
keywords = request.POST['keywords']
keylist = keywords.split(",")
for word in keylist:
k = Keyword(keyword = word, subscription = s)
k.save()
members = request.POST.getlist('council')
for mem in members:
k = Keyword(keyword = mem, subscription = s)
k.save()
t = loader.get_template('received.html')
c = Context({
'emailvar': emailvar,
'keylist': keylist,
'members': members
})
return HttpResponse(t.render(c))

def edit(request, subscription_id):
return HttpResponse("this is the update page for %s" % subscription_idi )
def unsubscribe(request):
t = loader.get_template('editsubscribe.html')
c = Context()
return HttpResponse(t.render(c))

def delete(request):
return HttpResponse("this is the delete page")
t = loader.get_template('unsubscribed.html')
emailvar = request.POST['email']
s = Subscription.objects.filter(email = emailvar)
for item in s:
item.delete()
c = Context({
'email': emailvar
})
return HttpResponse(t.render(c))

Binary file modified phillyleg/views.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/Users/bri/Desktop/phillyles/philly_legislative/phillyleg'
)

INSTALLED_APPS = (
Expand All @@ -80,4 +81,4 @@
'phillyleg'
)

AUTH_PROFILE_MODULE = 'phillyleg.subscription'
#AUTH_PROFILE_MODULE = 'phillyleg.subscription'
Binary file modified settings.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

(r'^subs/$', 'phillyleg.views.index'),
(r'^subs/create/$', 'phillyleg.views.create'),
(r'^subs/(?P<subscription_id>\d+)/$', 'phillyleg.views.edit'),
(r'^subs/unsubscribe/$', 'phillyleg.views.unsubscribe'),
#(r'^subs/(?P<subscription_id>\d+)/$', 'phillyleg.views.edit'),
(r'^subs/delete/$', 'phillyleg.views.delete')
)
Binary file modified urls.pyc
Binary file not shown.

0 comments on commit d81d37a

Please sign in to comment.