1. Matthew Schinckel
  2. django-biometrics

Source

django-biometrics / biometrics / models / fingerprint_template.py

Diff from to

File biometrics/models/fingerprint_template.py

 from django.db import models
 
+import picklefield
+
 class FingerprintTemplate(models.Model):
-    user = models.ForeignKey('auth.User', 
-        related_name='fingerprint_templates')
-    data = models.TextField()
+    user = models.OneToOneField('auth.User', 
+        related_name='fingerprint_template')
+    data = picklefield.fields.PickledObjectField(unique=True)
     
     class Meta:
         app_label = 'biometrics'
         db_table = 'biometrics_fingerprint_templates'
+        
+    def __unicode__(self):
+        return "Fingerprint template of %s" % self.user.name
     
-    
+    
+    def _get_serialized_data(self):
+        return self.data.encode('base64')
+    def _set_serialized_data(self, data):
+        self.data = data.decode('base64')
+    
+    serialized_data = property(_get_serialized_data, _set_serialized_data)