app/soc/views/helper/surveys.py
changeset 2442 dd1f94c3594c
parent 2439 7fac0da44bbf
child 2451 c58a7ea6c126
equal deleted inserted replaced
2441:a24b2b4af87d 2442:dd1f94c3594c
    24   ]
    24   ]
    25 
    25 
    26 
    26 
    27 from itertools import chain
    27 from itertools import chain
    28 import datetime
    28 import datetime
       
    29 import logging
    29 
    30 
    30 from google.appengine.ext.db import djangoforms
    31 from google.appengine.ext.db import djangoforms
    31 
    32 
    32 from django import forms
    33 from django import forms
    33 from django.forms import widgets
    34 from django.forms import widgets
    93 
    94 
    94     if not self.survey_content:
    95     if not self.survey_content:
    95       return
    96       return
    96 
    97 
    97     self.survey_fields = {}
    98     self.survey_fields = {}
    98     schema = eval(self.survey_content.schema)
    99     schema = SurveyContentSchema(self.survey_content.schema)
    99     has_record = (not self.editing) and self.survey_record
   100     has_record = (not self.editing) and self.survey_record
   100     extra_attrs = {}
   101     extra_attrs = {}
   101 
   102 
   102     # figure out whether we want a read-only view
   103     # figure out whether we want a read-only view
   103     if not self.editing:
   104     if not self.editing:
   104       # only survey taking can be read-only
   105       # only survey taking can be read-only
   105       read_only = self.read_only
   106       read_only = self.read_only
   106 
   107 
   107       if not read_only:
   108       if not read_only:
   108         deadline = self.survey_content.survey_parent.get().deadline
   109         deadline = self.survey_content.survey_parent.get().survey_end
   109         read_only =  deadline and (datetime.datetime.now() > deadline)
   110         read_only =  deadline and (datetime.datetime.now() > deadline)
   110       else:
   111       else:
   111         extra_attrs['disabled'] = 'disabled'
   112         extra_attrs['disabled'] = 'disabled'
   112 
   113 
   113     # add unordered fields to self.survey_fields
   114     # add unordered fields to self.survey_fields