Пример #1
0
def global_settings(request):
	# Return any necessary settings values.
	return {
		'GA_ACCOUNT': settings.GA_ACCOUNT,
		'GOOGLE_WEBMASTER_VERIFICATION': settings.GOOGLE_WEBMASTER_VERIFICATION,
		'FALLBACK_EVENT_DESCRIPTION': settings.FALLBACK_EVENT_DESCRIPTION,
		'CANONICAL_ROOT': settings.CANONICAL_ROOT,
		'CANONICAL_URL': get_canonical(request),
		'EARLIEST_VALID_DATE': get_earliest_valid_date(date_format='%m/%d/%Y'),
		'LATEST_VALID_DATE': get_latest_valid_date(date_format='%m/%d/%Y')
	}
Пример #2
0
    def clean(self):
        cleaned_data = super(EventInstanceForm, self).clean()

        start = cleaned_data.get('start')
        end = cleaned_data.get('end')
        until = cleaned_data.get('until')
        location = cleaned_data.get('location')
        new_location_title = cleaned_data.get('new_location_title')
        new_location_url = cleaned_data.get('new_location_url')

        if start and end:
            if start > end:
                self._errors['end'] = self.error_class(['The end day/time must occur after the start day/time'])
            if not is_date_in_valid_range(start.date()):
                self._errors['start'] = self.error_class(['Please provide a start date that falls between %s and %s' % (get_earliest_valid_date(date_format='%m/%d/%Y'), get_latest_valid_date(date_format='%m/%d/%Y'))])
            if not is_date_in_valid_range(end.date()):
                self._errors['end'] = self.error_class(['Please provide a end date that falls between %s and %s' % (get_earliest_valid_date(date_format='%m/%d/%Y'), get_latest_valid_date(date_format='%m/%d/%Y'))])
        else:
            if not start:
                self._errors['start'] = self.error_class(['Please enter a valid date/time, e.g. 11/16/2014 at 12:45 PM'])
            if not end:
                self._errors['end'] = self.error_class(['Please enter a valid date/time, e.g. 11/16/2014 at 12:45 PM'])

        if until:
            if not is_date_in_valid_range(until):
                self._errors['until'] = self.error_class(['Please provide an until date that falls between %s and %s' % (get_earliest_valid_date(date_format='%m/%d/%Y'), get_latest_valid_date(date_format='%m/%d/%Y'))])
            if end.date() >= until:
                self._errors['until'] = self.error_class(['The until date must fall after the end date/time'])

        if not location:
            if new_location_title:
                if not new_location_url:
                    self._errors['new_location_url'] = self.error_class(['URL needs to be provided for new locations'])
            else:
                self._errors['location'] = self.error_class(['No location was specified'])

        return cleaned_data