ソースを参照

Decreasing opacity for seum counters

Denis Merigoux 9 年 前
コミット
a11d070a04
共有2 個のファイルを変更した4 個の追加2 個の削除を含む
  1. 1 1
      counter/templates/homeTemplate.html
  2. 3 1
      counter/views.py

+ 1 - 1
counter/templates/homeTemplate.html

@@ -6,7 +6,7 @@
6 6
 	<div class="row">
7 7
 		{% for counter in counters %}
8 8
 		<div class="col-md-4 col-sm-6 col-lg-3">
9
-			<div class="panel panel-{{counter.CSSclass}}">
9
+			<div class="panel panel-{{counter.CSSclass}}" style="opacity:{{counter.opacity}}">
10 10
 				<div class="panel-heading">
11 11
 					<a class="counter-link" href="{% url 'counter' id_counter=counter.id %}"><h2 class="panel-title">{{ counter.trigramme }} <small>{{ counter.name }}</small></h2></a>
12 12
 				</div>

+ 3 - 1
counter/views.py

@@ -9,6 +9,7 @@ from graphos.renderers import gchart
9 9
 from graphos.sources.simple import SimpleDataSource
10 10
 from graphos.sources.model import ModelDataSource
11 11
 import random
12
+import math
12 13
 from django.utils import timezone
13 14
 
14 15
 class resetCounterForm(forms.ModelForm):
@@ -43,7 +44,8 @@ def home(request):
43 44
                 if (counter.lastReset.delta.total_seconds())/(24*3600) > maxJSS:
44 45
                     maxJSS = (counter.lastReset.delta.total_seconds())/(24*3600)
45 46
             else:
46
-                counter.CSSclass = "danger"
47
+                counter.CSSclass = "primary"
48
+            counter.opacity = 0.3 + 0.7*math.exp(-(counter.lastReset.delta.total_seconds())/(7*24*3600))
47 49
         counter.lastReset.formatted_delta = format_timedelta(counter.lastReset.delta,locale='fr',threshold=1)
48 50
         counter.isHidden = "hidden"
49 51
     counters = sorted(counters,key=lambda t: t.lastReset.delta)