# Path: cloudkittydashboard/api/cloudkitty.py
# def cloudkittyclient(request):
# def identify(what, name=False, key=None):


import calendar
import collections
import datetime
import decimal
import time
from horizon import tabs
from cloudkittydashboard.api import cloudkitty as api
        services[service]['hourly'] = collections.OrderedDict(
            sorted(d.items(), key=lambda t: t[0]))

    return services


class CostRepartitionTab(tabs.Tab):
    name = "This month"
    slug = "this_month"
    template_name = 'project/reporting/this_month.html'

    def get_context_data(self, request, **kwargs):
        today = datetime.datetime.today()
        day_start, day_end = calendar.monthrange(today.year, today.month)
        begin = "%4d-%02d-01T00:00:00" % (today.year, today.month)
        end = "%4d-%02d-%02dT23:59:59" % (today.year, today.month, day_end)
        client = api.cloudkittyclient(request)
        data = client.storage.get_dataframes(
            begin=begin, end=end, tenant_id=request.user.tenant_id)
        parsed_data = _do_this_month(data)
        return {'repartition_data': parsed_data}


class ReportingTabs(tabs.TabGroup):
    slug = "reporting_tabs"
    tabs = (CostRepartitionTab, )
    sticky = True


class IndexView(tabs.TabbedTableView):

# Path: cloudkittydashboard/api/cloudkitty.py
# def cloudkittyclient(request):
# def identify(what, name=False, key=None):


# Path: cloudkittydashboard/dashboards/project/reporting/views.py
import calendar
import collections
import datetime
import decimal
import time
from horizon import tabs
from cloudkittydashboard.api import cloudkitty as api

        services[service]['hourly'] = collections.OrderedDict(
            sorted(d.items(), key=lambda t: t[0]))

    return services


class CostRepartitionTab(tabs.Tab):
    name = "This month"
    slug = "this_month"
    template_name = 'project/reporting/this_month.html'

    def get_context_data(self, request, **kwargs):
        today = datetime.datetime.today()
        day_start, day_end = calendar.monthrange(today.year, today.month)
        begin = "%4d-%02d-01T00:00:00" % (today.year, today.month)
        end = "%4d-%02d-%02dT23:59:59" % (today.year, today.month, day_end)
        client = api.cloudkittyclient(request)
        data = client.storage.get_dataframes(
            begin=begin, end=end, tenant_id=request.user.tenant_id)
        parsed_data = _do_this_month(data)
        return {'repartition_data': parsed_data}


class ReportingTabs(tabs.TabGroup):
    slug = "reporting_tabs"
    tabs = (CostRepartitionTab, )
    sticky = True


class IndexView(tabs.TabbedTableView):

    tab_group_class = ReportingTabs