Commit 183cb97cc606d48c359507833db1a915d1ea4047
1 parent
dacfcb1a
Exists in
master
and in
39 other branches
Normalizing superarchives models #52
Showing
7 changed files
with
74 additions
and
107 deletions
Show diff stats
src/accounts/templates/accounts/user_detail.html
... | ... | @@ -91,7 +91,7 @@ |
91 | 91 | <h3>{% trans "Latest posted" %} </h3> |
92 | 92 | <ul class="message-list"> |
93 | 93 | {% for doc in emails %} |
94 | - {% include "message-preview.html" %} | |
94 | + {% include "message-preview.html" with result=doc %} | |
95 | 95 | {% empty %} |
96 | 96 | <li>{% trans "There are no posts by this user so far." %}</li> |
97 | 97 | {% endfor %} |
... | ... | @@ -102,7 +102,7 @@ |
102 | 102 | <h3>{% trans "Community inside participations" %}</h3> |
103 | 103 | <ul class="message-list"> |
104 | 104 | {% for result in results %} |
105 | - {% include "search/preview-search.html" %} | |
105 | + {% include "message-preview.html" %} | |
106 | 106 | {% empty %} |
107 | 107 | <li>{% trans "No contributions of this user so far." %}</li> |
108 | 108 | {% endfor %} | ... | ... |
src/super_archives/models.py
... | ... | @@ -283,7 +283,7 @@ class Message(models.Model): |
283 | 283 | |
284 | 284 | @property |
285 | 285 | def mailinglist(self): |
286 | - if not self.thread or not self.thread.mailinglist: | |
286 | + if not self.thread: | |
287 | 287 | return None |
288 | 288 | |
289 | 289 | return self.thread.mailinglist |
... | ... | @@ -314,12 +314,12 @@ class Message(models.Model): |
314 | 314 | self.thread.subject_token]) |
315 | 315 | |
316 | 316 | @property |
317 | - def Description(self): | |
317 | + def description(self): | |
318 | 318 | """Alias to self.body""" |
319 | 319 | return self.body |
320 | 320 | |
321 | 321 | @property |
322 | - def Title(self): | |
322 | + def title(self): | |
323 | 323 | """Alias to self.subject_clean""" |
324 | 324 | return self.subject_clean |
325 | 325 | |
... | ... | @@ -328,6 +328,28 @@ class Message(models.Model): |
328 | 328 | """Alias to self.modified""" |
329 | 329 | return self.received_time |
330 | 330 | |
331 | + @property | |
332 | + def tag(self): | |
333 | + if not self.thread: | |
334 | + return None | |
335 | + return self.mailinglist.name | |
336 | + | |
337 | + @property | |
338 | + def author(self): | |
339 | + return self.from_address.get_full_name() | |
340 | + | |
341 | + @property | |
342 | + def author_url(self): | |
343 | + return self.from_address.user.get_absolute_url() | |
344 | + | |
345 | + @property | |
346 | + def icon_name(self): | |
347 | + return u'envelope' | |
348 | + | |
349 | + @property | |
350 | + def type(self): | |
351 | + return u'thread' | |
352 | + | |
331 | 353 | |
332 | 354 | class MessageBlock(models.Model): |
333 | 355 | message = models.ForeignKey(Message, related_name='blocks') | ... | ... |
src/super_archives/templates/message-list.html
... | ... | @@ -50,7 +50,7 @@ |
50 | 50 | <div class="col-xs-12 col-sm-12 col-md-10 col-lg-10"> |
51 | 51 | <ul class="unstyled-list"> |
52 | 52 | {% for thread in threads.object_list %} |
53 | - {% include "message-preview.html" with doc=thread.latest_message %} | |
53 | + {% include "message-preview.html" with result=thread.latest_message %} | |
54 | 54 | {% empty %} |
55 | 55 | <br/><br/> |
56 | 56 | <span> | ... | ... |
src/super_archives/templates/message-preview.html
1 | 1 | {% load i18n %} |
2 | +{% load highlight %} | |
2 | 3 | |
3 | -{% if doc.Title %} | |
4 | 4 | <li class="preview-message"> |
5 | - {% if doc.Type %} | |
6 | - <img alt="{{ doc.Type }}" title="{{ doc.Type }}" | |
7 | - src="{{ STATIC_URL }}img/{{ doc.Type }}.png" /> | |
8 | - {% else %} | |
9 | - <span class="glyphicon glyphicon-envelope"></span> | |
10 | - {% endif %} | |
5 | +<span class="glyphicon glyphicon-{{ result.icon_name }}" title="{{ result.type }}"></span> | |
11 | 6 | |
12 | - {% if doc.mailinglist %} | |
13 | - <a href="{% url 'super_archives.views.list_messages' %}?list={{ doc.mailinglist }}"> | |
14 | - <span class="label label-primary">{{ doc.mailinglist }}</span> | |
15 | - </a> | |
16 | - {% endif %} | |
17 | - | |
18 | - <span class="subject"> | |
19 | - <a href="{{ doc.url }}#msg-{{ doc.id }}" | |
20 | - {% if | |
21 | - title="{% filter striptags|truncatewords:50 %} | |
22 | - {{ doc.Description|escape }} | |
23 | - {% endfilter %}"> | |
24 | - {{ doc.Title }} | |
25 | - </a> | |
26 | - </span> | |
27 | - | |
28 | - <span class="quiet">- | |
29 | - {{ doc.Description|striptags }} | |
30 | - </span> | |
31 | - | |
32 | - <div class="quiet"> | |
33 | - <span class="pull-left"> | |
34 | - {% if doc.from_address.user.get_absolute_url or doc.from_address.get_full_name or doc.last_author or doc.Creator %} | |
35 | - {% trans "by" %} | |
36 | - {% endif %} | |
7 | +{% if result.tag %} | |
8 | +<a href="{% firstof result.mailinglist_url result.url %}"> | |
9 | + <span class="label label-primary">{{ result.tag }}</span> | |
10 | +</a> | |
11 | +{% endif %} | |
37 | 12 | |
38 | - {% if doc.from_address.user.get_absolute_url %} | |
39 | - <a href="{{ doc.from_address.user.get_absolute_url }}"> | |
40 | - {{ doc.from_address.user.get_full_name }} | |
41 | - </a> | |
42 | - {% elif doc.from_address.get_full_name %} | |
43 | - <span>{{ doc.from_address.get_full_name }}</span> | |
13 | +{% if result.title %} | |
14 | + <a href="{{ result.url }}" {% if result.description %}title="{{ result.description|escape|truncatechars:200 }}"{% endif %}> | |
15 | + <span class="subject"> | |
16 | + <!-- a striptags filter was raising an error here because using with highlight --> | |
17 | + {% if query %} | |
18 | + {% highlight result.title with query max_length "1000" %} | |
44 | 19 | {% else %} |
45 | - {% firstof doc.last_author doc.Creator "" %} | |
20 | + {{ result.title }} | |
46 | 21 | {% endif %} |
47 | 22 | </span> |
23 | + </a> | |
24 | +{% endif %} | |
48 | 25 | |
49 | - <span class="pull-right"> | |
50 | - {{ doc.modified|timesince }} | |
51 | - {% trans "ago" %} | |
52 | - </span> | |
26 | +{% if result.description %} | |
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 }}{% endif %}</span> | |
29 | +{% endif %} | |
30 | + | |
31 | +{% if result.author or result.modified %} | |
32 | + <div class="quiet"> | |
33 | + {% if result.author %} | |
34 | + <span class="pull-left">{% trans "by" %} | |
35 | + {% if result.author and result.author_url %} | |
36 | + <a href="{{ result.author_url }}"> | |
37 | + {% if query %} | |
38 | + {% highlight result.author with query %} | |
39 | + {% else %} | |
40 | + {{ result.author }} | |
41 | + {% endif %} | |
42 | + </a> | |
43 | + {% else %} | |
44 | + <span>{{ result.author }}</span> | |
45 | + {% endif %} | |
46 | + </span> | |
47 | + {% endif %} | |
48 | + {% if result.modified %} | |
49 | + <span class="pull-right">{{ result.modified|timesince }} {% trans "ago" %}</span> | |
50 | + {% endif %} | |
53 | 51 | </div> |
54 | -</li> | |
55 | 52 | {% endif %} |
53 | +</li> | ... | ... |
src/templates/home.html
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | </a> |
23 | 23 | <ul class="message-list"> |
24 | 24 | {% for result in latest_results %} |
25 | - {% include "search/preview-search.html" %} | |
25 | + {% include "message-preview.html" %} | |
26 | 26 | {% endfor %} |
27 | 27 | </ul> |
28 | 28 | <a class="column-align" |
... | ... | @@ -50,7 +50,7 @@ |
50 | 50 | </a> |
51 | 51 | <ul class="message-list"> |
52 | 52 | {% for thread in hottest_threads %} |
53 | - {% include "message-preview.html" with doc=thread.latest_message %} | |
53 | + {% include "message-preview.html" with result=thread.latest_message %} | |
54 | 54 | {% endfor %} |
55 | 55 | </ul> |
56 | 56 | <a class="column-align" |
... | ... | @@ -70,7 +70,7 @@ |
70 | 70 | </a> |
71 | 71 | <ul class="message-list"> |
72 | 72 | {% for thread in latest_threads %} |
73 | - {% include "message-preview.html" with doc=thread.latest_message %} | |
73 | + {% include "message-preview.html" with result=thread.latest_message %} | |
74 | 74 | {% endfor %} |
75 | 75 | </ul> |
76 | 76 | <a class="column-align" href="{% url 'thread_list' %}"> | ... | ... |
src/templates/search/preview-search.html
... | ... | @@ -1,53 +0,0 @@ |
1 | -{% load i18n %} | |
2 | -{% load highlight %} | |
3 | - | |
4 | -<li class="preview-message"> | |
5 | -<span class="glyphicon glyphicon-{{ result.icon_name }}" title="{{ result.type }}"></span> | |
6 | - | |
7 | -{% if result.tag %} | |
8 | -<a href="{% firstof result.mailinglist_url result.url %}"> | |
9 | - <span class="label label-primary">{{ result.tag }}</span> | |
10 | -</a> | |
11 | -{% endif %} | |
12 | - | |
13 | -{% if result.title %} | |
14 | - <a href="{{ result.url }}" {% if result.description %}title="{{ result.description|escape|truncatechars:200 }}"{% endif %}> | |
15 | - <span class="subject"> | |
16 | - <!-- a striptags filter was raising an error here because using with highlight --> | |
17 | - {% if query %} | |
18 | - {% highlight result.title with query max_length "1000" %} | |
19 | - {% else %} | |
20 | - {{ result.title }} | |
21 | - {% endif %} | |
22 | - </span> | |
23 | - </a> | |
24 | -{% endif %} | |
25 | - | |
26 | -{% if result.description %} | |
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 }}{% endif %}</span> | |
29 | -{% endif %} | |
30 | - | |
31 | -{% if result.author or result.modified %} | |
32 | - <div class="quiet"> | |
33 | - {% if result.author %} | |
34 | - <span class="pull-left">{% trans "by" %} | |
35 | - {% if result.author and result.author_url %} | |
36 | - <a href="{{ result.author_url }}"> | |
37 | - {% if query %} | |
38 | - {% highlight result.author with query %} | |
39 | - {% else %} | |
40 | - {{ result.author }} | |
41 | - {% endif %} | |
42 | - </a> | |
43 | - {% else %} | |
44 | - <span>{{ result.author }}</span> | |
45 | - {% endif %} | |
46 | - </span> | |
47 | - {% endif %} | |
48 | - {% if result.modified %} | |
49 | - <span class="pull-right">{{ result.modified|timesince }} {% trans "ago" %}</span> | |
50 | - {% endif %} | |
51 | - </div> | |
52 | -{% endif %} | |
53 | -</li> |
src/templates/search/search.html
... | ... | @@ -214,7 +214,7 @@ |
214 | 214 | <div class="col-lg-10"> |
215 | 215 | <ul class="list-unstyled"> |
216 | 216 | {% for result in page.object_list %} |
217 | - {% include "search/preview-search.html" %} | |
217 | + {% include "message-preview.html" %} | |
218 | 218 | {% empty %} |
219 | 219 | <li class="text-center"> |
220 | 220 | {% trans "No results for your search." %} | ... | ... |