Explorar el Código

Changed seum reason input

Denis Merigoux hace 9 años
padre
commit
fcfe795184

+ 10 - 3
counter/templates/baseTemplate.html

@@ -10,7 +10,7 @@
10 10
 	<link rel="shortcut icon" type="image/png" href="{{STATIC_URL}}/favicon.ico"/>
11 11
 	<title>SeumBook™ – {% block title %}{% endblock %}</title>
12 12
 
13
-	{# Load the tag library #} {% load bootstrap3 %} {# Load CSS and JavaScript #} {% bootstrap_css %} {% bootstrap_javascript %} {# Display django.contrib.messages as Bootstrap alerts #} {% bootstrap_messages %}
13
+	{# Load the tag library #} {% load bootstrap3 %} {# Load CSS and JavaScript #} {% bootstrap_css %} {# Display django.contrib.messages as Bootstrap alerts #} {% bootstrap_messages %}
14 14
 
15 15
 	<style>
16 16
 		body {
@@ -35,8 +35,8 @@
35 35
 		}
36 36
 
37 37
 		.counter-link, .counter-link:hover {
38
-  	color: inherit; /* blue colors for links too */
39
-  	text-decoration: inherit; /* no underline */
38
+  			color: inherit; /* blue colors for links too */
39
+  			text-decoration: inherit; /* no underline */
40 40
 		}
41 41
 	</style>
42 42
 
@@ -45,6 +45,13 @@
45 45
 		google.load("visualization", "1", {
46 46
 			packages: ["corechart"]
47 47
 		});
48
+
49
+		function revealSeumForm(counterID) {
50
+			document.getElementById('counter'+counterID).style.display='inline';
51
+			document.getElementById('button'+counterID).style.display='none';
52
+			document.getElementById('reason'+counterID).focus();
53
+			document.getElementById('container'+counterID).style.height='200px';
54
+		}
48 55
 	</script>
49 56
 </head>
50 57
 <section id="content">

+ 2 - 2
counter/templates/counterTemplate.html

@@ -20,13 +20,13 @@
20 20
 
21 21
           <p>{{ counter.lastReset.reason }}</p>
22 22
           <div class="text-center">
23
-            <button id="button{{counter.id}}" class="btn btn-default btn-danger" type="button" onclick="getElementById('counter{{counter.id}}').style.display='inline';getElementById('button{{counter.id}}').style.display='none';getElementById('container{{counter.id}}').style.height='225px';">Remettre à zéro</button>
23
+            <button id="button{{counter.id}}" class="btn btn-default btn-danger" type="button" onclick="revealSeumForm({{counter.id}})">Remettre à zéro</button>
24 24
           </div>
25 25
           <form style="display:none" id="counter{{counter.id}}" action="{% url 'reset-counter' %}" method="post">
26 26
             {% csrf_token %}
27 27
             <div class="form-group">
28 28
               <label for="reason">Motif du seum :</label>
29
-              <textarea class="form-control" name="reason"></textarea>
29
+              <input id="reason{{counter.id}}" type="text" class="form-control" name="reason"></input>
30 30
             </div>
31 31
             <input type="hidden" name="counter" value="{{counter.id}}"></input>
32 32
             <input type="hidden" name="redirect" value="{% url 'counter' id_counter=counter.id %}"></input>

+ 2 - 2
counter/templates/homeTemplate.html

@@ -51,13 +51,13 @@
51 51
 
52 52
 					<p>{{ myCounter.lastReset.reason }}</p>
53 53
 					<div class="text-center" id="button{{myCounter.id}}">
54
-						<button class="btn btn-default btn-danger" type="button" onclick="getElementById('counter{{myCounter.id}}').style.display='inline';getElementById('button{{myCounter.id}}').style.display='none';getElementById('container{{myCounter.id}}').style.height='225px';">Remettre à zéro</button>
54
+						<button class="btn btn-default btn-danger" type="button" onclick="revealSeumForm({{myCounter.id}})">Remettre à zéro</button>
55 55
 					</div>
56 56
 					<form style="display:none" id="counter{{myCounter.id}}" action="{% url 'reset-counter' %}" method="post">
57 57
 						{% csrf_token %}
58 58
 						<div class="form-group">
59 59
 							<label for="reason">Motif du seum :</label>
60
-							<textarea class="form-control" name="reason"></textarea>
60
+							<input id="reason{{myCounter.id}}" type="text" class="form-control" name="reason"></input>
61 61
 						</div>
62 62
 						<input type="hidden" name="counter" value="{{myCounter.id}}"></input>
63 63
 						<input type="hidden" name="redirect" value="{% url 'home' %}"></input>

+ 5 - 5
counter/urls.py

@@ -4,10 +4,10 @@ from counter.rss import SeumFeed
4 4
 from . import views
5 5
 
6 6
 urlpatterns = [
7
-    url(r'^$', views.home,name="home"),
8
-    url(r'^reset-counter',views.resetCounter,name="reset-counter"),
7
+    url(r'^$', views.home, name="home"),
8
+    url(r'^reset-counter', views.resetCounter, name="reset-counter"),
9 9
     url(r'^counter/(?P<id_counter>\d+)$', views.counter, name="counter"),
10
-    url(r'^set-my-counter',views.setMyCounter,name="set-my-counter"),
11
-    url(r'^reset-my-counter',views.resetMyCounter,name="reset-my-counter"),
12
-    url(r'^rss',SeumFeed())
10
+    url(r'^set-my-counter', views.setMyCounter, name="set-my-counter"),
11
+    url(r'^reset-my-counter', views.resetMyCounter, name="reset-my-counter"),
12
+    url(r'^rss', SeumFeed())
13 13
 ]

+ 4 - 1
counter/views.py

@@ -4,7 +4,6 @@ from babel.dates import format_timedelta, format_datetime
4 4
 from datetime import datetime, timedelta
5 5
 from django import forms
6 6
 from django.http import HttpResponseRedirect
7
-from django.core import serializers
8 7
 from django.core.mail import EmailMessage
9 8
 from graphos.renderers import gchart
10 9
 from graphos.sources.simple import SimpleDataSource
@@ -14,6 +13,7 @@ import math
14 13
 import copy
15 14
 from django.utils import timezone
16 15
 
16
+
17 17
 def home(request):
18 18
     # JSS above this limit will not be displayed on the col graph
19 19
     JSS_limit = 7
@@ -51,6 +51,7 @@ def home(request):
51 51
         myCounter = None
52 52
         chooseCounter = True
53 53
 
54
+    # Building data for counters display
54 55
     counters = Counter.objects.all()
55 56
     for counter in counters:
56 57
         lastReset = Reset.objects.filter(
@@ -152,6 +153,7 @@ def home(request):
152 153
             'legend': 'none',
153 154
             'height': 90
154 155
         })
156
+
155 157
     # Graph of greatest seumers
156 158
     seumCounts = []
157 159
     for counter in counters:
@@ -171,6 +173,7 @@ def home(request):
171 173
             'vAxis': {'title': 'Nombre de seums'},
172 174
             'hAxis': {'title': 'Trigramme'},
173 175
         })
176
+
174 177
     # Graph of seum activity
175 178
     resets = Reset.objects.filter(
176 179
         timestamp__gte=timezone.now() - timedelta(days=365))