Parcourir la Source

Display likers in tooltip

Victor Quach il y a 9 ans
Parent
commit
92231bd86e
2 fichiers modifiés avec 11 ajouts et 5 suppressions
  1. 7 4
      counter/templates/homeTemplate.html
  2. 4 1
      counter/views.py

+ 7 - 4
counter/templates/homeTemplate.html

@@ -12,12 +12,9 @@
12 12
 							<b>{{ myCounter.trigramme }}</b> <small>{{ myCounter.name }}</small>
13 13
 						</a>
14 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 16
 								<span class="glyphicon glyphicon-fire"></span>&emsp;{{ myCounter.likeCount }}
17 17
 							</span>
18
-                            {% for liker in myCounter.likers %}
19
-                                <span>{{ liker.trigramme }}</span>
20
-                            {% endfor %}
21 18
 						{% endif %}
22 19
 						</h2>
23 20
 				</div>
@@ -215,4 +212,10 @@
215 212
 		{% endif %}
216 213
 	</a>
217 214
 </div>
215
+
216
+<script>
217
+$(function () {
218
+  $('[data-toggle="tooltip"]').tooltip()
219
+})
220
+</script>
218 221
 {% endblock %}

+ 4 - 1
counter/views.py

@@ -16,6 +16,7 @@ from graphos.sources.model import ModelDataSource
16 16
 import random
17 17
 import math
18 18
 import copy
19
+import functools
19 20
 from django.utils import timezone
20 21
 
21 22
 # JSS above this limit will not be displayed on the home page col graph
@@ -54,7 +55,9 @@ def home(request):
54 55
             likesMe = Like.objects.filter(
55 56
                 reset=myCounter.lastReset)
56 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 61
         myCounter.lastReset.formatted_delta = format_timedelta(
59 62
             myCounter.lastReset.delta, locale='fr', threshold=1)
60 63
     except Counter.DoesNotExist: