Commit 3dfea19e0aaf40ae14f7fb7c32d3fbeab0aeadb0
1 parent
d2f3f322
Exists in
master
and in
39 other branches
Changing author to fullname
The author kept the user's fullname, now it keeps the user's username
Showing
7 changed files
with
34 additions
and
13 deletions
Show diff stats
src/accounts/views.py
@@ -56,7 +56,7 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView): | @@ -56,7 +56,7 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView): | ||
56 | 56 | ||
57 | fields_or_lookup = ( | 57 | fields_or_lookup = ( |
58 | {'collaborators__contains': user.username}, | 58 | {'collaborators__contains': user.username}, |
59 | - {'author_and_username__contains': user.username}, | 59 | + {'fullname_and_username__contains': user.username}, |
60 | ) | 60 | ) |
61 | 61 | ||
62 | for type in ['thread', 'ticket', 'wiki', 'changeset', 'attachment']: | 62 | for type in ['thread', 'ticket', 'wiki', 'changeset', 'attachment']: |
src/proxy/templates/search/indexes/proxy/wiki_text.txt
1 | {{ object.author }} | 1 | {{ object.author }} |
2 | -{{ object.author|slugify }} | 2 | +{{ object.get_author.get_full_name }} |
3 | +{{ object.get_author.get_full_name|slugify }} | ||
3 | {{ object.name }} | 4 | {{ object.name }} |
4 | {{ object.name|slugify }} | 5 | {{ object.name|slugify }} |
5 | {{ object.collaborators }} | 6 | {{ object.collaborators }} |
src/search/base_indexes.py
@@ -10,13 +10,14 @@ class BaseIndex(indexes.SearchIndex): | @@ -10,13 +10,14 @@ class BaseIndex(indexes.SearchIndex): | ||
10 | url = indexes.CharField(model_attr='get_absolute_url', indexed=False) | 10 | url = indexes.CharField(model_attr='get_absolute_url', indexed=False) |
11 | title = indexes.CharField() | 11 | title = indexes.CharField() |
12 | description = indexes.CharField(null=True) | 12 | description = indexes.CharField(null=True) |
13 | + fullname = indexes.CharField(null=True) | ||
13 | author = indexes.CharField(null=True) | 14 | author = indexes.CharField(null=True) |
14 | author_url = indexes.CharField(null=True, indexed=False) | 15 | author_url = indexes.CharField(null=True, indexed=False) |
15 | created = indexes.DateTimeField(model_attr='created', null=True) | 16 | created = indexes.DateTimeField(model_attr='created', null=True) |
16 | modified = indexes.DateTimeField(model_attr='modified', null=True) | 17 | modified = indexes.DateTimeField(model_attr='modified', null=True) |
17 | type = indexes.CharField() | 18 | type = indexes.CharField() |
18 | icon_name = indexes.CharField(indexed=False) | 19 | icon_name = indexes.CharField(indexed=False) |
19 | - author_and_username = indexes.CharField(null=True, stored=False) | 20 | + fullname_and_username = indexes.CharField(null=True, stored=False) |
20 | hits = indexes.IntegerField(model_attr='hits') | 21 | hits = indexes.IntegerField(model_attr='hits') |
21 | 22 | ||
22 | def get_updated_field(self): | 23 | def get_updated_field(self): |
@@ -36,10 +37,10 @@ class BaseIndex(indexes.SearchIndex): | @@ -36,10 +37,10 @@ class BaseIndex(indexes.SearchIndex): | ||
36 | def prepare_author(self, obj): | 37 | def prepare_author(self, obj): |
37 | author = obj.get_author() | 38 | author = obj.get_author() |
38 | if author: | 39 | if author: |
39 | - return author.get_full_name() | 40 | + return author.username |
40 | return obj.author | 41 | return obj.author |
41 | 42 | ||
42 | - def prepare_author_and_username(self, obj): | 43 | + def prepare_fullname_and_username(self, obj): |
43 | author = obj.get_author() | 44 | author = obj.get_author() |
44 | if not author: | 45 | if not author: |
45 | return obj.author | 46 | return obj.author |
@@ -53,3 +54,9 @@ class BaseIndex(indexes.SearchIndex): | @@ -53,3 +54,9 @@ class BaseIndex(indexes.SearchIndex): | ||
53 | if author: | 54 | if author: |
54 | return author.get_absolute_url() | 55 | return author.get_absolute_url() |
55 | return None | 56 | return None |
57 | + | ||
58 | + def prepare_fullname(self, obj): | ||
59 | + author = obj.get_author() | ||
60 | + if author: | ||
61 | + return author.get_full_name() | ||
62 | + return obj.author |
src/search/forms.py
@@ -117,7 +117,7 @@ class ColabSearchForm(SearchForm): | @@ -117,7 +117,7 @@ class ColabSearchForm(SearchForm): | ||
117 | 117 | ||
118 | if self.cleaned_data['author']: | 118 | if self.cleaned_data['author']: |
119 | sqs = sqs.filter( | 119 | sqs = sqs.filter( |
120 | - author_and_username__contains=self.cleaned_data['author'] | 120 | + fullname_and_username__contains=self.cleaned_data['author'] |
121 | ) | 121 | ) |
122 | 122 | ||
123 | if self.cleaned_data['milestone']: | 123 | if self.cleaned_data['milestone']: |
src/super_archives/models.py
@@ -330,6 +330,13 @@ class Message(models.Model): | @@ -330,6 +330,13 @@ class Message(models.Model): | ||
330 | 330 | ||
331 | @property | 331 | @property |
332 | def author(self): | 332 | def author(self): |
333 | + from_address = self.from_address | ||
334 | + if from_address.user: | ||
335 | + return from_address.user.username | ||
336 | + return None | ||
337 | + | ||
338 | + @property | ||
339 | + def fullname(self): | ||
333 | return self.from_address.get_full_name() | 340 | return self.from_address.get_full_name() |
334 | 341 | ||
335 | @property | 342 | @property |
src/super_archives/search_indexes.py
@@ -34,9 +34,15 @@ class ThreadIndex(BaseIndex, indexes.Indexable): | @@ -34,9 +34,15 @@ class ThreadIndex(BaseIndex, indexes.Indexable): | ||
34 | return 'latest_message__received_time' | 34 | return 'latest_message__received_time' |
35 | 35 | ||
36 | def prepare_author(self, obj): | 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): | ||
37 | return obj.message_set.first().from_address.get_full_name() | 43 | return obj.message_set.first().from_address.get_full_name() |
38 | 44 | ||
39 | - def prepare_author_and_username(self, obj): | 45 | + def prepare_fullname_and_username(self, obj): |
40 | from_address = obj.message_set.first().from_address | 46 | from_address = obj.message_set.first().from_address |
41 | if not from_address.user: | 47 | if not from_address.user: |
42 | return from_address.get_full_name() | 48 | return from_address.get_full_name() |
src/super_archives/templates/message-preview.html
@@ -28,20 +28,20 @@ | @@ -28,20 +28,20 @@ | ||
28 | <span class="quiet">- {% if query %}{% highlight result.description with query max_length "150" %}{% else %}{{ result.description }}{% endif %}</span> | 28 | <span class="quiet">- {% if query %}{% highlight result.description with query max_length "150" %}{% else %}{{ result.description }}{% endif %}</span> |
29 | {% endif %} | 29 | {% endif %} |
30 | 30 | ||
31 | -{% if result.author or result.modified %} | 31 | +{% if result.fullname or result.modified %} |
32 | <div class="quiet"> | 32 | <div class="quiet"> |
33 | - {% if result.author %} | 33 | + {% if result.fullname %} |
34 | <span class="pull-left">{% trans "by" %} | 34 | <span class="pull-left">{% trans "by" %} |
35 | - {% if result.author and result.author_url %} | 35 | + {% if result.fullname and result.author_url %} |
36 | <a href="{{ result.author_url }}"> | 36 | <a href="{{ result.author_url }}"> |
37 | {% if query %} | 37 | {% if query %} |
38 | - {% highlight result.author with query %} | 38 | + {% highlight result.fullname with query %} |
39 | {% else %} | 39 | {% else %} |
40 | - {{ result.author }} | 40 | + {{ result.fullname }} |
41 | {% endif %} | 41 | {% endif %} |
42 | </a> | 42 | </a> |
43 | {% else %} | 43 | {% else %} |
44 | - <span>{{ result.author }}</span> | 44 | + <span>{{ result.fullname }}</span> |
45 | {% endif %} | 45 | {% endif %} |
46 | </span> | 46 | </span> |
47 | {% endif %} | 47 | {% endif %} |