Beispiel #1
0
    def get_timezone(self, schedule):
        if self.recipient_is_an_individual_contact(self.recipient):
            try:
                timezone_str = self.recipient.get_time_zone()
                if timezone_str:
                    return coerce_timezone_value(timezone_str)
            except ValidationError:
                pass

        if schedule.use_utc_as_default_timezone:
            # See note on Schedule.use_utc_as_default_timezone.
            # When use_utc_as_default_timezone is enabled and the contact has
            # no time zone configured, use UTC.
            return pytz.UTC
        else:
            return self.domain_timezone
Beispiel #2
0
    def timezone(self):
        timezone = None

        if self.recipient_is_an_individual_contact:
            try:
                timezone = self.recipient.get_time_zone()
            except ValidationError:
                pass

        if not timezone:
            timezone = get_timezone_for_domain(self.domain)

        if isinstance(timezone, tzinfo):
            return timezone

        if isinstance(timezone, basestring):
            try:
                return coerce_timezone_value(timezone)
            except ValidationError:
                pass

        return pytz.UTC
Beispiel #3
0
    def timezone(self):
        timezone = None

        if self.recipient_type in ('CommCareCase', 'CommCareUser', 'WebUser'):
            try:
                timezone = self.recipient.get_time_zone()
            except ValidationError:
                pass

        if not timezone:
            timezone = get_timezone_for_domain(self.domain)

        if isinstance(timezone, tzinfo):
            return timezone

        if isinstance(timezone, basestring):
            try:
                return coerce_timezone_value(timezone)
            except ValidationError:
                pass

        return pytz.UTC
Beispiel #4
0
 def to_python(self, value):
     value = super(TimeZoneField, self).to_python(value)
     if value is None:
         return None # null=True
     return coerce_timezone_value(value)
Beispiel #5
0
 def to_python(self, value):
     value = super(TimeZoneField, self).to_python(value)
     if value is None:
         return None  # null=True
     return coerce_timezone_value(value)
Beispiel #6
0
 def get_timezone(self):
     if self.timezone:
         return coerce_timezone_value(self.timezone)
     else:
         return get_timezone_for_domain(self.domain)