def get_report_view(request):
 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 {}

def get_report_view ( request ) : 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 { }
parse and validate a pair of yyymmdd date strings .