def homepage(request): """Front page of the default OpenBlock theme. """ end_date = today() start_date = end_date - datetime.timedelta(days=settings.DEFAULT_DAYS) end_date += datetime.timedelta(days=1) manager = get_schema_manager(request) sparkline_schemas = list(manager.filter(allow_charting=True, is_special_report=False)) # Order by slug to ensure case-insensitive ordering. (Kind of hackish.) lt_list = LocationType.objects.filter(is_significant=True).order_by('slug').extra(select={'count': 'select count(*) from db_location where is_public=True and location_type_id=db_locationtype.id'}) street_count = Street.objects.count() more_schemas = manager.filter(allow_charting=False).order_by('name') # Get the public records. date_charts = get_date_chart_agg_model(sparkline_schemas, start_date, end_date, AggregateDay) empty_date_charts, non_empty_date_charts = [], [] for chart in date_charts: if chart['total_count']: non_empty_date_charts.append(chart) else: empty_date_charts.append(chart) non_empty_date_charts.sort(lambda a, b: cmp(b['total_count'], a['total_count'])) empty_date_charts.sort(lambda a, b: cmp(a['schema'].plural_name, b['schema'].plural_name)) return eb_render(request, 'homepage.html', { 'location_type_list': lt_list, 'street_count': street_count, 'more_schemas': more_schemas, 'non_empty_date_charts': non_empty_date_charts, 'empty_date_charts': empty_date_charts, 'num_days': settings.DEFAULT_DAYS, 'default_lon': settings.DEFAULT_MAP_CENTER_LON, 'default_lat': settings.DEFAULT_MAP_CENTER_LAT, 'default_zoom': settings.DEFAULT_MAP_ZOOM, 'bodyclass': 'homepage', 'breadcrumbs': breadcrumbs.home({}), 'map_configuration': _preconfigured_map({}) })
def base_crumbs(): crumbs = breadcrumbs.home({}) crumbs.append(('Data Dashboard', reverse('dashboard'))) return crumbs