Ejemplo n.º 1
0
def get_daterange_or_404(start, end):
    """Parse and validate a pair of YYYYMMDD date strings."""
    dates = DateForm(data={"start": start, "end": end})
    if not dates.is_valid():
        logger.info("Dates parsed were not valid.")
        raise http.Http404

    return (dates.cleaned_data["start"], dates.cleaned_data["end"])
Ejemplo n.º 2
0
def get_daterange_or_404(start, end):
    """Parse and validate a pair of YYYYMMDD date strings."""
    dates = DateForm(data={'start': start, 'end': end})
    if not dates.is_valid():
        logger.info('Dates parsed were not valid.')
        raise http.Http404

    return (dates.cleaned_data['start'], dates.cleaned_data['end'])
Ejemplo n.º 3
0
def get_daterange_or_404(start, end):
    """Parse and validate a pair of YYYYMMDD date strings."""
    dates = DateForm(data={'start': start, 'end': end})
    if not dates.is_valid():
        logger.info('Dates parsed were not valid.')
        raise http.Http404

    return (
        dates.cleaned_data['start'],
        dates.cleaned_data['end']
    )
Ejemplo n.º 4
0
def get_report_view(request):
    """Parse and validate a pair of YYYMMDD date strings."""
    dates = DateForm(data=request.GET)
    if not dates.is_valid():
        logger.info("Dates parsed were not valid.")
        return {}

    if dates.cleaned_data.get("start") and dates.cleaned_data.get("end"):
        return {
            "range": "custom",
            "start": dates.cleaned_data["start"].strftime("%Y%m%d"),
            "end": dates.cleaned_data["end"].strftime("%Y%m%d"),
        }

    elif dates.cleaned_data.get("last"):
        return {"range": dates.cleaned_data["last"], "last": str(dates.cleaned_data["last"]) + " days"}

    logger.info('Missing "start and end" or "last"')
    return {}
Ejemplo n.º 5
0
def get_report_view(request):
    """Parse and validate a pair of YYYMMDD date strings."""
    dates = DateForm(data=request.GET)
    if not dates.is_valid():
        logger.info('Dates parsed were not valid.')
        return {}

    if dates.cleaned_data.get('start') and dates.cleaned_data.get('end'):
        return {
            'range': 'custom',
            'start': dates.cleaned_data['start'].strftime('%Y%m%d'),
            'end': dates.cleaned_data['end'].strftime('%Y%m%d'),
        }

    elif dates.cleaned_data.get('last'):
        return {
            'range': dates.cleaned_data['last'],
            'last': str(dates.cleaned_data['last']) + ' days'
        }

    logger.info('Missing "start and end" or "last"')
    return {}
Ejemplo n.º 6
0
def get_report_view(request):
    """Parse and validate a pair of YYYMMDD date strings."""
    dates = DateForm(data=request.GET)
    if not dates.is_valid():
        logger.info('Dates parsed were not valid.')
        return {}

    if dates.cleaned_data.get('start') and dates.cleaned_data.get('end'):
        return {
            'range': 'custom',
            'start': dates.cleaned_data['start'].strftime('%Y%m%d'),
            'end': dates.cleaned_data['end'].strftime('%Y%m%d'),
        }

    elif dates.cleaned_data.get('last'):
        return {
            'range': dates.cleaned_data['last'],
            'last': str(dates.cleaned_data['last']) + ' days'
        }

    logger.info('Missing "start and end" or "last"')
    return {}