Mercurial > public > sg101
annotate forums/signals.py @ 943:cf9918328c64
Haystack tweaks for Django 1.7.7.
I had to upgrade to Haystack 2.3.1 to get it to work with Django
1.7.7. I also had to update the Xapian backend. But I ran into
problems.
On my laptop anyway (Ubuntu 14.0.4), xapian gets mad when search terms
are greater than 245 chars (or something) when indexing. So I created
a custom field that would simply omit terms greater than 64 chars and
used this field everywhere I previously used a CharField.
Secondly, the custom search form was broken now. Something changed in
the Xapian backend and exact searches stopped working. Fortunately the
auto_query (which I was using originally and broke during an upgrade)
started working again. So I cut the search form back over to doing an
auto_query. I kept the form the same (3 fields) because I didn't want
to change the form and I think it's better that way.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 13 May 2015 20:25:07 -0500 |
parents | 5902dc5e58a3 |
children |
rev | line source |
---|---|
bgneal@75 | 1 """ |
bgneal@920 | 2 Signals for the forums application. |
bgneal@469 | 3 |
bgneal@75 | 4 """ |
bgneal@469 | 5 import django.dispatch |
bgneal@181 | 6 |
bgneal@75 | 7 |
bgneal@469 | 8 # This signal is sent when a topic has had its textual content (title) changed. |
bgneal@469 | 9 # The provided arguments are: |
bgneal@469 | 10 # sender - the topic model instance |
bgneal@469 | 11 # created - True if the topic is new, False if updated |
bgneal@469 | 12 |
bgneal@470 | 13 topic_content_update = django.dispatch.Signal(providing_args=['created']) |
bgneal@469 | 14 |
bgneal@469 | 15 # This signal is sent when a post has had its textual content (body) changed. |
bgneal@469 | 16 # The provided arguments are: |
bgneal@469 | 17 # sender - the post model instance |
bgneal@469 | 18 # created - True if the post is new, False if updated |
bgneal@469 | 19 |
bgneal@470 | 20 post_content_update = django.dispatch.Signal(providing_args=['created']) |
bgneal@469 | 21 |
bgneal@469 | 22 |
bgneal@469 | 23 def notify_new_topic(topic): |
bgneal@469 | 24 """ |
bgneal@469 | 25 Sends the topic_content_update signal for a new topic instance. |
bgneal@469 | 26 |
bgneal@469 | 27 """ |
bgneal@470 | 28 topic_content_update.send_robust(topic, created=True) |
bgneal@469 | 29 |
bgneal@469 | 30 |
bgneal@469 | 31 def notify_updated_topic(topic): |
bgneal@469 | 32 """ |
bgneal@469 | 33 Sends the topic_content_update signal for an updated topic instance. |
bgneal@469 | 34 |
bgneal@469 | 35 """ |
bgneal@470 | 36 topic_content_update.send_robust(topic, created=False) |
bgneal@469 | 37 |
bgneal@469 | 38 |
bgneal@469 | 39 def notify_new_post(post): |
bgneal@469 | 40 """ |
bgneal@469 | 41 Sends the post_content_update signal for a new post instance. |
bgneal@469 | 42 |
bgneal@469 | 43 """ |
bgneal@470 | 44 post_content_update.send_robust(post, created=True) |
bgneal@469 | 45 |
bgneal@469 | 46 |
bgneal@469 | 47 def notify_updated_post(post): |
bgneal@469 | 48 """ |
bgneal@469 | 49 Sends the post_content_update signal for an updated post instance. |
bgneal@469 | 50 |
bgneal@469 | 51 """ |
bgneal@470 | 52 post_content_update.send_robust(post, created=False) |