Mercurial > public > sg101
comparison custom_search/indexes.py @ 677:858ce870c854
For #47, create custom search index for models with is_public.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 14 Aug 2013 13:56:43 -0500 |
parents | ee87ea74d46b |
children |
comparison
equal
deleted
inserted
replaced
676:afb17af7948f | 677:858ce870c854 |
---|---|
27 | 27 |
28 """ | 28 """ |
29 if (action == 'update' and self.can_index(instance) or | 29 if (action == 'update' and self.can_index(instance) or |
30 action == 'delete'): | 30 action == 'delete'): |
31 super(CondQueuedSearchIndex, self).enqueue(action, instance) | 31 super(CondQueuedSearchIndex, self).enqueue(action, instance) |
32 | |
33 | |
34 class PublicQueuedSearchIndex(QueuedSearchIndex): | |
35 """QueuedSearchIndex for models with is_public attributes.""" | |
36 | |
37 def enqueue(self, action, instance): | |
38 """Conditionally enqueue actions as follows. | |
39 | |
40 For update actions: if is_public is True, enqueue the update. If | |
41 is_public is False, enqueue a delete action. | |
42 | |
43 Delete actions are always enqueued. | |
44 | |
45 """ | |
46 if action == 'update' and instance.is_public: | |
47 super(PublicQueuedSearchIndex, self).enqueue(action, instance) | |
48 elif (action == 'update' and not instance.is_public) or action == 'delete': | |
49 super(PublicQueuedSearchIndex, self).enqueue('delete', instance) |