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


from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from horizon import tables
from cloudkittydashboard.api import cloudkitty as api
    def allowed(self, request, module=None):
        self.enabled = module.get('enabled')
        if self.enabled:
            self.current_present_action = DISABLE
        else:
            self.current_present_action = ENABLE
        return True

    def action(self, request, obj_id):
        client = api.cloudkittyclient(request)
        module = client.rating.get_module(module_id=obj_id)
        self.enabled = module.get('enabled', False)
        self.current_past_action = DISABLE if self.enabled else ENABLE
        client.rating.update_module(module_id=obj_id,
                                    enabled=(not self.enabled))


def get_details_link(datum):
    if datum.module_id:
        url = "horizon:admin:rating_modules:module_details"
        return reverse(url, kwargs={'module_id': datum.module_id})


class ModulesTable(tables.DataTable):
    name = tables.Column('name', verbose_name=_("Name"), link=get_details_link)
    description = tables.Column('description', verbose_name=_("Description"))
    hot_config = tables.Column('hot-config', verbose_name=_("Configurable"))
    priority = tables.Column('priority', verbose_name=_("Priority"))
    enabled = tables.Column('enabled', verbose_name=_("Enabled"))


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


# Path: cloudkittydashboard/dashboards/admin/modules/tables.py
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from horizon import tables
from cloudkittydashboard.api import cloudkitty as api

    def allowed(self, request, module=None):
        self.enabled = module.get('enabled')
        if self.enabled:
            self.current_present_action = DISABLE
        else:
            self.current_present_action = ENABLE
        return True

    def action(self, request, obj_id):
        client = api.cloudkittyclient(request)
        module = client.rating.get_module(module_id=obj_id)
        self.enabled = module.get('enabled', False)
        self.current_past_action = DISABLE if self.enabled else ENABLE
        client.rating.update_module(module_id=obj_id,
                                    enabled=(not self.enabled))


def get_details_link(datum):
    if datum.module_id:
        url = "horizon:admin:rating_modules:module_details"
        return reverse(url, kwargs={'module_id': datum.module_id})


class ModulesTable(tables.DataTable):
    name = tables.Column('name', verbose_name=_("Name"), link=get_details_link)
    description = tables.Column('description', verbose_name=_("Description"))
    hot_config = tables.Column('hot-config', verbose_name=_("Configurable"))
    priority = tables.Column('priority', verbose_name=_("Priority"))
    enabled = tables.Column('enabled', verbose_name=_("Enabled"))


    class Meta(object):