Commit 7f97cab39b6d75761f590c5f47b86276d4ec6ef9
1 parent
6b645c7d
Exists in
master
and in
39 other branches
Minor fixes on thread indexes and message-preview
Showing
2 changed files
with
16 additions
and
10 deletions
Show diff stats
src/super_archives/search_indexes.py
| @@ -12,12 +12,12 @@ class ThreadIndex(BaseIndex, indexes.Indexable): | @@ -12,12 +12,12 @@ class ThreadIndex(BaseIndex, indexes.Indexable): | ||
| 12 | title = indexes.CharField(model_attr='latest_message__subject_clean') | 12 | title = indexes.CharField(model_attr='latest_message__subject_clean') |
| 13 | description = indexes.CharField(use_template=True) | 13 | description = indexes.CharField(use_template=True) |
| 14 | latest_description = indexes.CharField( | 14 | latest_description = indexes.CharField( |
| 15 | - model_attr='latest_message__body', | 15 | + model_attr='latest_message__description', |
| 16 | indexed=False, | 16 | indexed=False, |
| 17 | ) | 17 | ) |
| 18 | created = indexes.DateTimeField() | 18 | created = indexes.DateTimeField() |
| 19 | modified = indexes.DateTimeField( | 19 | modified = indexes.DateTimeField( |
| 20 | - model_attr='latest_message__received_time' | 20 | + model_attr='latest_message__modified' |
| 21 | ) | 21 | ) |
| 22 | tag = indexes.CharField(model_attr='mailinglist__name') | 22 | tag = indexes.CharField(model_attr='mailinglist__name') |
| 23 | collaborators = indexes.CharField(use_template=True, stored=False) | 23 | collaborators = indexes.CharField(use_template=True, stored=False) |
| @@ -33,12 +33,6 @@ class ThreadIndex(BaseIndex, indexes.Indexable): | @@ -33,12 +33,6 @@ class ThreadIndex(BaseIndex, indexes.Indexable): | ||
| 33 | def get_updated_field(self): | 33 | def get_updated_field(self): |
| 34 | return 'latest_message__received_time' | 34 | return 'latest_message__received_time' |
| 35 | 35 | ||
| 36 | - def prepare_author(self, obj): | ||
| 37 | - from_address = obj.message_set.first().from_address | ||
| 38 | - if from_address.user: | ||
| 39 | - return from_address.user.username | ||
| 40 | - return None | ||
| 41 | - | ||
| 42 | def prepare_fullname(self, obj): | 36 | def prepare_fullname(self, obj): |
| 43 | return obj.message_set.first().from_address.get_full_name() | 37 | return obj.message_set.first().from_address.get_full_name() |
| 44 | 38 | ||
| @@ -52,6 +46,9 @@ class ThreadIndex(BaseIndex, indexes.Indexable): | @@ -52,6 +46,9 @@ class ThreadIndex(BaseIndex, indexes.Indexable): | ||
| 52 | from_address.user.username, | 46 | from_address.user.username, |
| 53 | ) | 47 | ) |
| 54 | 48 | ||
| 49 | + def prepare_author(self, obj): | ||
| 50 | + return obj.latest_message.author | ||
| 51 | + | ||
| 55 | def prepare_author_url(self, obj): | 52 | def prepare_author_url(self, obj): |
| 56 | first_message = obj.message_set.first() | 53 | first_message = obj.message_set.first() |
| 57 | if first_message.from_address.user: | 54 | if first_message.from_address.user: |
src/super_archives/templates/message-preview.html
| @@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
| 11 | {% endif %} | 11 | {% endif %} |
| 12 | 12 | ||
| 13 | {% if result.title %} | 13 | {% if result.title %} |
| 14 | - <a href="{{ result.url }}" {% if result.description %}title="{{ result.description|escape|truncatechars:200 }}"{% endif %}> | 14 | + <a href="{{ result.url }}" {% if result.latest_description %}title="{{ result.latest_description|escape|truncatechars:150 }}"{% elif result.description %}title="{{ result.description|escape|truncatechars:150 }}"{% endif %}> |
| 15 | <span class="subject"> | 15 | <span class="subject"> |
| 16 | <!-- a striptags filter was raising an error here because using with highlight --> | 16 | <!-- a striptags filter was raising an error here because using with highlight --> |
| 17 | {% if query %} | 17 | {% if query %} |
| @@ -25,7 +25,16 @@ | @@ -25,7 +25,16 @@ | ||
| 25 | 25 | ||
| 26 | {% if result.description %} | 26 | {% if result.description %} |
| 27 | <!-- a striptags filter was raising an error here because using with highlight --> | 27 | <!-- a striptags filter was raising an error here because using with highlight --> |
| 28 | - <span class="quiet">- {% if query %}{% highlight result.description with query max_length "150" %}{% else %}{{ result.description|truncatechars:150 }}{% endif %}</span> | 28 | + <span class="quiet">- {% if query %} |
| 29 | + {% highlight result.description with query max_length "150" %} | ||
| 30 | + {% else %} | ||
| 31 | + {% if result.latest_description %} | ||
| 32 | + {{ result.latest_description|escape|truncatechars:150 }} | ||
| 33 | + {% elif result.description %} | ||
| 34 | + {{ result.description|escape|truncatechars:150 }} | ||
| 35 | + {% endif %} | ||
| 36 | + {% endif %} | ||
| 37 | + </span> | ||
| 29 | {% endif %} | 38 | {% endif %} |
| 30 | 39 | ||
| 31 | {% if result.fullname or result.modified %} | 40 | {% if result.fullname or result.modified %} |