Commits

Ed Brannin committed f4d6019

Latest status.

Comments (0)

Files changed (6)

Baptism-Records/TODO

 
 * Prettify a bit more
   * flawless.css
+
+* Better flash: Support multiple messages, error-levels.

Baptism-Records/baptism_records/controllers/christian.py

         log.debug("In index()")
         log.debug("====================================================================================")
         
-        christians = DBSession.query(Christian)
+        christians = DBSession.query(Christian).order_by(Christian.last_name)
         return dict(christians=christians)
     
     @expose('baptism_records.templates.christian.new')

Baptism-Records/baptism_records/model/baptism_model.py

     first_name = Column(Unicode(255), nullable=False)
     middle_name = Column(Unicode(255), nullable=True)
     last_name = Column(Unicode(255), nullable=False)
-    suffix = Column(Unicode(255), nullable=False)
+    suffix = Column(Unicode(255), nullable=True)
     notes = Column(Unicode(4096), nullable=True)
     
     def __unicode__(self):

Baptism-Records/baptism_records/public/js/baptism.js

 
   //TODO: Replace Date picker text boxes with hidden fields; insert Datejs-listening fields that have their data.
   //Class: .calendardatepicker or .datejs
+})
 
-  //TODO: Autocomplete on Postal Code & Birth Hospital
-})
+function setup_autocomplete(selector, url) {
+  var cache = {},
+		lastXhr;
+	$( selector ).autocomplete({
+		minLength: 2,
+		source: function( request, response ) {
+			var term = request.term;
+			if ( term in cache ) {
+				response( cache[ term ] );
+				return;
+			}
+
+			lastXhr = $.getJSON( url + request, function( data, status, xhr ) {
+				cache[ term ] = data;
+				if ( xhr === lastXhr ) {
+					response( data );
+				}
+			});
+		}
+	});
+	
+}
+
+//Setup Autocomplete on Postal Code & Birth Hospital
+$(function() {
+  setup_autocomplete("input[name=birth_hospital]", '/complete/birth_hospitals');
+  setup_autocomplete("input[name=postal_code]", '/complete/postal_codes');
+});

Baptism-Records/baptism_records/templates/christian/list.html

 
     <body>
         <div class="main_content">
-            <h1>Baptism Records<span py:if="book is not None"> in Book ${book}</span><span py:if="page is not None">, Page ${page}</span></h1>
+            <h1>Baptism Records<span py:if="defined('book') and book is not None"> in Book ${book}</span><span py:if="defined('page') and page is not None">, Page ${page}</span></h1>
             <a id="add_new_button" href="${tg.url('/christians/new')}">Add Christian</a>
             <div py:choose="christians.count()">
-              <h2 py:when="0">No Christians Found<span py:if="book is not None"> in Book ${book}</span><span py:if="page is not None">, Page ${page}</span>.  Add one with the link above.</h2>
+              <h2 py:when="0">No Christians Found<span py:if="defined('book') and book is not None"> in Book ${book}</span><span py:if="defined('page') and page is not Nont">, Page ${page}</span>.  Add one with the link above.</h2>
               <table class="list christians" py:otherwise="" >
                 <tr>
                   <th>First Name</th>
                   <td py:content="dude.last_name">Last Name</td>
                   <td py:content="dude.birthday">Birthday</td>
                   <td py:content="dude.postal_code">Postal Code</td>
-                  <td><ul class="book_location" py:if="len(dude.book_locations) > 0"><li py:for="book in dude.book_locations" py:content="book">Book Location</li></ul></td>
+                  <td><ul class="book_location" py:if="len(dude.book_locations) > 0"><li py:for="bl in dude.book_locations"><a href="/book/${bl.book}">Book ${bl.book}</a>, 
+                  <a href="/book/${bl.book}/${bl.page}">Page ${bl.page}</a>,
+                  Number ${bl.number}
+                  </li></ul></td>
                 </tr>
               </table>
             </div>

Baptism-Records/baptism_records/templates/christian/show.html

           <p py:for="bl in christian.book_locations" class="book_location">
             <a href="/book/${bl.book}">Book ${bl.book}</a>, 
             <a href="/book/${bl.book}/${bl.page}">Page ${bl.page}</a>,
-            <a href="/book/${bl.book}/${bl.page}/${bl.number}">Number ${bl.number}</a>
+            Number ${bl.number}
           </p>
           
           <dl class="table-display">