1 | from django.http import HttpResponse
|
---|
2 | from friends.people.models import person, Blog
|
---|
3 | from django.shortcuts import render_to_response, get_object_or_404
|
---|
4 | from friends.quotes.models import quote
|
---|
5 | from datetime import datetime
|
---|
6 | from django import forms
|
---|
7 |
|
---|
8 |
|
---|
9 | def index(request):
|
---|
10 | pList = person.objects.all()
|
---|
11 | return render_to_response('people/person_index.html', {'pList':pList})
|
---|
12 |
|
---|
13 | def details(request, pID='0', opts=()):
|
---|
14 | rDict = {}
|
---|
15 | p = get_object_or_404(person, pk=pID)
|
---|
16 | rDict['p'] = p
|
---|
17 | quotes= quote.objects.all()
|
---|
18 | rDict['quotes']=quotes
|
---|
19 | return render_to_response('people/person_details.html',rDict)
|
---|
20 |
|
---|
21 | def person_form(request, pID='0'):
|
---|
22 | PersonForm = forms.form_for_model(person)
|
---|
23 | f = PersonForm()
|
---|
24 | message = 'Unknown Request'
|
---|
25 | p= get_object_or_404(Person, pk=pID)
|
---|
26 |
|
---|
27 | if request.method == 'GET':
|
---|
28 | PersonForm = forms.form_for_instance(p)
|
---|
29 | f=PersonForm()
|
---|
30 | message= 'Editing person %s ' % p.name
|
---|
31 |
|
---|
32 | if request.method == 'POST':
|
---|
33 | if request.POST['submit'] == 'update':
|
---|
34 | message = 'Update Request for %s ' % p.name
|
---|
35 |
|
---|
36 | return render_to_response(
|
---|
37 | 'people/person_form.html',
|
---|
38 | {'pForm':f,
|
---|
39 | 'message':message})
|
---|
40 | # Create your views here.
|
---|