示例#1
0
 def get_rrule(self):
     if not self.cleaned_data:
         return None
         
     if self.cleaned_data.has_key("repeats") and self.cleaned_data["repeats"] == "no":
         params = {}
     else: 
         params = self._build_rrule_params() 
         
     return rr2t(dtstart=self.cleaned_data['start_time'], **params)
示例#2
0
 def save(self, series):        
     """
     returns the Event these readings are associated with
     """
     
     # This creates the occurences by calling Event.add_occurrences and gives them the series as a foreign key. It does not
     # save the series.
     super(MonthlyReadingMultipleOccurrenceForm, self).save(series)
     
     # this code also appears in the super save method, but params is local so 
     # we don't have access to it here. but we need params to save as part of the
     # series.
     if self.cleaned_data['repeats'] == 'no':
          params = {}
     else:
          params = self._build_rrule_params()        
          
     # We need to use params to generate the rrule which we will save to the db
     # as part of the series. We need it to use when describing this series.
     series.rrule = rr2t(dtstart=self.cleaned_data['start_time'], **params)
     series.save()
     
     return series