diff --git a/src/proxy/search_indexes.py b/src/proxy/search_indexes.py index c0666cc..e3dfc8a 100644 --- a/src/proxy/search_indexes.py +++ b/src/proxy/search_indexes.py @@ -20,6 +20,7 @@ class WikiIndex(indexes.SearchIndex, indexes.Indexable): modified = indexes.DateTimeField(model_attr='modified', null=True) type = indexes.CharField() icon_name = indexes.CharField() + author_username = indexes.CharField(null=True) # trac extra fields collaborators = indexes.CharField(model_attr='collaborators', null=True) @@ -36,6 +37,15 @@ class WikiIndex(indexes.SearchIndex, indexes.Indexable): return author.get_full_name() return obj.author + def prepare_author_username(self, obj): + author = obj.get_author() + if not author: + return obj.author + return u'{}\n{}'.format( + author.get_full_name(), + author.username, + ) + def prepare_author_url(self, obj): author = obj.get_author() if author: @@ -65,6 +75,7 @@ class TicketIndex(indexes.SearchIndex, indexes.Indexable): type = indexes.CharField() icon_name = indexes.CharField() tag = indexes.CharField(model_attr='status', null=True) + author_username = indexes.CharField(null=True) # trac extra fields milestone = indexes.CharField(model_attr='milestone', null=True) @@ -86,6 +97,15 @@ class TicketIndex(indexes.SearchIndex, indexes.Indexable): return author.get_full_name() return obj.author + def prepare_author_username(self, obj): + author = obj.get_author() + if not author: + return obj.author + return u'{}\n{}'.format( + author.get_full_name(), + author.username, + ) + def prepare_author_url(self, obj): author = obj.get_author() if author: @@ -120,6 +140,7 @@ class RevisionIndex(indexes.SearchIndex, indexes.Indexable): modified = indexes.DateTimeField(model_attr='created', null=True) type = indexes.CharField() icon_name = indexes.CharField() + author_username = indexes.CharField(null=True) # trac extra fields repository_name = indexes.CharField(model_attr='repository_name') @@ -137,6 +158,15 @@ class RevisionIndex(indexes.SearchIndex, indexes.Indexable): return author.get_full_name() return obj.author + def prepare_author_username(self, obj): + author = obj.get_author() + if not author: + return obj.author + return u'{}\n{}'.format( + author.get_full_name(), + author.username, + ) + def prepare_author_url(self, obj): author = obj.get_author() if author: diff --git a/src/search/forms.py b/src/search/forms.py index dca5e6c..d210440 100644 --- a/src/search/forms.py +++ b/src/search/forms.py @@ -62,7 +62,9 @@ class ColabSearchForm(SearchForm): sqs = sqs.order_by(*dict_order['fields']) if self.cleaned_data['author']: - sqs = sqs.filter(author=self.cleaned_data['author']) + sqs = sqs.filter( + author_username__contains=self.cleaned_data['author'] + ) if self.cleaned_data['milestone']: sqs = sqs.filter(milestone=self.cleaned_data['milestone']) diff --git a/src/super_archives/search_indexes.py b/src/super_archives/search_indexes.py index d8dab22..88ea19a 100644 --- a/src/super_archives/search_indexes.py +++ b/src/super_archives/search_indexes.py @@ -21,7 +21,9 @@ class ThreadIndex(indexes.SearchIndex, indexes.Indexable): type = indexes.CharField() icon_name = indexes.CharField() tag = indexes.CharField(model_attr='mailinglist__name') + collaborators = indexes.CharField(use_template=True) + author_username = indexes.CharField(null=True) mailinglist_url = indexes.CharField( model_attr='mailinglist__get_absolute_url' ) @@ -35,6 +37,16 @@ class ThreadIndex(indexes.SearchIndex, indexes.Indexable): def prepare_author(self, obj): return obj.message_set.first().from_address.get_full_name() + def prepare_author_username(self, obj): + from_address = obj.message_set.first().from_address + if not from_address.user: + return from_address.get_full_name() + + return u'{}\n{}'.format( + from_address.get_full_name(), + from_address.user.username, + ) + def prepare_author_url(self, obj): first_message = obj.message_set.first() if first_message.from_address.user: diff --git a/src/super_archives/templates/search/indexes/super_archives/thread_collaborators.txt b/src/super_archives/templates/search/indexes/super_archives/thread_collaborators.txt new file mode 100644 index 0000000..86bc3c1 --- /dev/null +++ b/src/super_archives/templates/search/indexes/super_archives/thread_collaborators.txt @@ -0,0 +1,7 @@ +{% for message in object.message_set.iterator %} + {% if not spam %} + {{ message.from_address.get_full_name }} + {{ message.from_address.get_full_name|slugify }} + {{ message.from_address.user.username }} + {% endif %} +{% endfor %} -- libgit2 0.21.2