Commit 3dfea19e0aaf40ae14f7fb7c32d3fbeab0aeadb0

Authored by Luan
1 parent d2f3f322

Changing author to fullname

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