# HG changeset patch # User Brian Neal # Date 1275881856 0 # Node ID cd4124b19196a94dc6d9aa0f5652142bdb3e2081 # Parent a5fcf3d1b663a843d1d25fe7b3f3b1bef7e4d779 For #51; add user profiles to Haystack search. diff -r a5fcf3d1b663 -r cd4124b19196 gpp/bio/models.py --- a/gpp/bio/models.py Sun Jun 06 21:05:48 2010 +0000 +++ b/gpp/bio/models.py Mon Jun 07 03:37:36 2010 +0000 @@ -127,6 +127,16 @@ user_is_active.boolean = True user_is_active.short_description = "Is Active" + def search_title(self): + full_name = self.user.get_full_name() + if full_name: + return u"%s (%s)" % (self.user.username, full_name) + return self.user.username + + def search_summary(self): + return u"\n".join((self.location, self.occupation, self.interests, + self.profile_text, self.signature)) + class UserProfileFlag(models.Model): """This model represents a user flagging a profile as inappropriate.""" diff -r a5fcf3d1b663 -r cd4124b19196 gpp/bio/search_indexes.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/bio/search_indexes.py Mon Jun 07 03:37:36 2010 +0000 @@ -0,0 +1,16 @@ +"""Haystack search index for the bio application.""" +from haystack.indexes import * +from haystack import site + +from bio.models import UserProfile + + +class UserProfileIndex(SearchIndex): + text = CharField(document=True, use_template=True) + author = CharField(model_attr='user') + + def get_queryset(self): + return UserProfile.objects.filter(user__is_active=True) + + +site.register(UserProfile, UserProfileIndex) diff -r a5fcf3d1b663 -r cd4124b19196 gpp/templates/bio/members.html --- a/gpp/templates/bio/members.html Sun Jun 06 21:05:48 2010 +0000 +++ b/gpp/templates/bio/members.html Mon Jun 07 03:37:36 2010 +0000 @@ -8,7 +8,10 @@ {% block content %}

Member List

Surfguitar101.com currently has {{ num_members }} active members. Looking for a -particular user? Try our member search.

+particular user? Try our member search, or +you can use our search function to search +user profiles. +

{% if page.object_list %}