Victor Quach лет назад: 9
Родитель
Сommit
92231bd86e
2 измененных файлов с 11 добавлено и 5 удалено
  1. 7 4
      counter/templates/homeTemplate.html
  2. 4 1
      counter/views.py

+ 7 - 4
counter/templates/homeTemplate.html

12
 							<b>{{ myCounter.trigramme }}</b> <small>{{ myCounter.name }}</small>
12
 							<b>{{ myCounter.trigramme }}</b> <small>{{ myCounter.name }}</small>
13
 						</a>
13
 						</a>
14
 						{% if not myCounter.lastReset.noSeum %}
14
 						{% if not myCounter.lastReset.noSeum %}
15
-							<span class="pull-right badge">
15
+							<span class="pull-right badge" data-toggle="tooltip" data-placement="top" title="{{ myCounter.likersString }}">
16
 								<span class="glyphicon glyphicon-fire"></span>&emsp;{{ myCounter.likeCount }}
16
 								<span class="glyphicon glyphicon-fire"></span>&emsp;{{ myCounter.likeCount }}
17
 							</span>
17
 							</span>
18
-                            {% for liker in myCounter.likers %}
19
-                                <span>{{ liker.trigramme }}</span>
20
-                            {% endfor %}
21
 						{% endif %}
18
 						{% endif %}
22
 						</h2>
19
 						</h2>
23
 				</div>
20
 				</div>
215
 		{% endif %}
212
 		{% endif %}
216
 	</a>
213
 	</a>
217
 </div>
214
 </div>
215
+
216
+<script>
217
+$(function () {
218
+  $('[data-toggle="tooltip"]').tooltip()
219
+})
220
+</script>
218
 {% endblock %}
221
 {% endblock %}

+ 4 - 1
counter/views.py

16
 import random
16
 import random
17
 import math
17
 import math
18
 import copy
18
 import copy
19
+import functools
19
 from django.utils import timezone
20
 from django.utils import timezone
20
 
21
 
21
 # JSS above this limit will not be displayed on the home page col graph
22
 # JSS above this limit will not be displayed on the home page col graph
54
             likesMe = Like.objects.filter(
55
             likesMe = Like.objects.filter(
55
                 reset=myCounter.lastReset)
56
                 reset=myCounter.lastReset)
56
             myCounter.likeCount = likesMe.count()
57
             myCounter.likeCount = likesMe.count()
57
-            myCounter.likers = [like.liker for like in likesMe]
58
+            myCounter.likersString = functools.reduce(
59
+                        lambda a,b: a + ", " +  b,
60
+                        [like.liker.trigramme for like in likesMe])
58
         myCounter.lastReset.formatted_delta = format_timedelta(
61
         myCounter.lastReset.formatted_delta = format_timedelta(
59
             myCounter.lastReset.delta, locale='fr', threshold=1)
62
             myCounter.lastReset.delta, locale='fr', threshold=1)
60
     except Counter.DoesNotExist:
63
     except Counter.DoesNotExist: