enhance mock timeline form and listing
authorroot <gtsouk@cslab.ece.ntua.gr>
Thu, 20 Sep 2012 15:02:31 +0000 (18:02 +0300)
committerroot <gtsouk@cslab.ece.ntua.gr>
Fri, 21 Sep 2012 12:05:20 +0000 (15:05 +0300)
snf-astakos-app/astakos/im/forms.py
snf-astakos-app/astakos/im/templates/im/timeline.html
snf-astakos-app/astakos/im/views.py

index dd21d46..061c946 100644 (file)
@@ -102,7 +102,7 @@ class LocalUserCreationForm(UserCreationForm):
             self.fields.keyOrder.extend(['recaptcha_challenge_field',
                                          'recaptcha_response_field', ])
         if get_latest_terms():
-            self.fields.keyOrder.append('has_signed_terms')
+               self.fields.keyOrder.append('has_signed_terms')
 
         if 'has_signed_terms' in self.fields:
             # Overriding field label since we need to apply a link
@@ -603,15 +603,20 @@ class TimelineForm(forms.Form):
     )
     start_date = forms.DateTimeField()
     end_date = forms.DateTimeField()
-    action = forms.ChoiceField(choices=(), required=False)
-    
+    details = forms.BooleanField(required=False, label="detailed listing?")
+    operation = forms.ChoiceField(choices = (
+                        ('',                '[Choose Charging Method]'),
+                        ('charge_usage',    'Charge Usage'),
+                        ('charge_traffic',  'Charge Traffic')
+                ))
     def clean(self):
         super(TimelineForm, self).clean()
         d = self.cleaned_data
         if 'resource' in d:
             d['resource'] = str(d['resource'])
         if 'start_date' in d:
-            d['start_date'] = d['start_date'].strftime("%Y-%m-%dT%H:%M:%S.%f")
+            d['start_date'] = d['start_date'].strftime("%Y-%m-%dT%H:%M:%S.%f")[:24]
         if 'end_date' in d:
-            d['end_date'] = d['end_date'].strftime("%%Y-%m-%dT%H:%M:%S.%f")
-        return d
\ No newline at end of file
+            d['end_date'] = d['end_date'].strftime("%Y-%m-%dT%H:%M:%S.%f")[:24]
+        return d
+
index 516f06e..d2d1c30 100644 (file)
            </form>
        </div>
 </div>
-{% for o in l %}
+<div class="timeline">
+<table>
+    <tr style="color:black; font-weight:bold;">
+    {% for i in timeline_header %}
+        <td>{{i}}</td>
+    {% endfor %}
+    </tr>
+{% for o in timeline_body %}
+    <tr style="color:black">
     {% for i in o %}
-        {{i}}
+        <td>{{i}}</td>
     {% endfor %}
-    <br>
+    </tr>
 {% endfor %}
+</table>
+</div>
 {% endblock %}
