Commits

Ed Brannin  committed 5812958

Added another Christian-viewing Action.

  • Participants
  • Parent commits 930290d

Comments (0)

Files changed (4)

File baptism_records/baptism/migrations/0002_auto__del_field_christian_baptism_name__add_field_christian_first_name.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Deleting field 'Christian.baptism_name'
+        db.delete_column('baptism_christian', 'baptism_name')
+
+        # Adding field 'Christian.first_name'
+        db.add_column('baptism_christian', 'first_name', self.gf('django.db.models.fields.CharField')(default='', max_length=50), keep_default=False)
+
+        # Adding field 'Christian.last_name'
+        db.add_column('baptism_christian', 'last_name', self.gf('django.db.models.fields.CharField')(default='', max_length=50), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Adding field 'Christian.baptism_name'
+        db.add_column('baptism_christian', 'baptism_name', self.gf('django.db.models.fields.CharField')(default='', max_length=50), keep_default=False)
+
+        # Deleting field 'Christian.first_name'
+        db.delete_column('baptism_christian', 'first_name')
+
+        # Deleting field 'Christian.last_name'
+        db.delete_column('baptism_christian', 'last_name')
+
+
+    models = {
+        'baptism.christian': {
+            'Meta': {'object_name': 'Christian'},
+            'baptism_church': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['baptism.Church']"}),
+            'baptism_date': ('django.db.models.fields.DateField', [], {}),
+            'baptizer': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'baptized'", 'to': "orm['baptism.Minister']"}),
+            'birth_date': ('django.db.models.fields.DateField', [], {}),
+            'birth_hospital': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'book': ('django.db.models.fields.PositiveIntegerField', [], {}),
+            'book2': ('django.db.models.fields.PositiveIntegerField', [], {}),
+            'confirmation_date': ('django.db.models.fields.DateField', [], {'blank': 'True'}),
+            'confirmation_place': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'confirmer': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'confirmed'", 'blank': 'True', 'to': "orm['baptism.Minister']"}),
+            'father_name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'middle_name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'mother_maiden_name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'number': ('django.db.models.fields.PositiveIntegerField', [], {}),
+            'number2': ('django.db.models.fields.PositiveIntegerField', [], {}),
+            'page': ('django.db.models.fields.PositiveIntegerField', [], {}),
+            'page2': ('django.db.models.fields.PositiveIntegerField', [], {}),
+            'sponsor1': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'sponsor2': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'zip_code': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['baptism.ZipCode']"})
+        },
+        'baptism.church': {
+            'Meta': {'ordering': "['id']", 'object_name': 'Church'},
+            'city_state_zip': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
+            'id': ('django.db.models.fields.IntegerField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
+            'street': ('django.db.models.fields.CharField', [], {'max_length': '60'})
+        },
+        'baptism.minister': {
+            'Meta': {'object_name': 'Minister'},
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+            'middle_name': ('django.db.models.fields.CharField', [], {'max_length': '40', 'blank': 'True'}),
+            'notes': ('django.db.models.fields.CharField', [], {'max_length': '40', 'blank': 'True'}),
+            'prefix': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'}),
+            'suffix': ('django.db.models.fields.CharField', [], {'max_length': '10', 'blank': 'True'})
+        },
+        'baptism.note': {
+            'Meta': {'object_name': 'Note'},
+            'church': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['baptism.Church']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'note_type': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
+            'person': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['baptism.Christian']"})
+        },
+        'baptism.zipcode': {
+            'Meta': {'object_name': 'ZipCode'},
+            'city': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'state': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
+            'zip_code': ('django.db.models.fields.CharField', [], {'max_length': '10'})
+        }
+    }
+
+    complete_apps = ['baptism']

File baptism_records/baptism/views.py

 # Create your views here.
+from django.shortcuts import render_to_response
 from django.template import Context, loader
 from baptism_records.baptism.models import Christian
 from django.http import HttpResponse
 
 def index(request):
-    people = Christian.objects.all().order_by('last_name')[:5]
-    t = loader.get_template('baptism/index.html')
-    c = Context({
+    people = Christian.objects.all().order_by('last_name')
+    return render_to_response('baptism/index.html', {
         'people': people,
     })
-    return HttpResponse(t.render(c))
 
 
-def show(request, christian_id):
-    return HttpResponse("You're looking at Christian #%s" % christian_id)
-    people = Christian.objects.all().order_by('last_name')[:5]
-    t = loader.get_template('baptism/index.html')
-    c = Context({
-        'people': people,
-    })
-    return HttpResponse(t.render(c))
+from django.http import Http404
+def detail(request, christian_id):
+    try:
+        c = Christian.objects.get(pk=christian_id)
+    except Christian.DoesNotExist:
+        raise Http404
+    return render_to_response('baptism/detail.html', {'christian': c})
 

File baptism_records/templates/baptism/detail.html

+{% if christian %}
+    <p>Hi.  You're looking at {{ christian.full_name }}.</p>
+    <p>
+      Soon, you'll be able to:
+    </p>
+    <ul>
+      <li>Print my Baptism Certificate</li>
+      <li>Edit me</li>
+    </ul>
+{% else %}
+    <p>No people are available.</p>
+    <p>Want to add one?  Yeah, not yet.</p>
+{% endif %}

File baptism_records/urls.py

     # Uncomment the next line to enable the admin:
     (r'^admin/', include(admin.site.urls)),
     
-    (r'^baptism/(?P<christian_id>\d+)', 'baptism_records.baptism.views.show'),
+    (r'^baptism/(?P<christian_id>\d+)', 'baptism_records.baptism.views.detail'),
     (r'^baptism/', 'baptism_records.baptism.views.index'),
 )