diff gpp/bio/models.py @ 277:d424b8bae71d

Fixing #128 and #129. Add elsewhere weblinks to search content. Add support for haystack's get_update_field() method.
author Brian Neal <bgneal@gmail.com>
date Sat, 02 Oct 2010 23:24:39 +0000
parents 75ea1a8be7f2
children 39664e661c69
line wrap: on
line diff
--- a/gpp/bio/models.py	Thu Sep 30 00:06:04 2010 +0000
+++ b/gpp/bio/models.py	Sat Oct 02 23:24:39 2010 +0000
@@ -2,13 +2,14 @@
 Contains models for the bio application.
 I would have picked profile for this application, but that is already taken, apparently.
 """
-
+import datetime
 import os.path
 
 from django.db import models
 from django.contrib.auth.models import User
 from django.conf import settings
 from django.core.cache import cache
+from django.template.loader import render_to_string
 
 from core.markup import SiteMarkup
 
@@ -90,6 +91,7 @@
             choices=USER_STATUS_CHOICES)
     status_date = models.DateTimeField(auto_now_add=True)
     badges = models.ManyToManyField(Badge, through="BadgeOwnership")
+    update_date = models.DateTimeField(db_index=True, blank=True)
 
     def __unicode__(self):
         return self.user.username
@@ -98,6 +100,7 @@
         ordering = ('user__username', )
 
     def save(self, *args, **kwargs):
+        update_date = datetime.datetime.now()
         sm = SiteMarkup()
         self.profile_html = sm.convert(self.profile_text)
         self.signature_html = sm.convert(self.signature)
@@ -134,8 +137,9 @@
         return self.user.username
 
     def search_summary(self):
-        return u"\n".join((self.location, self.occupation, self.interests,
-            self.profile_text, self.signature))
+        text = render_to_string('search/indexes/bio/userprofile_text.txt',
+                {'object': self});
+        return text
 
 
 class UserProfileFlag(models.Model):