Beispiel #1
0
    def get_billing_types_data(self):
        try:
            data = get_billing_types(self.request)
            return data

        except Exception:
            error_message = _('Unable to get billing types')
            exceptions.handle(self.request, error_message)
            return []
Beispiel #2
0
    def __init__(self, request, *args, **kwargs):
        super(UpdateAccountGenericAction,
              self).__init__(request, *args, **kwargs)

        # populate billing types
        # TODO (div): switch on astudeclient lib [get_billing_types()]
        billing_types = dict([(str(billing_type['id']), billing_type['name'])
                              for billing_type in get_billing_types(request)])
        self.fields['billing_type_name'].widget.attrs['value'] = billing_types[
            str(self.initial['billing_type'])]
Beispiel #3
0
    def __init__(self, request, *args, **kwargs):
        super(CreateAccountGenericAction,
              self).__init__(request, *args, **kwargs)

        # populate existing projects
        #Keystone connection
        #(_projects, _) = keystone.tenant_list(self.request)
        (_projects, _) = get_tenants(self.request)
        projects = [(project.id, project.name) for project in _projects]
        self.fields['project_id'].choices = projects

        # populate billing types
        # TODO (div): switch on astudeclient lib [get_billing_types()]
        billing_types = [(billing_type['id'], billing_type['name'])
                         for billing_type in get_billing_types(request)]
        self.fields['billing_type'].choices = billing_types
Beispiel #4
0
def gen_billing_types(request):
    data = []
    for item in get_billing_types(request):
        data.append((item['id'], _(item['name'])))
    return data