diff sat_website/forms.py @ 96:c868187b8d00

add the current date in the subscription form's results
author souliane <souliane@mailoo.org>
date Thu, 25 Jun 2015 15:06:07 +0200
parents dc8a30f6c369
children d0cd185f9b61
line wrap: on
line diff
--- a/sat_website/forms.py	Thu Jun 25 14:39:52 2015 +0200
+++ b/sat_website/forms.py	Thu Jun 25 15:06:07 2015 +0200
@@ -26,6 +26,7 @@
 from django import forms
 from django.conf import settings
 from collections import OrderedDict
+from time import strftime
 import unicodecsv
 import utils
 import re
@@ -152,6 +153,13 @@
         if not self.is_valid():
             return None
         results = []
+
+        date = strftime("%Y-%m-%d")
+        if user_readable:
+            results.append((_(u"Date"), date))
+        else:
+            results.append(('date', date))
+
         for field in self:
             if isinstance(field.field, Section):
                 continue  # filter out section fields
@@ -174,10 +182,12 @@
                 if isinstance(field.field, ChoiceField):
                     value = field.field.choice_label(value)
             results.append((key, value))
+
         if user_readable:
             results.append((_(u'Language'), utils.get_language_name_local(get_language())))
         else:
             results.append(('lang', get_language()))
+
         return results
 
     def result_as_dict(self, user_readable=True):