index 4046c15..fd50920 100644 (file)
@@ -365,10 +365,10 @@ def signup(request, template_name='im/signup.html', on_success='im/signup_comple
                         logger.log(LOGGING_LEVEL, msg)
                 if user and user.is_active:
                     next = request.POST.get('next', '')
-                   transaction.commit()
+                    transaction.commit()
                     return prepare_response(request, user, next=next)
                 messages.add_message(request, status, message)
-               transaction.commit()
+                transaction.commit()
                 return render_response(on_success,
                                        context_instance=get_context(request, extra_context))
             except SendMailError, e:
@@ -1028,26 +1028,30 @@ def timeline(request):
     l = []
     if request.method == 'POST':
         data = request.POST
-        l =[(u'test/apples', u'2012-09-20T11:39:53.1797', 192172055040L, 25569215632749L),
-            (u'test/pears/kate.jpg', u'2012-09-20T11:45:14.1153', 381640896L, 25626036449581L),
-            (u'test/pears/kate_beckinsale.jpg', u'2012-09-20T11:45:14.5830', 0L, 25626036449581L),
-            (u'test/pears/How To Win Friends And Influence People.pdf', u'2012-09-20T11:45:15.0694', 0L, 25626036449581L),
-            (u'test/pears/moms_birthday.jpg', u'2012-09-20T11:45:15.5615', 0L, 25626036449581L),
-            (u'test/pears/poodle_strut.mov', u'2012-09-20T11:45:16.0290', 0L, 25626036449581L),
-            (u'test/pears/Disturbed - Down With The Sickness.mp3', u'2012-09-20T11:45:16.4950', 0L, 25626036449581L),
-            (u'test/pears/army_of_darkness.avi', u'2012-09-20T11:45:16.9844', 0L, 25626036449581L),
-            (u'test/pears/the_mad.avi', u'2012-09-20T11:45:17.4516', 0L, 25626036449581L),
-            (u'test/apples/photos/animals/dogs/poodle.jpg', u'2012-09-20T11:45:17.9281', 0L, 25626036449581L),
-            (u'test/apples/photos/animals/dogs/terrier.jpg', u'2012-09-20T11:45:18.3918', 0L, 25626036449581L),
-            (u'test/apples/photos/animals/cats/persian.jpg', u'2012-09-20T11:45:18.8626', 0L, 25626036449581L),
-            (u'test/apples/photos/animals/cats/siamese.jpg', u'2012-09-20T11:45:19.3686', 0L, 25626036449581L),
-            (u'test/apples/photos/plants/fern.jpg', u'2012-09-20T11:45:19.8464', 0L, 25626036449581L),
-            (u'test/apples/photos/plants/rose.jpg', u'2012-09-20T11:45:20.7334', 0L, 25626036449581L)]
-    
+        #l =[(u'test/apples', u'2012-09-20T11:39:53.1797', 192172055040L, 25569215632749L),
+        #    (u'test/pears/kate.jpg', u'2012-09-20T11:45:14.1153', 381640896L, 25626036449581L),
+        #    (u'test/pears/kate_beckinsale.jpg', u'2012-09-20T11:45:14.5830', 0L, 25626036449581L),
+        #    (u'test/pears/How To Win Friends And Influence People.pdf', u'2012-09-20T11:45:15.0694', 0L, 25626036449581L),
+        #    (u'test/pears/moms_birthday.jpg', u'2012-09-20T11:45:15.5615', 0L, 25626036449581L),
+        #    (u'test/pears/poodle_strut.mov', u'2012-09-20T11:45:16.0290', 0L, 25626036449581L),
+        #    (u'test/pears/Disturbed - Down With The Sickness.mp3', u'2012-09-20T11:45:16.4950', 0L, 25626036449581L),
+        #    (u'test/pears/army_of_darkness.avi', u'2012-09-20T11:45:16.9844', 0L, 25626036449581L),
+        #    (u'test/pears/the_mad.avi', u'2012-09-20T11:45:17.4516', 0L, 25626036449581L),
+        #    (u'test/apples/photos/animals/dogs/poodle.jpg', u'2012-09-20T11:45:17.9281', 0L, 25626036449581L),
+        #    (u'test/apples/photos/animals/dogs/terrier.jpg', u'2012-09-20T11:45:18.3918', 0L, 25626036449581L),
+        #    (u'test/apples/photos/animals/cats/persian.jpg', u'2012-09-20T11:45:18.8626', 0L, 25626036449581L),
+        #    (u'test/apples/photos/animals/cats/siamese.jpg', u'2012-09-20T11:45:19.3686', 0L, 25626036449581L),
+        #    (u'test/apples/photos/plants/fern.jpg', u'2012-09-20T11:45:19.8464', 0L, 25626036449581L),
+        #    (u'test/apples/photos/plants/rose.jpg', u'2012-09-20T11:45:20.7334', 0L, 25626036449581L)]
+        timeline_header = (data['entity'], data['resource'],
+                           data['start_date'], data['end_date'],
+                           data['details'], data['operation'])
+        timeline_body = [timeline_header] * 2
     form = TimelineForm(data)
     if form.is_valid():
         print '>>>', form.cleaned_data
     return render_response(template='im/timeline.html',
                            context_instance=get_context(request),
                            form=form,
-                           l=l)
\ No newline at end of file
+                           timeline_header=timeline_header,
+                           timeline_body=timeline_body)