Commit 9857e341b2ec9c972d3bb9a6b37458da0354dcdb
1 parent
e67bc4d4
Exists in
master
and in
39 other branches
moving modified_by to base indexes
Showing
3 changed files
with
23 additions
and
27 deletions
Show diff stats
src/proxy/search_indexes.py
| ... | ... | @@ -78,8 +78,6 @@ class AttachmentIndex(BaseIndex, indexes.Indexable): |
| 78 | 78 | |
| 79 | 79 | class WikiIndex(BaseIndex, indexes.Indexable): |
| 80 | 80 | title = indexes.CharField(model_attr='name') |
| 81 | - modified_by = indexes.CharField(model_attr='modified_by', null=True) | |
| 82 | - modified_by_url = indexes.CharField(null=True) | |
| 83 | 81 | collaborators = indexes.CharField( |
| 84 | 82 | model_attr='collaborators', |
| 85 | 83 | null=True, |
| ... | ... | @@ -92,12 +90,6 @@ class WikiIndex(BaseIndex, indexes.Indexable): |
| 92 | 90 | def prepare_description(self, obj): |
| 93 | 91 | return u'{}\n{}'.format(obj.wiki_text, obj.collaborators) |
| 94 | 92 | |
| 95 | - def prepare_modified_by_url(self, obj): | |
| 96 | - modified_by = obj.get_modified_by() | |
| 97 | - if modified_by: | |
| 98 | - return modified_by.get_absolute_url() | |
| 99 | - return None | |
| 100 | - | |
| 101 | 93 | def prepare_icon_name(self, obj): |
| 102 | 94 | return u'book' |
| 103 | 95 | |
| ... | ... | @@ -112,8 +104,6 @@ class TicketIndex(BaseIndex, indexes.Indexable): |
| 112 | 104 | severity = indexes.CharField(model_attr='severity', null=True) |
| 113 | 105 | reporter = indexes.CharField(model_attr='reporter', null=True) |
| 114 | 106 | keywords = indexes.CharField(model_attr='keywords', null=True) |
| 115 | - modified_by = indexes.CharField(model_attr='modified_by', null=True) | |
| 116 | - modified_by_url = indexes.CharField(null=True) | |
| 117 | 107 | collaborators = indexes.CharField( |
| 118 | 108 | model_attr='collaborators', |
| 119 | 109 | null=True, |
| ... | ... | @@ -129,12 +119,6 @@ class TicketIndex(BaseIndex, indexes.Indexable): |
| 129 | 119 | obj.reporter, obj.keywords, obj.collaborators |
| 130 | 120 | ) |
| 131 | 121 | |
| 132 | - def prepare_modified_by_url(self, obj): | |
| 133 | - modified_by = obj.get_modified_by() | |
| 134 | - if modified_by: | |
| 135 | - return modified_by.get_absolute_url() | |
| 136 | - return None | |
| 137 | - | |
| 138 | 122 | def prepare_icon_name(self, obj): |
| 139 | 123 | return u'tag' |
| 140 | 124 | ... | ... |
src/search/base_indexes.py
| ... | ... | @@ -19,6 +19,8 @@ class BaseIndex(indexes.SearchIndex): |
| 19 | 19 | icon_name = indexes.CharField(indexed=False) |
| 20 | 20 | fullname_and_username = indexes.CharField(null=True, stored=False) |
| 21 | 21 | hits = indexes.IntegerField(model_attr='hits') |
| 22 | + modified_by = indexes.CharField(null=True) | |
| 23 | + modified_by_url = indexes.CharField(null=True) | |
| 22 | 24 | |
| 23 | 25 | def get_updated_field(self): |
| 24 | 26 | return 'modified' |
| ... | ... | @@ -40,15 +42,6 @@ class BaseIndex(indexes.SearchIndex): |
| 40 | 42 | return author.username |
| 41 | 43 | return obj.author |
| 42 | 44 | |
| 43 | - def prepare_fullname_and_username(self, obj): | |
| 44 | - author = obj.get_author() | |
| 45 | - if not author: | |
| 46 | - return obj.author | |
| 47 | - return u'{}\n{}'.format( | |
| 48 | - author.get_full_name(), | |
| 49 | - author.username, | |
| 50 | - ) | |
| 51 | - | |
| 52 | 45 | def prepare_author_url(self, obj): |
| 53 | 46 | author = obj.get_author() |
| 54 | 47 | if author: |
| ... | ... | @@ -66,3 +59,24 @@ class BaseIndex(indexes.SearchIndex): |
| 66 | 59 | if author: |
| 67 | 60 | return author.get_full_name() |
| 68 | 61 | return obj.author |
| 62 | + | |
| 63 | + def prepare_fullname_and_username(self, obj): | |
| 64 | + author = obj.get_author() | |
| 65 | + if not author: | |
| 66 | + return obj.author | |
| 67 | + return u'{}\n{}'.format( | |
| 68 | + author.get_full_name(), | |
| 69 | + author.username, | |
| 70 | + ) | |
| 71 | + | |
| 72 | + def prepare_modified_by(self, obj): | |
| 73 | + if hasattr(obj, 'modified_by'): | |
| 74 | + return obj.modified_by | |
| 75 | + return None | |
| 76 | + | |
| 77 | + def prepare_modified_by_url(self, obj): | |
| 78 | + if hasattr(obj, 'modified_by'): | |
| 79 | + modified_by = obj.get_modified_by() | |
| 80 | + if modified_by: | |
| 81 | + return modified_by.get_absolute_url() | |
| 82 | + return None | ... | ... |
src/super_archives/search_indexes.py
| ... | ... | @@ -19,8 +19,6 @@ class ThreadIndex(BaseIndex, indexes.Indexable): |
| 19 | 19 | modified = indexes.DateTimeField( |
| 20 | 20 | model_attr='latest_message__modified' |
| 21 | 21 | ) |
| 22 | - modified_by = indexes.CharField(null=True) | |
| 23 | - modified_by_url = indexes.CharField(null=True) | |
| 24 | 22 | tag = indexes.CharField(model_attr='mailinglist__name') |
| 25 | 23 | collaborators = indexes.CharField(use_template=True, stored=False) |
| 26 | 24 | mailinglist_url = indexes.CharField( | ... | ... |